#include <boost/utility.hpp>
class A : public boost::noncopyable {};
int main()
{
A a;
A b(a);
return 0;
}
g++ -Wall -I\boost_1_33_1 -c noncopy.cpp
noncopy.cpp: In copy constructor `A::A(const A&)':
/boost_1_33_1/boost/noncopyable.hpp:27: error:
`boost::noncopyable_::noncopyable
::noncopyable(const boost::noncopyable_::noncopyable&)' is private
noncopy.cpp:9: error: within this context
You've pretty much answered the question already. You don't want people
making a function like:
void profoundlyUselessFunction(const boost::noncopyable &);
The typical use of boost::noncopyable is a "implemented in terms of"
relationship, which is best modeled by inheriting privately.
From a technical standpoint, since everything interesting in
boost::noncopyable is private already, whether you inherit publicly or
privately makes very little difference.
--
Alan Johnson