[unique.ptr.runtime.general]

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

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

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

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

#### 20.3.1.4.1 General [unique.ptr.runtime.general]

[ð](#lib:unique_ptr)

namespace std {template<class T, class D> class unique_ptr<T[], D> {public:using pointer = *see below*; using element_type = T; using deleter_type = D; // [[unique.ptr.runtime.ctor]](unique.ptr.runtime.ctor "20.3.1.4.2 Constructors"), constructorsconstexpr unique_ptr() noexcept; template<class U> constexpr explicit unique_ptr(U p) noexcept; template<class U> constexpr unique_ptr(U p, *see below* d) noexcept; template<class U> constexpr unique_ptr(U p, *see below* d) noexcept; constexpr unique_ptr(unique_ptr&& u) noexcept; template<class U, class E>constexpr unique_ptr(unique_ptr<U, E>&& u) noexcept; constexpr unique_ptr(nullptr_t) noexcept; // destructorconstexpr ~unique_ptr(); // assignmentconstexpr unique_ptr& operator=(unique_ptr&& u) noexcept; template<class U, class E>constexpr unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept; constexpr unique_ptr& operator=(nullptr_t) noexcept; // [[unique.ptr.runtime.observers]](unique.ptr.runtime.observers "20.3.1.4.4 Observers"), observersconstexpr T& operator[](size_t i) const; constexpr pointer get() const noexcept; constexpr deleter_type& get_deleter() noexcept; constexpr const deleter_type& get_deleter() const noexcept; constexpr explicit operator bool() const noexcept; // [[unique.ptr.runtime.modifiers]](unique.ptr.runtime.modifiers "20.3.1.4.5 Modifiers"), modifiersconstexpr pointer release() noexcept; template<class U> constexpr void reset(U p) noexcept; constexpr void reset(nullptr_t = nullptr) noexcept; constexpr void swap(unique_ptr& u) noexcept; // disable copy from lvalue unique_ptr(const unique_ptr&) = delete;
 unique_ptr& operator=(const unique_ptr&) = delete; };}

[1](#1)

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

A specialization for array types is provided with a slightly altered
interface[.](#1.sentence-1)

- [(1.1)](#1.1)

  Conversions between different types ofunique_ptr<T[], D> that would be disallowed for the corresponding pointer-to-array types,
and conversions to or from the non-array forms ofunique_ptr, produce an ill-formed program[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  Pointers to types derived from T are
rejected by the constructors, and by reset[.](#1.2.sentence-1)

- [(1.3)](#1.3)

  The observers operator* andoperator-> are not provided[.](#1.3.sentence-1)

- [(1.4)](#1.4)

  The indexing observer operator[] is provided[.](#1.4.sentence-1)

- [(1.5)](#1.5)

  The default deleter will call delete[][.](#1.5.sentence-1)

[2](#2)

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

Descriptions are provided below only for members that
differ from the primary template[.](#2.sentence-1)

[3](#3)

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

The template argument T shall be a complete type[.](#3.sentence-1)
