boost::noncopyable
is this:
class noncopyable
{
protected:
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
BOOST_CONSTEXPR noncopyable() = default;
~noncopyable() = default;
#else
noncopyable() {}
~noncopyable() {}
#endif
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
noncopyable( const noncopyable& ) = delete;
noncopyable& operator=( const noncopyable& ) = delete;
#else
private: // emphasize the following members are private
noncopyable( const noncopyable& );
noncopyable& operator=( const noncopyable& );
#endif
};
Usage is
struct X : private boost::noncopyable {};
If you do not want boost, it is straightforward to write your own my::noncopyable
. The protected
constructor and destructor are merely to make clear that the class is meant to be used as base class. Without the pre-C++11 conditions, the class is just:
class noncopyable
{
protected:
constexpr noncopyable() = default;
~noncopyable() = default;
noncopyable( const noncopyable& ) = delete;
noncopyable& operator=( const noncopyable& ) = delete;
};
The macro you are asking for does not exist. As Sergey pointed out in a comment, you would at least have to pass the name of the class to the macro, which makes the point of typing less moot.
Last but not least, I suggest you to read this answer which makes some good points against a noncopyable
base class and for spelling out the deleted member functions. Don't try to be too lazy. Less typing is not always the way to cleaner code.