[unique.ptr.runtime] (original) (raw)

20 Memory management library [mem]

20.3 Smart pointers [smartptr]

20.3.1 Unique-ownership pointers [unique.ptr]

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

20.3.1.4.1 General [unique.ptr.runtime.general]

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;constexpr 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;constexpr ~unique_ptr();constexpr 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;constexpr 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;constexpr 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; unique_ptr(const unique_ptr&) = delete; unique_ptr& operator=(const unique_ptr&) = delete;};}

A specialization for array types is provided with a slightly altered interface.

Descriptions are provided below only for members that differ from the primary template.

The template argument T shall be a complete type.

20.3.1.4.2 Constructors [unique.ptr.runtime.ctor]

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

This constructor behaves the same as the constructor in the primary template that takes a single parameter of type pointer.

Constraints:

template<class U> constexpr unique_ptr(U p, _see below_ d) noexcept;template<class U> constexpr unique_ptr(U p, _see below_ d) noexcept;

These constructors behave the same as the constructors in the primary template that take a parameter of type pointer and a second parameter.

Constraints:

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

This constructor behaves the same as in the primary template.

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

[Note 1:

This replaces the Constraints: specification of the primary template.

— _end note_]

20.3.1.4.3 Assignment [unique.ptr.runtime.asgn]

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

This operator behaves the same as in the primary template.

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

[Note 1:

This replaces the Constraints: specification of the primary template.

— _end note_]

20.3.1.4.4 Observers [unique.ptr.runtime.observers]

constexpr T& operator[](size_t i) const;

Preconditions: i < the number of elements in the array to which the stored pointer points.

20.3.1.4.5 Modifiers [unique.ptr.runtime.modifiers]

constexpr void reset(nullptr_t p = nullptr) noexcept;

Effects: Equivalent to reset(pointer()).

template<class U> constexpr void reset(U p) noexcept;

This function behaves the same as the reset member of the primary template.

Constraints: