RE: [boost] Generic non-derivable base class

Matthew Vogt wrote:
The following simple base class implements the mechanism as dicussed on Stroustrup's FAQ page, and encapsulates the virtual inheritance so that the class can be non-virtually inherited, removing the most obvious chance of implementation error.
Will this code work on multiple platforms? I have only tested on gcc 3.2... [snip]
Why can't you do: namespace boost { template< class T > struct nonderivable; namespace detail { template< class T > class nonderivable_base { friend T; friend class nonderivable< T >; nonderivable_base() { } nonderivable_base( const nonderivable_base & ) { } }; } template< class T > struct nonderivable: public virtual detail::nonderivable_base< T > { }; } This *will* work with MS VC 6-7.1 and Borland 5.5.1. I haven't tested on GCC or other compilers, but it should work. Regards, Reece _________________________________________________________________ Use MSN Messenger to send music and pics to your friends http://www.msn.co.uk/messenger

Reece Dunn wrote:
Why can't you do:
namespace boost { template< class T > struct nonderivable;
namespace detail { template< class T > class nonderivable_base { friend T;
----------^^^^^^^^^ not standard, alas. -- Eric Niebler Boost Consulting www.boost-consulting.com
participants (2)
-
Eric Niebler
-
Reece Dunn