Files
2025-10-25 03:02:53 +03:00

4.1 KiB
Raw Permalink Blame History

[unique.ptr.single.asgn]

20 Memory management library [mem]

20.3 Smart pointers [smartptr]

20.3.1 Unique-ownership pointers [unique.ptr]

20.3.1.3 unique_ptr for single objects [unique.ptr.single]

20.3.1.3.4 Assignment [unique.ptr.single.asgn]

🔗

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

1

#

Constraints: is_move_assignable_v is true.

2

#

Preconditions: If D is not a reference type, D meets theCpp17MoveAssignable requirements (Table 33) 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 meets the Cpp17CopyAssignable requirements and assignment of the deleter from an lvalue of type D does not throw an exception.

3

#

Effects: Calls reset(u.release()) followed byget_deleter() = std::forward(u.get_deleter()).

4

#

Postconditions: If this != addressof(u),u.get() == nullptr, otherwise u.get() is unchanged.

5

#

Returns: *this.

🔗

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

6

#

Constraints:

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.

7

#

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

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

8

#

Effects: Calls reset(u.release()) followed byget_deleter() = std::forward(u.get_deleter()).

9

#

Postconditions: u.get() == nullptr.

10

#

Returns: *this.

🔗

constexpr unique_ptr& operator=(nullptr_t) noexcept;

11

#

Effects: As if by reset().

12

#

Postconditions: get() == nullptr.

13

#

Returns: *this.