
6 Oct
2006
6 Oct
'06
4:39 p.m.
"Stefan Schild" <schilds@itis.ethz.ch> wrote in message news:eg3r7s$bcb$1@sea.gmane.org...
Hi there
Having a templatized base class B
template<class T> class B .....
is it possible to enforce that a class D can derive from B IF AND ONLY IF the curiously recurring template pattern is applied, that is
class D1 : public B<D1> ... // ok, compile class D2 : public B<X> ... // not ok, do not compile
???
Thx Stefan
Did you try: template<typename T> class B { BOOST_STATIC_ASSERT( boost::is_base_and_derived<B<T>, T>::value ); .... }; Gennadiy