constexpr any(); | (1) | (since C++17) |
any( const any& other ); | (2) | (since C++17) |
any( any&& other ); | (3) | (since C++17) |
template< class ValueType > any( ValueType&& value ); | (4) | (since C++17) |
template< class T, class... Args > explicit any( std::in_place_type_t<T>, Args&&... args ); | (5) | (since C++17) |
template< class T, class U, class... Args >
explicit any( std::in_place_type_t<T>, std::initializer_list<U> il,
Args&&... args );
| (6) | (since C++17) |
Constructs a new any object.
other into a new instance, so that any content is equivalent in both type and value to those of other prior to the constructor call, or empty if other is empty.std::decay_t<ValueType>, direct-initialized from std::forward<ValueType>(value). If std::is_copy_constructible<std::decay_t<ValueType>>::value is false, the program is ill-formed. This overload only participates in overload resolution if std::decay_t<ValueType> is not the same type as any.T, direct-non-list-initialized from std::forward<Args>(args).... If std::is_constructible_v<T, Args...> is false, the behavior is undefined.T, direct-non-list-initialized from il, std::forward<Args>(args).... This overload only participates in overload resolution if std::is_constructible_v<T, std::initializer_list<U>&, Args...> is true. | ValueType | - | contained value type |
| Type requirements | ||
-
std::decay_t<ValueType> must meet the requirements of CopyConstructible. |
||
| other | - | another any object to copy or move from |
| value | - | value to initialize the contained value with |
| il, args | - | arguments to be passed to the constructor of the contained object |
noexcept specification: noexceptBecause the default constructor is constexpr, static std::anys are initialized as part of static non-local initialization, before any dynamic non-local initialization begins. This makes it safe to use an object of type std::any in a constructor of any static object.
assigns an any object (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility/any/any