libstdc++
Type-safe container of any type
Collaboration diagram for Type-safe container of any type:

Macros

#define __cpp_lib_experimental_any
 

Functions

 std::experimental::fundamentals_v1::any::_Storage::_Storage (const _Storage &)=delete
 
 std::experimental::fundamentals_v1::any::any () noexcept
 
template<typename _ValueType , typename _Tp = _Decay<_ValueType>, typename _Mgr = _Manager<_Tp>, typename enable_if< is_constructible< _Tp, _ValueType && >::value, bool >::type = true>
 std::experimental::fundamentals_v1::any::any (_ValueType &&__value)
 
 std::experimental::fundamentals_v1::any::any (any &&__other) noexcept
 
 std::experimental::fundamentals_v1::any::any (const any &__other)
 
 std::experimental::fundamentals_v1::any::~any ()
 
template<typename _Tp >
static constexpr bool std::experimental::fundamentals_v1::any::__is_valid_cast ()
 
template<typename _Up >
static void std::experimental::fundamentals_v1::any::_Manager_internal< _Tp >::_S_create (_Storage &__storage, _Up &&__value)
 
template<typename _Up >
static void std::experimental::fundamentals_v1::any::_Manager_external< _Tp >::_S_create (_Storage &__storage, _Up &&__value)
 
static void std::experimental::fundamentals_v1::any::_Manager_internal< any::_Op >::_S_manage (_Op, const any *, _Arg *)
 
template<typename _ValueType >
_ValueType std::experimental::any_cast (const any &__any)
 
void std::experimental::fundamentals_v1::any::clear () noexcept
 
bool std::experimental::fundamentals_v1::any::empty () const noexcept
 
template<typename _ValueType >
enable_if_t<!is_same< any, decay_t< _ValueType > >::value, any & > std::experimental::fundamentals_v1::any::operator= (_ValueType &&__rhs)
 
anystd::experimental::fundamentals_v1::any::operator= (any &&__rhs) noexcept
 
_Storage & std::experimental::fundamentals_v1::any::_Storage::operator= (const _Storage &)=delete
 
anystd::experimental::fundamentals_v1::any::operator= (const any &__rhs)
 
void std::experimental::fundamentals_v1::any::swap (any &__rhs) noexcept
 
void std::experimental::swap (any &__x, any &__y) noexcept
 
const type_infostd::experimental::fundamentals_v1::any::type () const noexcept
 
virtual const char * std::experimental::fundamentals_v1::bad_any_cast::what () const noexcept
 

Variables

anystd::experimental::fundamentals_v1::any::_Arg::_M_any
 
aligned_storage< sizeof(_M_ptr), alignof(void *)>::type std::experimental::fundamentals_v1::any::_Storage::_M_buffer
 
void * std::experimental::fundamentals_v1::any::_Arg::_M_obj
 
void * std::experimental::fundamentals_v1::any::_Storage::_M_ptr
 
const std::type_infostd::experimental::fundamentals_v1::any::_Arg::_M_typeinfo
 

Friends

template<typename _Tp >
enable_if_t< is_object< _Tp >::value, void * > std::experimental::fundamentals_v1::any::__any_caster (const any *__any)
 
static void std::experimental::fundamentals_v1::any::_Manager_internal< _Tp >::_S_manage (_Op __which, const any *__anyp, _Arg *__arg)
 
static void std::experimental::fundamentals_v1::any::_Manager_external< _Tp >::_S_manage (_Op __which, const any *__anyp, _Arg *__arg)
 
template<typename _ValueType >
_ValueType std::experimental::any_cast (any &__any)
 
template<typename _ValueType , typename enable_if<!is_move_constructible< _ValueType >::value||is_lvalue_reference< _ValueType >::value, bool >::type = true>
_ValueType std::experimental::any_cast (any &&__any)
 
template<typename _ValueType >
const _ValueType * std::experimental::any_cast (const any *__any) noexcept
 
template<typename _ValueType >
_ValueType * std::experimental::any_cast (any *__any) noexcept
 

Detailed Description

A type-safe container for single values of value types, as described in n3804 "Any Library Proposal (Revision 3)".

Function Documentation

◆ any() [1/4]

std::experimental::fundamentals_v1::any::any ( )
inlinenoexcept

Default constructor, creates an empty object.

Definition at line 129 of file experimental/any.

◆ any() [2/4]

template<typename _ValueType , typename _Tp = _Decay<_ValueType>, typename _Mgr = _Manager<_Tp>, typename enable_if< is_constructible< _Tp, _ValueType && >::value, bool >::type = true>
std::experimental::fundamentals_v1::any::any ( _ValueType &&  __value)
inline

Construct with a copy of __value as the contained object.

Definition at line 166 of file experimental/any.

◆ any() [3/4]

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

Move constructor, transfer the state from __other.

Postcondition
__other.empty() (this postcondition is a GNU extension)

Definition at line 149 of file experimental/any.

◆ any() [4/4]

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

Copy constructor, copies the state of __other.

Definition at line 132 of file experimental/any.

◆ ~any()

std::experimental::fundamentals_v1::any::~any ( )
inline

Destructor, calls clear()

Definition at line 188 of file experimental/any.

◆ _S_manage() [1/2]

template<typename _Tp >
void std::experimental::fundamentals_v1::any::_Manager_internal< _Tp >::_S_manage ( _Op  __which,
const any __anyp,
_Arg *  __arg 
)
static

Access the contained object.

Template Parameters
_ValueTypeA reference or CopyConstructible type.
Parameters
__anyThe object to access.
Returns
The contained object.
Exceptions
bad_any_castIf __any.type() != typeid(remove_reference_t<_ValueType>)

Definition at line 486 of file experimental/any.

◆ _S_manage() [2/2]

template<typename _Tp >
void std::experimental::fundamentals_v1::any::_Manager_external< _Tp >::_S_manage ( _Op  __which,
const any __anyp,
_Arg *  __arg 
)
static

Access the contained object.

Template Parameters
_ValueTypeA reference or CopyConstructible type.
Parameters
__anyThe object to access.
Returns
The contained object.
Exceptions
bad_any_castIf __any.type() != typeid(remove_reference_t<_ValueType>)

Definition at line 520 of file experimental/any.

◆ any_cast() [1/5]

template<typename _ValueType , typename enable_if<!is_move_constructible< _ValueType >::value||is_lvalue_reference< _ValueType >::value, bool >::type = true>
_ValueType std::experimental::fundamentals_v1::any_cast ( any &&  __any)
inline

Access the contained object.

Template Parameters
_ValueTypeA reference or CopyConstructible type.
Parameters
__anyThe object to access.
Returns
The contained object.
Exceptions
bad_any_castIf __any.type() != typeid(remove_reference_t<_ValueType>)

Definition at line 392 of file experimental/any.

◆ any_cast() [2/5]

template<typename _ValueType >
_ValueType std::experimental::fundamentals_v1::any_cast ( any __any)
inline

Access the contained object.

Template Parameters
_ValueTypeA reference or CopyConstructible type.
Parameters
__anyThe object to access.
Returns
The contained object.
Exceptions
bad_any_castIf __any.type() != typeid(remove_reference_t<_ValueType>)

Definition at line 378 of file experimental/any.

◆ any_cast() [3/5]

template<typename _ValueType >
_ValueType* std::experimental::fundamentals_v1::any_cast ( any __any)
inlinenoexcept

Access the contained object.

Template Parameters
_ValueTypeA reference or CopyConstructible type.
Parameters
__anyThe object to access.
Returns
The contained object.
Exceptions
bad_any_castIf __any.type() != typeid(remove_reference_t<_ValueType>)

Definition at line 476 of file experimental/any.

◆ any_cast() [4/5]

template<typename _ValueType >
_ValueType std::experimental::fundamentals_v1::any_cast ( const any __any)
inline

Access the contained object.

Template Parameters
_ValueTypeA const-reference or CopyConstructible type.
Parameters
__anyThe object to access.
Returns
The contained object.
Exceptions
bad_any_castIf __any.type() != typeid(remove_reference_t<_ValueType>)

Definition at line 355 of file experimental/any.

◆ any_cast() [5/5]

template<typename _ValueType >
const _ValueType* std::experimental::fundamentals_v1::any_cast ( const any __any)
inlinenoexcept

Access the contained object.

Template Parameters
_ValueTypeThe type of the contained object.
Parameters
__anyA pointer to the object to access.
Returns
The address of the contained object if __any != nullptr && __any.type() == typeid(_ValueType) , otherwise a null pointer.

Definition at line 468 of file experimental/any.

◆ clear()

void std::experimental::fundamentals_v1::any::clear ( )
inlinenoexcept

If not empty, destroy the contained object.

Definition at line 230 of file experimental/any.

◆ empty()

bool std::experimental::fundamentals_v1::any::empty ( ) const
inlinenoexcept

Reports whether there is a contained object or not.

Definition at line 272 of file experimental/any.

◆ operator=() [1/3]

template<typename _ValueType >
enable_if_t<!is_same<any, decay_t<_ValueType> >::value, any&> std::experimental::fundamentals_v1::any::operator= ( _ValueType &&  __rhs)
inline

Store a copy of __rhs as the contained object.

Definition at line 221 of file experimental/any.

◆ operator=() [2/3]

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

Move assignment operator.

Postcondition
__rhs.empty() (not guaranteed for other implementations)

Definition at line 204 of file experimental/any.

◆ operator=() [3/3]

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

Copy the state of another object.

Definition at line 193 of file experimental/any.

◆ swap() [1/2]

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

Exchange state with another object.

Definition at line 240 of file experimental/any.

◆ swap() [2/2]

void std::experimental::fundamentals_v1::swap ( any __x,
any __y 
)
inlinenoexcept

Exchange the states of two any objects.

Definition at line 342 of file experimental/any.

◆ type()

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

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

Definition at line 276 of file experimental/any.

◆ what()

virtual const char* std::experimental::fundamentals_v1::bad_any_cast::what ( ) const
inlinevirtualnoexcept

Returns a C-style character string describing the general cause of the current error.

Reimplemented from std::bad_cast.

Definition at line 70 of file experimental/any.