20 General utilities library [utilities]

20.11 Smart pointers [smartptr]

20.11.1 Class template unique_ptr [unique.ptr]

20.11.1.3 unique_ptr for array objects with a runtime length [unique.ptr.runtime]

20.11.1.3.1 unique_ptr constructors [unique.ptr.runtime.ctor]

template <class U> explicit unique_ptr(U p) noexcept; template <class U> unique_ptr(U p, see below d) noexcept; template <class U> unique_ptr(U p, see below d) noexcept;

These constructors behave the same as the constructors that take a pointer parameter in the primary template except that they shall not participate in overload resolution unless either

  • U is the same type as pointer,

  • U is nullptr_t, or

  • pointer is the same type as element_type*, U is a pointer type V*, and V(*)[] is convertible to element_type(*)[].

template <class U, class E> unique_ptr(unique_ptr<U, E>&& u) noexcept;

This constructor behaves the same as in the primary template, except that it shall not participate in overload resolution unless all of the following conditions hold, where UP is unique_ptr<U, E>:

  • U is an array type, and

  • pointer is the same type as element_type*, and

  • UP::pointer is the same type as UP::element_type*, and

  • UP::element_type(*)[] is convertible to element_type(*)[], and

  • either D is a reference type and E is the same type as D, or D is not a reference type and E is implicitly convertible to D.

Note: This replaces the overload-resolution specification of the primary template  — end note ]