[unique.ptr.runtime.ctor]

# 20 Memory management library [[mem]](./#mem)

## 20.3 Smart pointers [[smartptr]](smartptr#unique.ptr.runtime.ctor)

### 20.3.1 Unique-ownership pointers [[unique.ptr]](unique.ptr#runtime.ctor)

#### 20.3.1.4 unique_ptr for array objects with a runtime length [[unique.ptr.runtime]](unique.ptr.runtime#ctor)

#### 20.3.1.4.2 Constructors [unique.ptr.runtime.ctor]

[ð](#lib:unique_ptr,constructor)

`template<class U> constexpr explicit unique_ptr(U p) noexcept;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2987)

This constructor behaves the same as
the constructor in the primary template that
takes a single parameter of type pointer[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2992)

*Constraints*: 

- [(2.1)](#2.1)

U is the same type as pointer, or

- [(2.2)](#2.2)

pointer is the same type as element_type*,U is a pointer type V*, andV(*)[] is convertible to element_type(*)[][.](#2.sentence-1)

[ð](#lib:unique_ptr,constructor_)

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

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L3009)

These constructors behave the same as
the constructors in the primary template that
take a parameter of type pointer and a second parameter[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L3014)

*Constraints*: 

- [(4.1)](#4.1)

U is the same type as pointer,

- [(4.2)](#4.2)

U is nullptr_t, or

- [(4.3)](#4.3)

pointer is the same type as element_type*, U is a pointer type V*, and V(*)[] is convertible to element_type(*)[][.](#4.sentence-1)

[ð](#lib:unique_ptr,constructor__)

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

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L3031)

This constructor behaves the same as in the primary template[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L3034)

*Constraints*: Where UP is unique_ptr<U, E>:

- [(6.1)](#6.1)

U is an array type, and

- [(6.2)](#6.2)

pointer is the same type as element_type*, and

- [(6.3)](#6.3)

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

- [(6.4)](#6.4)

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

- [(6.5)](#6.5)

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[.](#6.sentence-1)

[*Note [1](#note-1)*:

This replaces the *Constraints*: specification of the primary template[.](#6.sentence-2)

â *end note*]
