Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-09-18 10:55:47


----- Original Message -----
From: <jeremy_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, September 18, 2001 12:45 PM
Subject: [boost] Re: noncopyable as a virtual base class?

> > --- In boost_at_y..., Daniel Frey <daniel.frey_at_a...> wrote:
> > Why would anybody want to do something like this? If a class is
> > noncopyable, eg. because it derives from 'boost::noncopyable',
> > all derived classes are automatically noncopyable unless, of course,
>
> Well I was thinking that sometime in the future I might change B so
> that it no longer inherits A. I didn't think I should have to
> remember that B got its noncopyable-ness from A.
>
Well, in that case I ask the group to reconsider a suggestion I did before,
but wan't seen as any useful:

  template<class T>
   class noncopyable_t
    {
    protected:
        noncopyable_t(){}
        ~noncopyable_t(){}
    private: // emphasize the following members are private
        noncopyable_t( const noncopyable_t& );
        const noncopyable_t& operator=( const noncopyable_t& );
    }; // noncopyable_t

   // For back compatibility:
   typedef noncopyable_t<void> noncopyable ;

struct A : noncopyable {} ;
struct B : A, noncopyable_t<B> {} ;
struct C : B, noncopyable_t<C> {} ;

.. and so on...

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


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