Boost logo

Boost :

From: Dave Abrahams (abrahams_at_[hidden])
Date: 2000-01-25 17:10:59


> 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...

Your post is perfect ;)

> 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.

In principle I agree with this and it seems like a real improvement.

In practice I am concerned about the effect of adding (even trivial inline)
destructor declarations, because of the negative effect it has on
optimization in some compilers (for classes that would not otherwise have a
user-defined destructor). Probably this concern is misplaced, because
noncopyable will be used mostly for classes which own resources and thus
have non-trivial destruction semantics. Unless someone can come up with a
compelling reason to reinforce my concern, I approve of this change.

Thanks,
Dave


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