
26 Oct
2006
26 Oct
'06
10:24 p.m.
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.)