|
Boost : |
From: Bronek Kozicki (brok_at_[hidden])
Date: 2004-01-19 17:38:50
Jonathan Turkanis <technews_at_[hidden]> wrote:
> The above example is okay, but I'm pretty sure your general claim is
> too strong. Consider:
>
> Base* new_base() { return new Derived; }
>
> auto_ptr<Base> p(new_base());
>
> How can the auto_ptr constructor know that Derived is the most derived
> type of the pointer? Even at construction, it does not have enough
> information to free the pointer properly.
That's true. "Base *" is to blame, and I see no way to pass type
information to auto_ptr (or maybe move_ptr ;) constructor. I called it
"pathological case". Conclusion is that raw pointer should be directly
packed into smart pointer, and I think that's not new.
B.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk