Skip to content

Latest commit

 

History

History
76 lines (55 loc) · 1.68 KB

any-functions.md

File metadata and controls

76 lines (55 loc) · 1.68 KB
description title ms.date f1_keywords no-loc
Learn more about the free functions for use with the std::any class in the C++ Standard Library.
<any> functions
09/20/2021
any/std::any_cast
any/std::make_any
any/std::swap
any
std
class

<any> functions

The <any> header declares several free functions for working with the any class.

Functions

   
any_cast Makes an object into an any.
make_any Takes values and creates an any object.
swap Exchanges the elements of two any objects.

any_cast

Makes an object into an any.

template<class T>
    T any_cast(const any& operand);
template<class T>
    T any_cast(any& operand);
template<class T>
    T any_cast(any&& operand);
template<class T>
    const T* any_cast(const any* operand) noexcept;
template<class T>
    T* any_cast(any* operand) noexcept;

make_any

Takes values and creates an any object.

template <class T, class... Args>
    any make_any(Args&& ...args);
template <class T, class U, class... Args>
    any make_any(initializer_list<U> il, Args&& ...args);

swap

Exchanges the elements of two any objects.

void swap(any& left, any& right) noexcept;

Parameters

left
An object of type any.

right
An object of type any.

Requirements

Header: <any>

Namespace: std

Standard: C++17 (Use at least /std:c++17 to compile.)

See also

<any>
any class
bad_any_cast