This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

674. shared_ptr interface changes for consistency with N1856

Section: 20.3.2.2 [util.smartptr.shared] Status: CD1 Submitter: Peter Dimov Opened: 2007-05-05 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [util.smartptr.shared].

View all issues with CD1 status.

Discussion:

N1856 does not propose any changes to shared_ptr. It needs to be updated to use a rvalue reference where appropriate and to interoperate with unique_ptr as it does with auto_ptr.

Proposed resolution:

Change 20.3.2.2 [util.smartptr.shared] as follows:

template<class Y> explicit shared_ptr(auto_ptr<Y>&&& r);
template<class Y, class D> explicit shared_ptr(const unique_ptr<Y,D>& r) = delete;
template<class Y, class D> explicit shared_ptr(unique_ptr<Y,D>&& r);
...
template<class Y> shared_ptr& operator=(auto_ptr<Y>&&& r);
template<class Y, class D> shared_ptr& operator=(const unique_ptr<Y,D>& r) = delete;
template<class Y, class D> shared_ptr& operator=(unique_ptr<Y,D>&& r);

Change 20.3.2.2.2 [util.smartptr.shared.const] as follows:

template<class Y> shared_ptr(auto_ptr<Y>&&& r);

Add to 20.3.2.2.2 [util.smartptr.shared.const]:

template<class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);

Effects: Equivalent to shared_ptr( r.release(), r.get_deleter() ) when D is not a reference type, shared_ptr( r.release(), ref( r.get_deleter() ) ) otherwise.

Exception safety: If an exception is thrown, the constructor has no effect.

Change 20.3.2.2.4 [util.smartptr.shared.assign] as follows:

template<class Y> shared_ptr& operator=(auto_ptr<Y>&&& r);

Add to 20.3.2.2.4 [util.smartptr.shared.assign]:

template<class Y, class D> shared_ptr& operator=(unique_ptr<Y,D>&& r);

-4- Effects: Equivalent to shared_ptr(std::move(r)).swap(*this).

-5- Returns: *this.

[ Kona (2007): We may need to open an issue (743(i)) to deal with the question of whether shared_ptr needs an rvalue swap. ]