On 23 February 2010 14:55, Baptiste Lepilleur <baptiste.lepilleur@gmail.com> wrote:
[A]    template<class Y>
[B]    explicit shared_ptr(std::auto_ptr<Y> & r): px(r.get()), pn()

By the way, shouldn't this constructor take std::auto_ptr by value instead of by reference. I remember being forced to introduce a local variable with the example below (was with sunstudio 12, default STL if I remember correctly). I think this was caused because you can not bind a temporary object to a non const reference.

Passing the auto_ptr by value would only get us the basic exception safety guarantee, as the shared_ptr will have taken ownership, even though it might still throw before it is done constructing itself.  Passing it in by reference allows us to have the strong exception safety guarantee.
--
Nevin Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404