If you inherit from boost::noncopyable
you will get a compile time error when the copy constructor is attempted. I have found that using this the error messages (with MSVC) are useless, since they generally don't point to the line that caused the error. The alternative is to declare a copy-constructor private
and leave it undefined, or define it with a BOOST_STATIC_ASSERT(false)
. If you are working with C++11 you can also delete
your copy constructor:
class nocopy
{
nocopy( nocopy const& ) = delete;
};