$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: kalin (kalin.eh_at_[hidden])
Date: 2005-01-12 21:49:33
Hi All, I've made a simple implementation of making a class non-derivable.
Aside from the pros/cons of actually using this, which I'm sure could
be debated for months, I thought I'd present the implementation anyway
to see if there is interest in it.
I thought something like this might already be in Boost, but I couldn't
locate it,
or any threads about the subject.
Usage is as:
class Foo : Sealed<Foo> {};
class Bar : Foo {}; // Error.
And it should all work as intended (unless I've missed something) and not
allow you to instantiate Bar.
--- Implementation ---
namespace Detail
{
template <class T, class Parent>
class Sealed
{
friend T;
friend Parent;
};
}
template <class T>
class Sealed : public virtual Detail::Sealed<T, Sealed>
{
friend T;
};
--- kalin