May 2017
Intermediate to advanced
590 pages
17h 18m
English
The original control class was both copyable and movable:
control c; c.resize(100, 20); c.set_text("sample"); c.hide(); control c2 = c; // copy c2.show(); control c3 = std::move(c2); // move c3.hide();
The refactored control class is only movable, not copyable. In order to make it both copyable and movable, we must provide the copy constructor and copy assignment operator and both the move constructor and move assignment operator. The latter ones can be defaulted, but the former ones must be explicitly implemented to create a new control_pimpl object from the object that it is copied from. The following code shows the implementation of the control class that is both copyable and movable:
class control_copyable { std::unique_ptr<control_pimpl, ...Read now
Unlock full access