Files
2025-10-25 03:02:53 +03:00

3.6 KiB

[unique.ptr.dltr]

20 Memory management library [mem]

20.3 Smart pointers [smartptr]

20.3.1 Unique-ownership pointers [unique.ptr]

20.3.1.2 Default deleters [unique.ptr.dltr]

20.3.1.2.1 General [unique.ptr.dltr.general]

1

#

The class template default_delete serves as the default deleter (destruction policy) for the class template unique_ptr.

2

#

The template parameter T of default_delete may be an incomplete type.

20.3.1.2.2 default_delete [unique.ptr.dltr.dflt]

namespace std {template struct default_delete {constexpr default_delete() noexcept = default; template constexpr default_delete(const default_delete&) noexcept; constexpr void operator()(T*) const; };}

🔗

template<class U> constexpr default_delete(const default_delete<U>& other) noexcept;

1

#

Constraints: U* is implicitly convertible to T*.

2

#

Effects: Constructs a default_delete object from another default_delete object.

🔗

constexpr void operator()(T* ptr) const;

3

#

Mandates: T is a complete type.

4

#

Effects: Calls delete on ptr.

20.3.1.2.3 default_delete<T[]> [unique.ptr.dltr.dflt1]

namespace std {template struct default_delete<T[]> {constexpr default_delete() noexcept = default; template constexpr default_delete(const default_delete<U[]>&) noexcept; template constexpr void operator()(U* ptr) const; };}

🔗

template<class U> constexpr default_delete(const default_delete<U[]>& other) noexcept;

1

#

Constraints: U()[] is convertible to T()[].

2

#

Effects: Constructs a default_delete object from another default_delete<U[]> object.

🔗

template<class U> constexpr void operator()(U* ptr) const;

3

#

Constraints: U()[] is convertible to T()[].

4

#

Mandates: U is a complete type.

5

#

Effects: Calls delete[] on ptr.