20 General utilities library [utilities]

20.8 Storage for any type [any]

20.8.3 Class any [any.class]

20.8.3.1 Construction and destruction [any.cons]

constexpr any() noexcept;

Postconditions: has_value() is false.

any(const any& other);

Effects: Constructs an object of type any with an equivalent state as other.

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

any(any&& other) noexcept;

Effects: Constructs an object of type any with a state equivalent to the original state of other.

Postconditions: other is left in a valid but otherwise unspecified state.

template<class ValueType> any(ValueType&& value);

Let T be decay_t<ValueType>.

Requires: T shall satisfy the CopyConstructible requirements.

Effects: Constructs an object of type any that contains an object of type T direct-initialized with std::forward<ValueType>(value).

Remarks: This constructor shall not participate in overload resolution unless T is not the same type as any, T is not a specialization of in_place_type_t, and is_copy_constructible_v<T> is true.

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

template <class ValueType, class... Args> explicit any(in_place_type_t<ValueType>, Args&&... args);

Let T be decay_t<ValueType>.

Requires: T shall satisfy the CopyConstructible requirements.

Effects: Initializes the contained value as if direct-non-list-initializing an object of type T with the arguments std::forward<Args>(args)....

Postconditions: *this contains a value of type T.

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

Remarks: This constructor shall not participate in overload resolution unless is_copy_constructible_v<T> is true and is_constructible_v<T, Args...> is true.

template <class ValueType, class U, class... Args> explicit any(in_place_type_t<ValueType>, initializer_list<U> il, Args&&... args);

Let T be decay_t<ValueType>.

Requires: T shall satisfy the CopyConstructible requirements.

Effects: Initializes the contained value as if direct-non-list-initializing an object of type T with the arguments il, std::forward<Args>(args)....

Postconditions: *this contains a value.

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

Remarks: This constructor shall not participate in overload resolution unless is_copy_constructible_v<T> is true and is_constructible_v<T, initializer_list<U>&, Args...> is true.

~any();

Effects: As if by reset().