std::any - A type-safe container of any type.
Contents
Constructor & Destructor Documentation
constexprstd::any::any()[inline],[constexpr],[noexcept]
Default constructor, creates an empty object.
std::any::any(constany&__other)[inline]
Copy constructor, copies the state of __other.
std::any::any(any&&__other)[inline],[noexcept]
Move constructor, transfer the state from __other.
Postcondition
!__other.has_value() (this postcondition is a GNU extension)
template<typename_Tp,typename_VTp=_Decay_if_not_any<_Tp>,typename_Mgr=_Manager<_VTp>,enable_if_t<is_copy_constructible_v<_VTp>&&!__is_in_place_type_v<_VTp>,bool>=true>std::any::any(_Tp&&__value)[inline]
Construct with a copy of __value as the contained object.
template<typename_Tp,typename..._Args,typename_VTp=decay_t<_Tp>,typename_Mgr=_Manager<_VTp>,__any_constructible_t<_VTp,_Args&&...>=false>std::any::any(in_place_type_t<_Tp>,_Args&&...__args)[inline],[explicit]
Construct with an object created from __args as the contained object.
template<typename_Tp,typename_Up,typename..._Args,typename_VTp=decay_t<_Tp>,typename_Mgr=_Manager<_VTp>,__any_constructible_t<_VTp,initializer_list<_Up>&,_Args&&...>=false>std::any::any(in_place_type_t<_Tp>,initializer_list<_Up>__il,_Args&&...__args)[inline],[explicit]
Construct with an object created from __il and __args as the contained object.
std::any::~any()[inline]
Destructor, calls reset()
Detailed Description
A type-safe container of any type.
An any object's state is either empty or it stores a contained object of CopyConstructible type.
Since
C++17
Member Function Documentation
template<typename_Tp,typename..._Args>__emplace_t<decay_t<_Tp>,_Args...>std::any::emplace(_Args&&...__args)[inline]
Emplace with an object created from __args as the contained object.
template<typename_Tp,typename_Up,typename..._Args>__emplace_t<decay_t<_Tp>,initializer_list<_Up>&,_Args&&...>std::any::emplace(initializer_list<_Up>__il,_Args&&...__args)[inline]
Emplace with an object created from __il and __args as the contained object.
boolstd::any::has_value()const[inline],[noexcept]
Reports whether there is a contained object or not.
template<typename_Tp>enable_if_t<is_copy_constructible<_Decay_if_not_any<_Tp>>::value,any&>std::any::operator=(_Tp&&__rhs)[inline]
Store a copy of __rhs as the contained object.
any&std::any::operator=(any&&__rhs)[inline],[noexcept]
Move assignment operator.
Postcondition
!__rhs.has_value() (not guaranteed for other implementations)
any&std::any::operator=(constany&__rhs)[inline]
Copy the state of another object.
voidstd::any::reset()[inline],[noexcept]
If not empty, destroy the contained object.
voidstd::any::swap(any&__rhs)[inline],[noexcept]
Exchange state with another object.
consttype_info&std::any::type()const[inline],[noexcept]
The typeid of the contained object, or typeid(void) if empty.
Name
std::any - A type-safe container of any type.
Synopsis
#include <any>
PublicMemberFunctions
constexpr any () noexcept
Default constructor, creates an empty object.
template<typename _Tp , typename_VTp = _Decay_if_not_any<_Tp>, typename_Mgr = _Manager<_VTp>,
enable_if_t< is_copy_constructible_v< _VTp > &&!__is_in_place_type_v< _VTp >, bool > = true> any
(_Tp &&__value)
Construct with a copy of __value as the contained object.
any (any &&__other) noexcept
Move constructor, transfer the state from __other.
any (const any &__other)
Copy constructor, copies the state of __other.
template<typename _Tp , typename... _Args, typename_VTp = decay_t<_Tp>, typename_Mgr =
_Manager<_VTp>, __any_constructible_t< _VTp, _Args &&... > = false> any (in_place_type_t< _Tp >,
_Args &&... __args)
Construct with an object created from __args as the contained object.
template<typename _Tp , typename _Up , typename... _Args, typename_VTp = decay_t<_Tp>, typename_Mgr =
_Manager<_VTp>, __any_constructible_t< _VTp, initializer_list< _Up > &, _Args &&... > = false> any
(in_place_type_t< _Tp >, initializer_list< _Up > __il, _Args &&... __args)
Construct with an object created from __il and __args as the contained object.
~any ()
Destructor, calls reset()
template<typename _Tp , typename... _Args> __emplace_t< decay_t< _Tp >, _Args... > emplace (_Args &&...
__args)
Emplace with an object created from __args as the contained object.
template<typename _Tp , typename _Up , typename... _Args> __emplace_t< decay_t< _Tp >, initializer_list<
_Up > &, _Args &&... > emplace (initializer_list< _Up > __il, _Args &&... __args)
Emplace with an object created from __il and __args as the contained object.
bool has_value () const noexcept
Reports whether there is a contained object or not.
template<typename _Tp > enable_if_t< is_copy_constructible< _Decay_if_not_any< _Tp > >::value, any & >
operator= (_Tp &&__rhs)
Store a copy of __rhs as the contained object.
any & operator= (any &&__rhs) noexcept
Move assignment operator.
any & operator= (const any &__rhs)
Copy the state of another object.
voidreset () noexcept
If not empty, destroy the contained object.
voidswap (any &__rhs) noexcept
Exchange state with another object.
const type_info & type () const noexcept
The typeid of the contained object, or typeid(void) if empty.
