Boost logo

Boost Users :

From: Philippe Mori (philippe_mori_at_[hidden])
Date: 2005-04-28 17:21:41


>
> And another pitfal with both auto_ptr and shared_ptr (at least on
> VC7.1 compiler) is if you don't provide expicit destructor, the
> generated destructor will try destroy the auto_ptr, which in its turn
> will try to destroy you pimpl via imcomplete pointer, therefor not
> calling destructor. Fortunately compiler at least gives a warning:
> "deletion of pointer to incomplete type 'TestClass::PrivateData'; no
> destructor called"
>

I suppose that a complete type is required to instanciate shared_ptr
destructor and any function that will destroy the pointee.

I was thinking that shared_ptr does ensure by itself that a complete
type is used (contrary to auto_ptr) so that the type must be complete
to compile properly. Do you just have a warning meaning that on
older compiler someone might not even notice the problem.

IMO, the fact that shared_ptr accept incomplete type but
require a complete type is what make it interesting for pimpl.

Philippe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net