default_delete
cannot be instantiated with incomplete typesSection: 20.3.1.2 [unique.ptr.dltr] Status: C++11 Submitter: Daniel Krügler Opened: 2009-08-18 Last modified: 2016-01-28
Priority: Not Prioritized
View all issues with C++11 status.
Discussion:
According to the general rules of 16.4.5.8 [res.on.functions] p 2 b 5 the effects are undefined, if an incomplete type is used to instantiate a library template. But neither in 20.3.1.2 [unique.ptr.dltr] nor in any other place of the standard such explicit allowance is given. Since this template is intended to be instantiated with incomplete types, this must be fixed.
[ 2009-11-15 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]
[ 2009-11-17 Alisdair Opens: ]
LWG 1193 tries to support
unique_ptr
for incomplete types. I believe the proposed wording goes too far:The template parameter
T
ofdefault_delete
may be an incomplete type.Do we really want to support
cv-void
? Suggested ammendment:The template parameter
T
ofdefault_delete
may be an incomplete type other thancv-void
.We might also consider saying something about arrays of incomplete types.
Did we lose support for
unique_ptr<function-type>
when the concept-enabled work was shelved? If so, we might want adefault_delete
partial specialization for function types that does nothing. Alternatively, function types should not be supported by default, but there is no reason a user cannot support them via their own deletion policy.Function-type support might also lead to conditionally supporting a function-call operator in the general case, and that seems way too inventive at this stage to me, even if we could largely steal wording directly from
reference_wrapper
.shared_ptr
would have similar problems too.
[ 2010-01-24 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]
Proposed resolution:
Add two new paragraphs directly to 20.3.1.2 [unique.ptr.dltr] (before 20.3.1.2.2 [unique.ptr.dltr.dflt]) with the following content:
The class template
default_delete
serves as the default deleter (destruction policy) for the class templateunique_ptr
.The template parameter
T
ofdefault_delete
may be an incomplete type.