Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
An any object either stores an instance of a type that satisfies the constructor requirements, or it has no value. Whether it has a stored instance, or no value, is called the state of the any object.
The stored instance is called the contained value. Two any objects have the same state if either they both have no value, or both have a contained value and those values are the same.
Syntax
class any;
Members
Constructors
| Name | Description |
|---|---|
any |
Constructs an object of type any. |
Functions
| Name | Description |
|---|---|
emplace |
Sets an any value. |
has_value |
Returns true if any has a value. |
reset |
Resets an any. |
swap |
Exchanges two any objects. |
type |
Returns the any type. |
Operators
| Name | Description |
|---|---|
operator= |
Replaces the any with a copy of another any. |
any
Constructs an object of type any. Also includes a destructor.
constexpr any() noexcept;
any(const any& other);
any(any&& other) noexcept;
template <class T>
any(T&& value);
template <class T, class... Args>
explicit any(in_place_type_t<T>, Args&&...);
template <class T, class U, class... Args>
explicit any(in_place_type_t<T>, initializer_list<U>, Args&&...);
~any();
emplace
Sets an any value.
template <class T, class... Args>
decay_t<T>& emplace(Args&& ...);
template <class T, class U, class... Args>
decay_t<T>& emplace(initializer_list<U>, Args&&...);
has_value
Returns true if the any object has a value.
bool has_value() const noexcept;
operator=
Replaces the any content with a copy of another any.
any& operator=(const any& right);
any& operator=(any&& right) noexcept;
template <class T>
any& operator=(T&& right);
Parameters
right
The any being copied into this any.
reset
Resets an any.
void reset() noexcept;
swap
Exchanges two any objects.
void swap(any& rhs) noexcept;
type
Returns the any type.
const type_info& type() const noexcept;
Requirements
Header: <any>
Namespace: std
Standard: C++17 (Use at least /std:c++17 to compile.)