Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2001-03-29 09:25:26


David Abrahams wrote:
 
>>
>> I know that. I meant to state that, in my opinion, this doesn't prevent
body
>> from having non-trivial dtor and *have it called*,

>True.

Then, scoped_ptr's docs contain an incorrect statement, and that is better
fixed.

>> that in most cases (i.e.
>> when you don't take special measures to the opposite effect) it will be
>> called

>Questionable, no? It depends how much you use forward declarations, right?

It actually depends on when you instantinate scoped_ptr's dtor. It is likely
that dtor for it won't be instantinated before dtor of "handle' and
therefore, before handle's first creation. And since ctor of handle is likely
to create body it will require struct body to be complete type.

I agree that it is possible to make wrong thing unintentionally, though.

>> , 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;
        }

-- 
Regards,
Vladimir

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