Boost logo

Boost Users :

From: Lehrer, Joshua (boost_at_[hidden])
Date: 2003-05-03 13:22:58


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().

The constructor now takes only a T*, and therefore populates the
pointer to the destructor function with a call to ~T(), which is
~base() in the above example.

If, however, the constructor took an X*, the above example would
pass a sub*, and it could populate the default destructor function
with a pointer to ~X().

Comments?

Joshua Lehrer
FactSet Research Systems
NYSE:FDS


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