On 04/26/17 03:00, Gavin Lambert via Boost wrote:
On 25/04/2017 22:23, Andrey Semashev via Boost wrote:
I think in C++11 noncopyable should be considered deprecated and generally avoided. It affects class hierarchy, adds an extra namespace to ADL and may not be optimized away with EBO. I would even avoid it in C++03 as well. It follows that nonmoveable makes no sense in C++11. Just use the language features you have.
boost::noncopyable has protection so it won't ADL to the boost:: namespace.
Yes, but it doesn't remove the dummy namespace from ADL.
Also, since it does not explicitly declare move constructors either way, anything that inherits from boost::noncopyable is also non-moveable by default, which is usually what you want.
Deleted copy constructor/assignment have the same property.
The C++11 way, however, would be to use a std::unique_ptr as a private member of your class (eg. for PIMPL), which automatically makes your class moveable but not copyable via Rule of Zero.
Or use shared_ptr if you want your class to be copyable but have all copies point to a shared implementation (handle-body or reference idiom).
That's fine if your design already employs pimpl (or you're willing to change it that way). But otherwise why would you want to add a data member to implement movability?