20 General utilities library [utilities]

20.8 Storage for any type [any]

20.8.3 Class any [any.class]

20.8.3.2 Assignment [any.assign]

any& operator=(const any& rhs);

Effects: As if by any(rhs).swap(*this). No effects if an exception is thrown.

Returns: *this.

Throws: Any exceptions arising from the copy constructor of the contained object.

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

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

Returns: *this.

Postconditions: The state of *this is equivalent to the original state of rhs and rhs is left in a valid but otherwise unspecified state.

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

Let T be decay_t<ValueType>.

Requires: T shall satisfy the CopyConstructible requirements.

Effects: Constructs an object tmp of type any that contains an object of type T direct-initialized with std::forward<ValueType>(rhs), and tmp.swap(*this). No effects if an exception is thrown.

Returns: *this.

Remarks: This operator shall not participate in overload resolution unless T is not the same type as any and is_copy_constructible_v<T> is true.

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