Title
shared_ptr interface changes for consistency with N1856
Status
cd1
Section
[util.smartptr.shared]
Submitter
Peter Dimov

Created on 2007-05-05.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Change [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 [util.smartptr.shared.const] as follows:

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

Add to [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 [util.smartptr.shared.assign] as follows:

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

Add to [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.

Date: 2007-05-05.00:00:00

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.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3398
2007-05-05 00:00:00admincreate