From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2004-03-02 14:15:59
Robert Ramey wrote:
> The follow little example illustrates an issue I have with scoped_ptr. I
> would like to use this to automatically manage destruction of a pointer to
> and undefined class. It seems that scope_ptr is instantiating its
> destructor "too early" and complaining about incomplete type for b;
> In my view, this should not occur as ~a() isn't defined yet.
> The following example fails on vc 7.1 and gcc 3.2
> Note that shared_ptr works as one would hope in this context. Is there
> anyway to adjust scoped_ptr to work here?
IMO this isn't something scoped_ptr should do. There's to much overhead
associated with capturing the type at construction.
I proposed something for exactly this purpose a while ago:
And I believe Peter Dimov has something similar in the files section.
-- Daniel Wallin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk