Files
cppdraft_translate/cppdraft/any/assign.md
2025-10-25 03:02:53 +03:00

3.0 KiB
Raw Blame History

[any.assign]

22 General utilities library [utilities]

22.7 Storage for any type [any]

22.7.4 Class any [any.class]

22.7.4.3 Assignment [any.assign]

🔗

any& operator=(const any& rhs);

1

#

Effects: As if by any(rhs).swap(*this).

No effects if an exception is thrown.

2

#

Returns: *this.

3

#

Throws: Any exceptions arising from the copy constructor for the contained value.

🔗

any& operator=(any&& rhs) noexcept;

4

#

Effects: As if by any(std::move(rhs)).swap(*this).

5

#

Postconditions: The state of *this is equivalent to the original state of rhs.

6

#

Returns: *this.

🔗

template<class T> any& operator=(T&& rhs);

7

#

Let VT be decay_t.

8

#

Constraints: VT is not the same type as any andis_copy_constructible_v is true.

9

#

Preconditions: VT meets the Cpp17CopyConstructible requirements.

10

#

Effects: Constructs an object tmp of type any that contains an object of type VT direct-initialized with std::forward(rhs), and tmp.swap(*this).

No effects if an exception is thrown.

11

#

Returns: *this.

12

#

Throws: Any exception thrown by the selected constructor of VT.