Hi,
I need to prevent a class from being derived from so I thought to myself, this is something that Boost is bound to have already done. I know they have a noncopyable, they must have a nonderivable...
Imagine my surprise when I couldn't find it....
That got me thinking.. There must be a reason. Maybe it isn't possible to do using templates..
I'm sure if it was easy it's be in the boost libraries.
I know how to do it without using templates, i.e. using a base class with a private constructor i.e.
class ThatCantBeDerived; // Forward reference
class _NonDeriv
{
_NonDeriv() {}
friend class ThatCantBeDerived;
};
class ThatCantBeDerived : virtual public _NonDeriv
{
public:
ThatCantBeDerived() :
_NonDeriv()
{
}
};
Or something like this..
Maybe it's the forward reference that causes the problem, or maybe there isn't a portable way to achieve it..
Either way, I'm not sure why it isn't in boost..
Any ideas?