1303. shared_ptr, unique_ptr, and rvalue references v2

Section: 23.11.1.2 [unique.ptr.single], 23.11.3 [util.smartptr.shared] Status: C++11 Submitter: Stephan T. Lavavej Opened: 2010-01-23 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [unique.ptr.single].

View all issues with C++11 status.

Discussion:

N3000 23.11.3 [util.smartptr.shared]/1 still says:

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

I believe that this is unnecessary now that "rvalue references v2" prevents rvalue references from binding to lvalues, and I didn't see a Library Issue tracking this.

[ 2010-02-12 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]

Proposed resolution:

Strike from 23.11.1.2 [unique.ptr.single]:

template <class T, class D = default_delete<T>> class unique_ptr {
  ...
  unique_ptr(const unique_ptr&) = delete;
  template <class U, class E> unique_ptr(const unique_ptr<U, E>&) = delete;
  unique_ptr& operator=(const unique_ptr&) = delete;
  template <class U, class E> unique_ptr& operator=(const unique_ptr<U, E>&) = delete;
};

Strike from 23.11.3 [util.smartptr.shared]:

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