Replace Gtk::manage() with std::make_unique<>() and std::move() ?
@murrayc
Submitted by Murray Cumming Link to original bug (#761665)
Description
Created attachment 320569 0001-Trying-to-replace-Gtk-manage-with-std-make_unique-an.patch
This patch tries to replace Gtk::manage() with std::make_unique() and std::move().
* gtk/src/*.[hg|ccg]: Add overloads for add(), append(), attach(), etc,
methods, taking a std::unique_ptr`<>` by value.
* demos/tests: Change uses of Gtk::manage() followed by add(*thing)
to std::make_unique`<>`() followed by add(std::move(thing)).
This required some lines of code to be rearranged to avoid us using
something after it has been std::move()ed. Typically the
add(std::move(thing)) lines end up all being at the end of the method.
Some API currently makes it impossible to do this properly.
See the
//TODO: Use after move
comments.
There are also still some missing method overloads, marked by TODO
comments.
This was inspired by parts of Herb Sutter's
"Back to the Basics: Essentials of Modern C++ Style" talk:
https://www.youtube.com/watch?v=xnqTKD8uD64
(slides: https://github.com/CppCon/CppCon2014/blob/master/Presentations/Back%20to%20the%20Basics!%20Essentials%20of%20Modern%20C%2B%2B%20Style/Back%20to%20the%20Basics!%20Essentials%20of%20Modern%20C%2B%2B%20Style%20-%20Herb%20Sutter%20-%20CppCon%202014.pdf )
Patch 320569, "0001-Trying-to-replace-Gtk-manage-with-std-make_unique-an.patch":
0001-Trying-to-replace-Gtk-manage-with-std-make_unique-an.patch
Version: 3.17.x