This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.
Section: 20.3.1.2.2 [unique.ptr.dltr.dflt] Status: C++11 Submitter: Howard Hinnant Opened: 2008-06-18 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [unique.ptr.dltr.dflt].
View all issues with C++11 status.
Discussion:
No relationship between U and T in the converting constructor for default_delete template.
Requirements: U* is convertible to T* and has_virtual_destructor<T>; the latter should also become a concept.
Rules out cross-casting.
The requirements for unique_ptr conversions should be the same as those on the deleter.
[ Howard adds 2008-11-26: ]
I believe we need to be careful to not outlaw the following use case, and I believe the current proposed wording (requires Convertible<U*, T*> && HasVirtualDestructor<T>) does so:
#include <memory> int main() { std::unique_ptr<int> p1(new int(1)); std::unique_ptr<const int> p2(move(p1)); int i = *p2; // *p2 = i; // should not compile }
I've removed "&& HasVirtualDestructor<T>" from the requires clause in the proposed wording.
[ Post Summit: ]
Alisdair: This issue has to stay in review pending a paper constraining unique_ptr.
Consensus: We agree with the resolution, but unique_ptr needs to be constrained, too.
Recommend Keep in Review.
[ Batavia (2009-05): ]
Keep in Review status for the reasons cited.
[ 2009-07 Frankfurt: ]
The proposed resolution uses concepts. Howard needs to rewrite the proposed resolution.
Move back to Open.
[ 2009-07-26 Howard provided rewritten proposed wording and moved to Review. ]
[ 2009-10 Santa Cruz: ]
Move to Ready.
Proposed resolution:
Add after 20.3.1.2.2 [unique.ptr.dltr.dflt], p1:
template <class U> default_delete(const default_delete<U>& other);-1- Effects: ...
Remarks: This constructor shall participate in overload resolution if and only if U* is implicitly convertible to T*.