Boost logo

Boost Users :

From: d_zakaib (d_zakaib_at_[hidden])
Date: 2003-05-06 02:18:07


--- In Boost-Users_at_[hidden], "Lehrer, Joshua" <boost_at_l...>
wrote:
> WRT boost::shared_ptr<>, why not template the explicit constructor
> that takes a T*? This way, it could select the correct destructor
> at construction time:
>
> struct base { ~base(); };
> struct sub : public base { ~sub() };
> boost::shared_ptr<base>(new sub);
>
> The above code currently only calls ~base(); Templating the
> explicit single argument constructor would allow the above code to
> call ~sub().
>

Why not just have a virtual destructor? Then delete will be able to
destroy your derived class properly:
struct base { virtual ~base(); };

Dan


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