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.
1517. default_delete's default constructor should be trivialSection: 20.3.1.2.2 [unique.ptr.dltr.dflt] Status: C++11 Submitter: Daniel Krügler Opened: 2010-09-12 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:
The current working draft does specify the default c'tor of default_delete
in a manner to guarantee static initialization for default-constructed objects of static storage duration as a consequence of the acceptance of the proposal n2976 but this paper overlooked the fact that the suggested declaration does not ensure that the type will be a trivial type. The type default_delete
was always considered as a simple wrapper for calling delete
or delete[]
, respectivly and should be a trivial type.
In agreement with the new settled core language rules this easy to realize by just changing the declaration to
constexpr default_delete() = default;
This proposal also automatically solves the problem, that the semantics of the default constructor of the partial specialization default_delete<T[]>
is not specified at all. By defaulting its default constructor as well, the semantics are well-defined.
[ Post-Rapperswil ]
Moved to Tentatively Ready after 5 positive votes on c++std-lib.
[ Adopted at 2010-11 Batavia ]
Proposed resolution:
The following wording changes are against N3126.
default_delete
in [unique.ptr.dltr.dflt] as indicated:
namespace std { template <class T> struct default_delete { constexpr default_delete() = default; template <class U> default_delete(const default_delete<U>&); void operator()(T*) const; }; }
default_delete
default constructor in [unique.ptr.dltr.dflt]/1. This brings it in harmony with the style used in the partial specialization default_delete<T[]>
. Since there are neither implied nor explicit members, there is no possibility to misinterpret what the constructor does:
constexpr default_delete();1 Effects: Default constructs a
default_delete
object.
default_delete
in [unique.ptr.dltr.dflt1] as indicated:
namespace std { template <class T> struct default_delete<T[]> { constexpr default_delete() = default; void operator()(T*) const; template <class U> void operator()(U*) const = delete; }; }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4