cpp/memory/default delete

is the default destruction policy used by std when no deleter is specified. Specializations of are empty classes on typical implementations, and used in the empty base class optimization.

@1@ The non-specialized uses  to deallocate memory for a single object.

@2@ A partial specialization for array types that uses is also provided.

Member functions
{{member|{{small|std::default_delete::}}default_delete|2= {{dcl begin}} {{dcl|num=1|1= constexpr default_delete noexcept = default; }} {{dcl rev multi|num=2 template default_delete( const default_delete& d ) noexcept; template constexpr default_delete( const default_delete& d ) noexcept; }} {{dcl rev multi|num=3 template default_delete( const default_delete& d ) noexcept; template constexpr default_delete( const default_delete& d ) noexcept; }} {{dcl end}}
 * since1=c++11|notes1={{mark|member only of primary {{tt|default_delete}} template}}|dcl1=
 * since2=c++23|notes2={{mark|member only of primary {{tt|default_delete}} template}}|dcl2=
 * since1=c++11|notes1={{mark|member only of {{tt|default_delete}} specialization}}|dcl1=
 * since2=c++23|notes2={{mark|member only of {{tt|default_delete}} specialization}}|dcl2=

@1@ Constructs a {{tt|std::default_delete}} object. @2@ Constructs a {{c|std::default_delete}} object from another {{tt|std::default_delete}} object. This constructor will only participate in overload resolution if {{c|U*}} is implicitly convertible to {{c|T*}}. @3@ Constructs a {{c|std::default_delete}} object from another {{c|std::default_delete}} object. This constructor will only participate in overload resolution if {{c|U(*)[]}} is implicitly convertible to {{c|T(*)[]}}.

Exceptions
No exception guarantees. }}

Invoking over Incomplete Types
At the point in the code the is called, the type must be complete. In some implementations a is used to make sure this is the case. The reason for this requirement is that calling delete on an incomplete type is undefined behavior in C++ if the complete class type has a nontrivial destructor or a deallocation function, as the compiler has no way of knowing whether such functions exist and must be invoked.