[Boost-docs] Converting shared_ptr to weak_ptr preserves the deleter.

Subject: [Boost-docs] Converting shared_ptr to weak_ptr preserves the deleter.
From: Shuckey (Shuckey_at_[hidden])
Date: 2007-10-02 10:06:59


Hello. I have observed a terrific feature which I feel should be explicitly
noted in the appropriate documentation.

If you create a shared_ptr with a custom deleter

    shared_ptr<T> pShared1( new T(), &deleter );

and create a weak pointer from that shared pointer

    weak_ptr<T> pWeak1( pShared );

and at last create a second shared pointer from the aforementioned weak
pointer

    shared_ptr<T> pShared2( pWeak1 );

then the newly created pointer (pShared2) will also have the custom
deleter, i.e. destroying both pShared1 and pShared2 invokes deleter().

Best regards,
                      Hrvoje Bratanic AKA Shuckey AKA Crtowat AKA No-Fun

-- 
I'm going, but I need a little time,
I promised I would drown myself in mystic heated wine.

This archive was generated by hypermail 2.1.7 : 2017-11-11 08:50:40 UTC