why does boost::noncopyable require inheritance
Because sizeof(boost::noncopyable)!=0
. So in this case your class size will be bigger.
Here you can read about the empty base optimization. (look at section "4.7: The Empty Member Optimization").
Edit: The fact, that noncopyable doesn't have public constructors makes it useless for any other use, while classes with public constructor could also be used for other wrong purposes. This is a another reason, why boost chose this approach.
If you could use noncopyable
as a member, it would require a public default constructor and destructor. Then people could create instances of noncopyable
or even use it as a polymorphic base class without the destructor being virtual. The implementation without any public members simply ensures that it is used solely as a policy class.
Personally, I prefer the boost syntax. Inheritance is a way to add some properties or features to the whole class, and noncopyable is such a feature. Noncopyable member seems tricky (you actually don't want to add any member, it's a trick). Inheritance is used precisely for what it is designed for.