Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-10-26 18:24:17


Emil Dotchevski wrote:

> template <class T>
> shared_ptr
> {
> ....
> template <class Y>
> shared_ptr( shared_ptr<Y> const & sp, T * p ): px(p), pn(sp.pn)
> {
> }
> ....
> };

This has already been proposed in

http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1851.pdf

along with a few other features. On the one hand, when you need it, it's
unquestionably useful and carries no additional overhead. I also like how
the casts are now implementable via the public interface. On the other hand,
it could be argued that this constructor makes it uncomfortably easy to
construct a shared_ptr that can dangle (because the lifetime of p is not
properly bounded by sp.)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk