libstdc++
std::any Class Reference

Public Member Functions

constexpr any () noexcept
 
template<typename _Tp , typename _VTp = _Decay_if_not_any<_Tp>, typename _Mgr = _Manager<_VTp>, enable_if_t< is_copy_constructible< _VTp >::value &&!__is_in_place_type< _VTp >::value, bool > = true>
 any (_Tp &&__value)
 
 any (any &&__other) noexcept
 
 any (const any &__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)
 
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)
 
 ~any ()
 
template<typename _Tp , typename... _Args>
__emplace_t< decay_t< _Tp >, _Args... > emplace (_Args &&... __args)
 
template<typename _Tp , typename _Up , typename... _Args>
__emplace_t< decay_t< _Tp >, initializer_list< _Up > &, _Args &&... > emplace (initializer_list< _Up > __il, _Args &&... __args)
 
bool has_value () const noexcept
 
template<typename _Tp >
enable_if_t< is_copy_constructible< _Decay_if_not_any< _Tp > >::value, any & > operator= (_Tp &&__rhs)
 
anyoperator= (any &&__rhs) noexcept
 
anyoperator= (const any &__rhs)
 
void reset () noexcept
 
void swap (any &__rhs) noexcept
 
const type_infotype () const noexcept
 

Static Public Member Functions

template<typename _Tp >
static constexpr bool __is_valid_cast ()
 

Friends

template<typename _Tp >
void * __any_caster (const any *__any)
 

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.

Definition at line 77 of file any.

Constructor & Destructor Documentation

◆ any() [1/6]

constexpr std::any::any ( )
inlineconstexprnoexcept

Default constructor, creates an empty object.

Definition at line 150 of file any.

Referenced by operator=().

◆ any() [2/6]

std::any::any ( const any __other)
inline

Copy constructor, copies the state of __other.

Definition at line 153 of file any.

References has_value().

◆ any() [3/6]

std::any::any ( any &&  __other)
inlinenoexcept

Move constructor, transfer the state from __other.

Postcondition
!__other.has_value() (this postcondition is a GNU extension)

Definition at line 170 of file any.

◆ any() [4/6]

template<typename _Tp , typename _VTp = _Decay_if_not_any<_Tp>, typename _Mgr = _Manager<_VTp>, enable_if_t< is_copy_constructible< _VTp >::value &&!__is_in_place_type< _VTp >::value, bool > = true>
std::any::any ( _Tp &&  __value)
inline

Construct with a copy of __value as the contained object.

Definition at line 187 of file any.

◆ any() [5/6]

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 
)
inlineexplicit

Construct with an object created from __args as the contained object.

Definition at line 198 of file any.

◆ any() [6/6]

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 
)
inlineexplicit

Construct with an object created from __il and __args as the contained object.

Definition at line 211 of file any.

◆ ~any()

std::any::~any ( )
inline

Destructor, calls reset()

Definition at line 218 of file any.

References reset().

Member Function Documentation

◆ emplace() [1/2]

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.

Definition at line 262 of file any.

◆ emplace() [2/2]

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.

Definition at line 273 of file any.

◆ has_value()

bool std::any::has_value ( ) const
inlinenoexcept

Reports whether there is a contained object or not.

Definition at line 325 of file any.

Referenced by any(), reset(), swap(), and type().

◆ operator=() [1/3]

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.

Definition at line 253 of file any.

References any().

◆ operator=() [2/3]

any& std::any::operator= ( any &&  __rhs)
inlinenoexcept

Move assignment operator.

Postcondition
!__rhs.has_value() (not guaranteed for other implementations)

Definition at line 236 of file any.

References reset().

◆ operator=() [3/3]

any& std::any::operator= ( const any __rhs)
inline

Copy the state of another object.

Definition at line 224 of file any.

References any().

◆ reset()

void std::any::reset ( )
inlinenoexcept

If not empty, destroy the contained object.

Definition at line 283 of file any.

References has_value().

Referenced by ~any(), and operator=().

◆ swap()

void std::any::swap ( any __rhs)
inlinenoexcept

Exchange state with another object.

Definition at line 293 of file any.

References has_value().

◆ type()

const type_info& std::any::type ( ) const
inlinenoexcept

The typeid of the contained object, or typeid(void) if empty.

Definition at line 329 of file any.

References has_value().


The documentation for this class was generated from the following file: