STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Macros | Typedefs | Enumerations | Functions | Variables
any File Reference
#include <initializer_list>
#include <typeinfo>
#include <type_traits>
#include <utility>
#include <xmemory0>

Classes

class  bad_any_cast
 
struct  _Any_big_RTTI
 
struct  _Any_small_RTTI
 
class  any
 
struct  any::_Small_storage_t
 
struct  any::_Big_storage_t
 
struct  any::_Storage_t
 

Macros

#define _ANY_
 

Typedefs

template<class _Ty >
using _Any_is_trivial = bool_constant< alignof(_Ty)<=alignof(max_align_t)&&is_trivially_copyable< _Ty >::value &&sizeof(_Ty)<=_Any_trivial_space_size >
 
template<class _Ty >
using _Any_is_small = bool_constant< alignof(_Ty)<=alignof(max_align_t)&&is_nothrow_move_constructible< _Ty >::value &&sizeof(_Ty)<=_Any_small_space_size >
 
template<class _Ty >
using _Any_is_function_or_array = bool_constant< is_function< _Ty >::value||is_array< _Ty >::value >
 

Enumerations

enum  _Any_representation : uintptr_t { _Any_representation::_Trivial, _Any_representation::_Big, _Any_representation::_Small }
 

Functions

void swap (any &_Left, any &_Right) _NOEXCEPT
 
template<class _ValueType , class... _Types>
any make_any (_Types &&..._Args)
 
template<class _ValueType , class _Elem , class... _Types>
any make_any (initializer_list< _Elem > _Ilist, _Types &&..._Args)
 
template<class _ValueType >
const _ValueType * _Any_cast1 (const any *, true_type) _NOEXCEPT
 
template<class _ValueType >
_ValueType * _Any_cast1 (any *, true_type) _NOEXCEPT
 
template<class _ValueType >
const _ValueType * _Any_cast1 (const any *const _Any, false_type) _NOEXCEPT
 
template<class _ValueType >
_ValueType * _Any_cast1 (any *const _Any, false_type) _NOEXCEPT
 
template<class _ValueType >
const _ValueType * any_cast (const any *const _Any) _NOEXCEPT
 
template<class _ValueType >
_ValueType * any_cast (any *const _Any) _NOEXCEPT
 
template<class _Ty >
_Ty any_cast (const any &_Any)
 
template<class _Ty >
_Ty any_cast (any &_Any)
 
template<class _Ty >
_Ty any_cast (any &&_Any)
 

Variables

constexpr size_t _Any_trivial_space_size = (_Small_object_num_ptrs - 1) * sizeof(void *)
 
constexpr size_t _Any_small_space_size = (_Small_object_num_ptrs - 2) * sizeof(void *)
 
template<class _Ty >
constexpr _Any_big_RTTI _Any_big_RTTI_obj
 
template<class _Ty >
constexpr _Any_small_RTTI _Any_small_RTTI_obj
 

Macro Definition Documentation

#define _ANY_

Typedef Documentation

template<class _Ty >
using _Any_is_function_or_array = bool_constant<is_function<_Ty>::value || is_array<_Ty>::value>
template<class _Ty >
using _Any_is_small = bool_constant< alignof(_Ty) <= alignof(max_align_t) && is_nothrow_move_constructible<_Ty>::value && sizeof(_Ty) <= _Any_small_space_size>
template<class _Ty >
using _Any_is_trivial = bool_constant< alignof(_Ty) <= alignof(max_align_t) && is_trivially_copyable<_Ty>::value && sizeof(_Ty) <= _Any_trivial_space_size>

Enumeration Type Documentation

Enumerator
_Trivial 
_Big 
_Small 

Function Documentation

template<class _ValueType >
const _ValueType* _Any_cast1 ( const any ,
true_type   
)
inline
471  { // retrieve a pointer to a function/array type
472  return (nullptr_t{});
473  }
template<class _ValueType >
_ValueType* _Any_cast1 ( any ,
true_type   
)
inline
476  { // retrieve a pointer to a function/array type
477  return (nullptr_t{});
478  }
template<class _ValueType >
const _ValueType* _Any_cast1 ( const any *const  _Any,
false_type   
)
inline
481  { // retrieve a pointer to the _ValueType contained in _Any, or null
482  return (_Any->_Cast<decay_t<_ValueType>>());
483  }
typename decay< _Ty >::type decay_t
Definition: type_traits:2095
const _Decayed * _Cast() const _NOEXCEPT
Definition: any:264
template<class _ValueType >
_ValueType* _Any_cast1 ( any *const  _Any,
false_type   
)
inline
486  { // retrieve a pointer to the _ValueType contained in _Any, or null
487  return (_Any->_Cast<decay_t<_ValueType>>());
488  }
typename decay< _Ty >::type decay_t
Definition: type_traits:2095
const _Decayed * _Cast() const _NOEXCEPT
Definition: any:264
template<class _ValueType >
const _ValueType* any_cast ( const any *const  _Any)
inline
495  { // retrieve a pointer to the _ValueType contained in _Any, or null
496  static_assert(!is_void<_ValueType>::value, "std::any cannot contain void.");
497  if (_Any)
498  {
499  return (_Any_cast1<_ValueType>(_Any, _Any_is_function_or_array<_ValueType>{}));
500  }
501 
502  return (nullptr_t{});
503  }
Definition: type_traits:116
template<class _ValueType >
_ValueType* any_cast ( any *const  _Any)
inline
506  { // retrieve a pointer to the _ValueType contained in _Any, or null
507  static_assert(!is_void<_ValueType>::value, "std::any cannot contain void.");
508  if (_Any)
509  {
510  return (_Any_cast1<_ValueType>(_Any, _Any_is_function_or_array<_ValueType>{}));
511  }
512 
513  return (nullptr_t{});
514  }
Definition: type_traits:116
template<class _Ty >
_Ty any_cast ( const any _Any)
inline
518  { // retrieve _Any's contained value as _Ty
519  static_assert(is_constructible<_Ty, const remove_cv_t<remove_reference_t<_Ty>>&>::value,
520  "any_cast<T>(const any&) requires T to be constructible from const remove_cv_t<remove_reference_t<T>>&");
521  const auto _Ptr = _STD any_cast<remove_cv_t<remove_reference_t<_Ty>>>(&_Any);
522  if (!_Ptr)
523  {
525  }
526 
527  return (static_cast<_Ty>(*_Ptr));
528  }
Definition: any:26
#define _THROW_NCEE(x, y)
Definition: xstddef:51
Definition: type_traits:554
typename remove_reference< _Ty >::type remove_reference_t
Definition: type_traits:2060
#define _EMPTY_ARGUMENT
Definition: xstddef:77
typename remove_cv< _Ty >::type remove_cv_t
Definition: type_traits:2048
const _ValueType * any_cast(const any *const _Any) _NOEXCEPT
Definition: any:494
template<class _Ty >
_Ty any_cast ( any _Any)
inline
531  { // retrieve _Any's contained value as _Ty
532  static_assert(is_constructible<_Ty, remove_cv_t<remove_reference_t<_Ty>>&>::value,
533  "any_cast<T>(any&) requires T to be constructible from remove_cv_t<remove_reference_t<T>>&");
534  const auto _Ptr = _STD any_cast<remove_cv_t<remove_reference_t<_Ty>>>(&_Any);
535  if (!_Ptr)
536  {
538  }
539 
540  return (static_cast<_Ty>(*_Ptr));
541  }
Definition: any:26
#define _THROW_NCEE(x, y)
Definition: xstddef:51
Definition: type_traits:554
typename remove_reference< _Ty >::type remove_reference_t
Definition: type_traits:2060
#define _EMPTY_ARGUMENT
Definition: xstddef:77
typename remove_cv< _Ty >::type remove_cv_t
Definition: type_traits:2048
const _ValueType * any_cast(const any *const _Any) _NOEXCEPT
Definition: any:494
template<class _Ty >
_Ty any_cast ( any &&  _Any)
inline
544  { // retrieve _Any's contained value as _Ty
545  static_assert(is_constructible<_Ty, remove_cv_t<remove_reference_t<_Ty>>>::value,
546  "any_cast<T>(any&&) requires T to be constructible from remove_cv_t<remove_reference_t<T>>");
547  const auto _Ptr = _STD any_cast<remove_cv_t<remove_reference_t<_Ty>>>(&_Any);
548  if (!_Ptr)
549  {
551  }
552 
553  return (static_cast<_Ty>(_STD move(*_Ptr)));
554  }
Definition: any:26
#define _THROW_NCEE(x, y)
Definition: xstddef:51
Definition: type_traits:554
typename remove_reference< _Ty >::type remove_reference_t
Definition: type_traits:2060
#define _EMPTY_ARGUMENT
Definition: xstddef:77
typename remove_cv< _Ty >::type remove_cv_t
Definition: type_traits:2048
constexpr remove_reference< _Ty >::type && move(_Ty &&_Arg) _NOEXCEPT
Definition: type_traits:1349
const _ValueType * any_cast(const any *const _Any) _NOEXCEPT
Definition: any:494
template<class _ValueType , class... _Types>
any make_any ( _Types &&...  _Args)
inline
458  { // construct an any containing a _ValueType initialized with _Args...
459  return (any{in_place_type<_ValueType>, _STD forward<_Types>(_Args)...});
460  }
Definition: any:113
template<class _ValueType , class _Elem , class... _Types>
any make_any ( initializer_list< _Elem >  _Ilist,
_Types &&...  _Args 
)
inline
465  { // construct an any containing a _ValueType initialized with _Ilist and _Args...
466  return (any{in_place_type<_ValueType>, _Ilist, _STD forward<_Types>(_Args)...});
467  }
Definition: any:113
void swap ( any _Left,
any _Right 
)
inline
451  { // exchange the values of _Left and _Right
452  _Left.swap(_Right);
453  }
void swap(any &_That) _NOEXCEPT
Definition: any:241

Variable Documentation

template<class _Ty >
constexpr _Any_big_RTTI _Any_big_RTTI_obj
Initial value:
=
{&_Any_big_RTTI::_Destroy_impl<_Ty>, &_Any_big_RTTI::_Copy_impl<_Ty>}
template<class _Ty >
constexpr _Any_small_RTTI _Any_small_RTTI_obj
Initial value:
=
{&_Any_small_RTTI::_Destroy_impl<_Ty>, &_Any_small_RTTI::_Copy_impl<_Ty>, &_Any_small_RTTI::_Move_impl<_Ty>}
constexpr size_t _Any_small_space_size = (_Small_object_num_ptrs - 2) * sizeof(void *)
constexpr size_t _Any_trivial_space_size = (_Small_object_num_ptrs - 1) * sizeof(void *)