Type-safe container of any type
Experimental
Collaboration diagram for Type-safe container of any type:

## Classes

class | std::experimental::fundamentals_v1::any
class | std::experimental::fundamentals_v1::bad_any_cast

## 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 ()
void | std::experimental::__throw_bad_any_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)
any & | std::experimental::fundamentals_v1::any::operator= (any &&__rhs) noexcept
_Storage & | std::experimental::fundamentals_v1::any::_Storage::operator= (const _Storage &)=delete
any & | std::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_info & | std::experimental::fundamentals_v1::any::type () const noexcept
virtual const char * | std::experimental::fundamentals_v1::bad_any_cast::what () const noexcept

## Variables

any * | std::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_info * | std::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 | ( |  | ) |

inline noexcept

Default constructor, creates an empty object.

Definition at line 126 of file 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 163 of file any.

## any() [3/4]

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

inline noexcept

Move constructor, transfer the state from `__other`.

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

Definition at line 146 of file any.

## any() [4/4]

std::experimental::fundamentals_v1::any::any | ( | const any & | __other | ) |

inline

Copy constructor, copies the state of `__other`.

Definition at line 129 of file any.

## ~any()

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

inline

Destructor, calls `clear()`

Definition at line 185 of file 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

  _ValueType | A reference or CopyConstructible type.

Parameters

  __any | The object to access.

Returns
  The contained object.

Exceptions

  bad_any_cast | If `__any.type() != typeid(remove_reference_t<_ValueType>)`

Definition at line 484 of file 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

  _ValueType | A reference or CopyConstructible type.

Parameters

  __any | The object to access.

Returns
  The contained object.

Exceptions

  bad_any_cast | If `__any.type() != typeid(remove_reference_t<_ValueType>)`

Definition at line 518 of file 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

  _ValueType | A reference or CopyConstructible type.

Parameters

  __any | The object to access.

Returns
  The contained object.

Exceptions

  bad_any_cast | If `__any.type() != typeid(remove_reference_t<_ValueType>)`

Definition at line 389 of file any.

## any_cast() [2/5]

template<typename _ValueType >

_ValueType std::experimental::fundamentals_v1::any_cast | ( | any & | __any | ) |

inline

Access the contained object.

Template Parameters

  _ValueType | A reference or CopyConstructible type.

Parameters

  __any | The object to access.

Returns
  The contained object.

Exceptions

  bad_any_cast | If `__any.type() != typeid(remove_reference_t<_ValueType>)`

Definition at line 375 of file any.

## any_cast() [3/5]

template<typename _ValueType >

_ValueType* std::experimental::fundamentals_v1::any_cast | ( | any * | __any | ) |

inline noexcept

Access the contained object.

Template Parameters

  _ValueType | A reference or CopyConstructible type.

Parameters

  __any | The object to access.

Returns
  The contained object.

Exceptions

  bad_any_cast | If `__any.type() != typeid(remove_reference_t<_ValueType>)`

Definition at line 473 of file 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

  _ValueType | A const-reference or CopyConstructible type.

Parameters

  __any | The object to access.

Returns
  The contained object.

Exceptions

  bad_any_cast | If `__any.type() != typeid(remove_reference_t<_ValueType>)`

Definition at line 352 of file any.

## any_cast() [5/5]

template<typename _ValueType >

const _ValueType* std::experimental::fundamentals_v1::any_cast | ( | const any * | __any | ) |

inline noexcept

Access the contained object.

Template Parameters

  _ValueType | The type of the contained object.

Parameters

  __any | A 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 465 of file any.

## clear()

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

inline noexcept

If not empty, destroy the contained object.

Definition at line 227 of file any.

## empty()

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

inline noexcept

Reports whether there is a contained object or not.

Definition at line 269 of file 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 218 of file any.

## operator=() [2/3]

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

inline noexcept

Move assignment operator.

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

Definition at line 201 of file any.

## operator=() [3/3]

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

inline

Copy the state of another object.

Definition at line 190 of file any.

## swap() [1/2]

void std::experimental::fundamentals_v1::any::swap | ( | any & | __rhs | ) |

inline noexcept

Exchange state with another object.

Definition at line 237 of file any.

## swap() [2/2]

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

inline noexcept

Exchange the states of two `any` objects.

Definition at line 339 of file any.

## type()

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

inline noexcept

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

Definition at line 273 of file any.

## what()

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

inline virtual noexcept

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

Reimplemented from std::bad_cast.

Definition at line 69 of file any.