Let's say I want to create some classes to manage resources that shouldn't be copied nor moved, which would be the minimal class to extend and avoid mistakes?
The idea is that by extending the class, I end on the safe side of the 0/3/5 rules.
I have this in mind, which apparently works.
class NOCOPYNOMOVE {
NOCOPYNOMOVE(NOCOPYNOMOVE &v) = delete;
NOCOPYNOMOVE(NOCOPYNOMOVE &&v) = delete;
NOCOPYNOMOVE& operator=(NOCOPYNOMOVE &r) = delete;
NOCOPYNOMOVE& operator=(NOCOPYNOMOVE &&r) = delete;
};
class Foo: private NOCOPYNOMOVE {
public:
Foo() {}
~Foo() {}
};
ALL_CAPSname, as it is conventionally by every convention used for macrosconstin copy constructor/assignment, so the usual form should be preferredNOCOPYNOMOVEin some namespace, it may trigger unintended ADL.boost::noncopyablesolves it by putting the definition innoncopyable_namespace, see the implementation