19 General utilities library [utilities]

19.11 Smart pointers [smartptr]

19.11.1 Class template unique_­ptr [unique.ptr]

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

19.11.1.2.3 Assignment [unique.ptr.single.asgn]

unique_ptr& operator=(unique_ptr&& u) noexcept;
Requires: If D is not a reference type, D shall satisfy the Cpp17MoveAssignable requirements (Table 27) and assignment of the deleter from an rvalue of type D shall not throw an exception.
Otherwise, D is a reference type; remove_­reference_­t<D> shall satisfy the Cpp17CopyAssignable requirements and assignment of the deleter from an lvalue of type D shall not throw an exception.
Effects: Calls reset(u.release()) followed by get_­deleter() = std::forward<D>(u.get_­deleter()).
Returns: *this.
Ensures: u.get() == nullptr.
template<class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
Requires: If E is not a reference type, assignment of the deleter from an rvalue of type E shall be well-formed and shall not throw an exception.
Otherwise, E is a reference type and assignment of the deleter from an lvalue of type E shall be well-formed and shall not throw an exception.
Remarks: This operator shall not participate in overload resolution unless:
  • unique_­ptr<U, E>::pointer is implicitly convertible to pointer, and
  • U is not an array type, and
  • is_­assignable_­v<D&, E&&> is true.
Effects: Calls reset(u.release()) followed by get_­deleter() = std::forward<E>(u.get_­deleter()).
Returns: *this.
Ensures: u.get() == nullptr.
unique_ptr& operator=(nullptr_t) noexcept;
Effects: As if by reset().
Ensures: get() == nullptr.
Returns: *this.