Skip to content

Latest commit

 

History

History
119 lines (84 loc) · 2.51 KB

File metadata and controls

119 lines (84 loc) · 2.51 KB
description Learn more about: any Class
title any Class
ms.date 04/04/2019
f1_keywords
any/std::any
any/std::any::emplace
any/std::any::has_value
any/std::any::reset
any/std::any::swap
any/std::any::type
helpviewer_keywords
any/std::any
any/std::any::emplace
any/std::any::has_value
any/std::any::reset
any/std::any::swap
any/std::any::type

any Class

Stores an instance of any type that satisfies the constructor requirements or it has no value, which is called the state of the class any object.

The stored instance is called the contained value. Two states are the same if either they both have no value, or both have a value and the contained 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 Swaps 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 any has a value.

bool has_value() const noexcept;

operator=

Replaces the any 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 the any.

reset

Resets an any.

void reset() noexcept;

swap

Swaps two any objects.

void swap(any& rhs) noexcept;

type

Returns the any type.

const type_info& type() const noexcept;