This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.
unique_ptr
templated assignmentSection: 20.3.1.3.4 [unique.ptr.single.asgn] Status: Resolved Submitter: Geoffrey Romer Opened: 2012-12-20 Last modified: 2016-01-28
Priority: 3
View all other issues in [unique.ptr.single.asgn].
View all issues with Resolved status.
Discussion:
20.3.1.3.4 [unique.ptr.single.asgn]/5 permits unique_ptr
's templated assignment operator to participate
in overload resolution even when incompatibilities between D
and E
will render the result ill-formed,
but the corresponding templated copy constructor is removed from the overload set in those situations (see the third
bullet point of 20.3.1.3.2 [unique.ptr.single.ctor]/19). This asymmetry is confusing, and presumably unintended;
it may lead to situations where constructing one unique_ptr
from another is well-formed, but assigning from
the same unique_ptr
would be ill-formed.
Previous resolution [SUPERSEDED]:
This wording is relative to N3485.
Revise 20.3.1.3.4 [unique.ptr.single.asgn] p5 as follows:
template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;-4- Requires: If
-5- Remarks: This operator shall not participate in overload resolution unless:E
is not a reference type, assignment of the deleter from an rvalue of typeE
shall be well-formed and shall not throw an exception. Otherwise,E
is a reference type and assignment of the deleter from an lvalue of typeE
shall be well-formed and shall not throw an exception.
unique_ptr<U, E>::pointer
is implicitly convertible topointer
and
U
is not an array type., andeither
D
is a reference type andE
is the same type asD
, orD
is not a reference type andE
is implicitly convertible toD
.-6- Effects: Transfers ownership from
-7- Returns:u
to*this
as if by callingreset(u.release())
followed by an assignment fromstd::forward<E>(u.get_deleter())
.*this
.
[2013-03-15 Issues Teleconference]
Moved to Review.
The wording looks good, but we want a little more time than the telecon permits to be truly comfortable. We expect this issue to resolve fairly easily in Bristol.
[2015-05-18, Howard comments]
Updated proposed wording has been provided in N4366.
[2015-05, Lenexa]
Straw poll: send N4366 to full committee,
with both fixes from the sections "What is the correct fix?" and "unique_ptr<T[]>
needs the correct fix too"
Proposed resolution:
Resolved by accepting N4366.