Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-04-07 12:20:55


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk