Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2001-04-03 10:04:55

Beman Dawes wrote:

> >>> , and that one can assure that you never call delete on an object with
> >>> incomplete type.
> >
> >>How?
> >
> >As I have stated in previous post, with sizeof(T):
> >
> > ~scoped_ptr() {
> > sizeof(T);
> > delete p;
> > }

>If you did that, scoped_ptr could not be used with incomplete
>types. Although you have to be careful that the destructor is trivial, it
>is highly desirable to be able to use scoped_ptr with incomplete types. I
>must be missing your point.

My first post was saying that point where pointer is deleted is near
instantination point of ~scoped_ptr(), which allows to instantinate
scoped_ptr on an incomplete type -- handle/body will work. It seems to be
standard bahaviour, g++ 3.0 and bcc 5.5.1 work exactly this way.

sizeof(T) simply assures that the type is complete at point of deletion -- I
really don't understand when this constraint will lead to anything but added

Peter Dimov wrote:
> Are there any compilers that don't warn on this?

Yes, bcc.


Boost list run by bdawes at, gregod at, cpdaniel at, john at