[unique.ptr.single.asgn] (original) (raw)

20 General utilities library [utilities]

20.11 Smart pointers [smartptr]

20.11.1 Class template unique_­ptr [unique.ptr]

20.11.1.2 unique_­ptr for single objects [unique.ptr.single]

20.11.1.2.3 Assignment [unique.ptr.single.asgn]

unique_ptr& operator=(unique_ptr&& u) noexcept;

Constraints: is_­move_­assignable_­v<D> is true.

Preconditions:If D is not a reference type, D meets theCpp17MoveAssignable requirements (Table 30) and assignment of the deleter from an rvalue of type D does not throw an exception.

Otherwise, D is a reference type;remove_­reference_­t<D> meets the Cpp17CopyAssignablerequirements and assignment of the deleter from an lvalue of type D does not throw an exception.

Effects:Calls reset(u.release()) followed byget_­deleter() = std​::​forward<D>(u.get_­deleter()).

Postconditions: u.get() == nullptr.

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

Constraints:

Preconditions:If E is not a reference type, assignment of the deleter from an rvalue of type Eis well-formed and does not throw an exception.

Otherwise, E is a reference type and assignment of the deleter from an lvalue of type Eis well-formed and does not throw an exception.

Effects:Calls reset(u.release()) followed byget_­deleter() = std​::​forward<E>(u.get_­deleter()).

Postconditions: u.get() == nullptr.

unique_ptr& operator=(nullptr_t) noexcept;

Effects:As if by reset().

Postconditions: get() == nullptr.