Boost logo

Boost :

From: Miki Jovanovic (miki_at_[hidden])
Date: 2000-01-25 14:17:31


"dave abrahams" <abraham-_at_[hidden]> wrote:
> I had a thought today that the default constructor for noncopyable
ought to
> be protected, to emphasize that it was only useful as a base class.

Hi all,

I am very new here (first 5 minuts on the board) so excuse me if my
post is not in the correct place or if someone had the same thought as
me...

Any way, protected constructor was a great idea. But is should be
complemented with a protected destructor. As it stands now, the
noncopyable class is little dangerious, since people can store pointer
to it, and then call destructor on it. Needless to say, this would not
destroy the object properly, since the overridden destructors will not
be called. So I was thinking of introducing a line like:

   protected:
      ~noncopyable() {}

BTW, this is an issue only if someone inherits publicly from
noncopyable. Otherwise I don't think one can get a pointer to
noncopyable.

Cheers,

Miki Jovanovic.


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