| Home | Libraries | People | FAQ | More

## Struct template default_delete

boost::movelib::default_delete

## Synopsis

    // 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;
    };

## Description

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

### Template Parameters

1.     typename T

   The type to be deleted. It may be an incomplete type

### `default_delete` public construct/copy/destruct

1.     default_delete();

   Default constructor.

2.     default_delete(const default_delete &);

   Trivial copy constructor

3.     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.

4.     default_delete & operator=(const default_delete &);

   Trivial assignment

5.     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 functions

1.     template<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*.

2.     void operator()(std::nullptr_t) const noexcept;

   Effects: Same as `(this)(static_cast<element_type>(nullptr))`.