...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::movelib::default_delete
// In header: <boost/move/default_delete.hpp> template<typename T> struct default_delete { // construct/copy/destruct default_delete(); default_delete(const default_delete &); template<typename U> default_delete(const default_delete< U > &) noexcept; default_delete & operator=(const default_delete &); template<typename U> default_delete & operator=(const default_delete< U > &) noexcept; // public member functions template<typename U> void operator()(U *) const noexcept; void operator()(std::nullptr_t) const noexcept; };
The class template default_delete
serves as the default deleter (destruction policy) for the class template unique_ptr
.
default_delete
public
construct/copy/destructdefault_delete();
Default constructor.
default_delete(const default_delete &);
Trivial copy constructor
template<typename U> default_delete(const default_delete< U > &) noexcept;
Effects: Constructs a default_delete
object from another default_delete<U>
object.
Remarks: This constructor shall not participate in overload resolution unless:
If T is not an array type and U* is implicitly convertible to T*.
If T is an array type and U* is a more CV qualified pointer to remove_extent<T>::type.
default_delete & operator=(const default_delete &);
Trivial assignment
template<typename U> default_delete & operator=(const default_delete< U > &) noexcept;
Effects: Constructs a default_delete
object from another default_delete<U>
object.
Remarks: This constructor shall not participate in overload resolution unless:
If T is not an array type and U* is implicitly convertible to T*.
If T is an array type and U* is a more CV qualified pointer to remove_extent<T>::type.
default_delete
public member functionstemplate<typename U> void operator()(U * ptr) const noexcept;
Effects: if T is not an array type, calls delete
on static_cast<T*>(ptr), otherwise calls delete[]
on static_cast<remove_extent<T>::type*>(ptr).
Remarks: If U is an incomplete type, the program is ill-formed. This operator shall not participate in overload resolution unless:
T is not an array type and U* is convertible to T*, OR
T is an array type, and remove_cv<U>::type is the same type as remove_cv<remove_extent<T>::type>::type and U* is convertible to remove_extent<T>::type*.
void operator()(std::nullptr_t) const noexcept;
Effects: Same as (this)(static_cast<element_type>(nullptr))
.