
Sid Sacek wrote:
template<class T> class shared_ptr { template<class Y> explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete { detail::sp_enable_shared_from_this( pn, p, p ); } };
I've tried really hard to figure out what it means when a constructor is both a template as well as explicit. The keywords have incompatible meanings to me and therefore I fail to make sense of it. If you template the argument, then you're saying you'll accept any type of pointer as long as it will still compile, and the explicit implies no explicit conversions to Y, which shouldn't happen anyway due to the template indicating any argument is valid as long as it complies.
You're incorrect on the second restriction. It doesn't mean "no explicit conversions to Y", it means "no implicit conversions from Y to shared_ptr<T>". So as long as you use explicit construction, like this: shared_ptr<A> myPtr(x); you can use any 'x' that is implicitly convertible to an 'A *'. -- Jon Biggar Levanta jon@levanta.com 650-403-7252