Title
auto_ptr to unique_ptr conversion
Status
resolved
Section
[unique.ptr.single.ctor]
Submitter
Howard Hinnant

Created on 2009-04-25.00:00:00 last changed 162 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Add to [unique.ptr.single]:

template <class T, class D>
class unique_ptr
{
public:
    template <class U>
      unique_ptr(auto_ptr<U>& u);
    template <class U>
      unique_ptr(auto_ptr<U>&& u);
};

Add to [unique.ptr.single.ctor]:

template <class U>
  unique_ptr(auto_ptr<U>& u);
template <class U>
  unique_ptr(auto_ptr<U>&& u);

Effects: Constructs a unique_ptr with u.release().

Postconditions: get() == the value u.get() had before the construciton, modulo any required offset adjustments resulting from the cast from U* to T*. u.get() == nullptr.

Throws: nothing.

Remarks: U* shall be implicitly convertible to T* and D shall be the same type as default_delete<T>, else these constructors shall not participate in overload resolution.

Date: 2010-10-21.18:28:33

Rationale:

Solved by N3073.

Date: 2010-03-14.00:00:00

[ 2010-03-14 Howard adds: ]

We moved N3073 to the formal motions page in Pittsburgh which should obsolete this issue. I've moved this issue to NAD Editorial, solved by N3073.

Date: 2010-10-21.18:28:33

[ 2009-10 Santa Cruz: ]

Move to Ready.

Date: 2009-08-01.00:00:00

[ 2009-08-01 Howard deconceptifies wording: ]

I also moved the change from [depr.auto.ptr] to [unique.ptr.single] per the Editor's request in Batavia (as long as I was making changes anyway). Set back to Review.

Date: 2010-10-21.18:28:33

[ 2009-07 Frankfurt ]

Moved from Tentatively Ready to Open only because the wording needs to be tweaked for concepts removal.

Date: 2010-10-21.18:28:33

[ Batavia (2009-05): ]

Pete believes it not a good idea to separate parts of a class's definition. Therefore, if we do this, it should be part of unique-ptr's specification.

Alisdair believes the lvalue overload may be not necessary.

Marc believes it is more than just sugar, as it does ease the transition to unique-ptr.

We agree with the resolution as presented. Move to Tentatively Ready.

Date: 2009-04-25.00:00:00

Message c++std-lib-23182 led to a discussion in which several people expressed interest in being able to convert an auto_ptr to a unique_ptr without the need to call release. Below is wording to accomplish this.

History
Date User Action Args
2010-11-19 19:04:45adminsetstatus: nad editorial -> resolved
2010-10-21 18:28:33adminsetmessages: + msg727
2010-10-21 18:28:33adminsetmessages: + msg726
2010-10-21 18:28:33adminsetmessages: + msg725
2010-10-21 18:28:33adminsetmessages: + msg724
2010-10-21 18:28:33adminsetmessages: + msg723
2010-10-21 18:28:33adminsetmessages: + msg722
2010-10-21 18:28:33adminsetmessages: + msg721
2009-04-25 00:00:00admincreate