STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
any Class Reference

Classes

struct  _Big_storage_t
 
struct  _Small_storage_t
 
struct  _Storage_t
 

Public Member Functions

constexpr any () _NOEXCEPT
 
 any (const any &_That)
 
 any (any &&_That) _NOEXCEPT
 
template<class _ValueType , enable_if_t<!is_same< decay_t< _ValueType >, any >::value &&!_Is_specialization< decay_t< _ValueType >, in_place_type_t >::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
 any (_ValueType &&_Value)
 
template<class _ValueType , class... _Types, enable_if_t< is_constructible< decay_t< _ValueType >, _Types...>::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
 any (in_place_type_t< _ValueType >, _Types &&..._Args)
 
template<class _ValueType , class _Elem , class... _Types, enable_if_t< is_constructible< decay_t< _ValueType >, initializer_list< _Elem > &, _Types...>::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
 any (in_place_type_t< _ValueType >, initializer_list< _Elem > _Ilist, _Types &&..._Args)
 
 ~any () _NOEXCEPT
 
anyoperator= (const any &_That)
 
anyoperator= (any &&_That) _NOEXCEPT
 
template<class _ValueType , enable_if_t<!is_same< decay_t< _ValueType >, any >::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
anyoperator= (_ValueType &&_Value)
 
template<class _ValueType , class... _Types, enable_if_t< is_constructible< decay_t< _ValueType >, _Types...>::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
void emplace (_Types &&..._Args)
 
template<class _ValueType , class _Elem , class... _Types, enable_if_t< is_constructible< decay_t< _ValueType >, initializer_list< _Elem > &, _Types...>::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
void emplace (initializer_list< _Elem > _Ilist, _Types &&..._Args)
 
void reset () _NOEXCEPT
 
void swap (any &_That) _NOEXCEPT
 
bool has_value () const _NOEXCEPT
 
const type_infotype () const _NOEXCEPT
 
template<class _Decayed >
const _Decayed * _Cast () const _NOEXCEPT
 
template<class _Decayed >
_Decayed * _Cast () _NOEXCEPT
 

Private Member Functions

_Any_representation _Rep () const
 
const type_info_TypeInfo () const
 
void _Move_from (any &_That)
 
template<class _Decayed , class... _Types>
void _Emplace (_Types &&..._Args)
 
template<class _Decayed , class... _Types>
void _Emplace1 (false_type, false_type, _Types &&..._Args)
 
template<class _Decayed , class... _Types>
void _Emplace1 (true_type, false_type, _Types &&..._Args)
 
template<class _Decayed , class... _Types>
void _Emplace1 (_Any_tag, true_type, _Types &&..._Args)
 
template<class _Decayed >
const _Decayed * _Cast1 (false_type, false_type) const _NOEXCEPT
 
template<class _Decayed >
const _Decayed * _Cast1 (true_type, false_type) const _NOEXCEPT
 
template<class _Decayed >
const _Decayed * _Cast1 (_Any_tag, true_type) const _NOEXCEPT
 
uintptr_t_TypeData ()&
 
const uintptr_t_TypeData () const &
 
void *& _BigPointer ()&
 
void *const & _BigPointer () const &
 
const _Any_big_RTTI *& _BigRTTI ()&
 
const _Any_big_RTTI *const & _BigRTTI () const &
 
void_SmallData ()&
 
const void_SmallData () const &
 
const _Any_small_RTTI *& _SmallRTTI ()&
 
const _Any_small_RTTI *const & _SmallRTTI () const &
 

Private Attributes

union {
   _Storage_t   _Storage
 
   max_align_t   _Dummy
 
}; 
 

Static Private Attributes

static constexpr uintptr_t _Rep_mask = 3
 

Constructor & Destructor Documentation

constexpr any::any ( )
inline
118  : _Storage{}
119  { // initialize to the empty state
120  }
Definition: functional:419
any::any ( const any _That)
inline
123  { // copy _That's value
124  _TypeData() = _That._TypeData();
125  switch (_Rep())
126  {
128  _SmallRTTI() = _That._SmallRTTI();
129  _SmallRTTI()->_Copy(_SmallData(), _That._SmallData());
130  break;
132  _BigRTTI() = _That._BigRTTI();
133  _BigPointer() = _BigRTTI()->_Copy(_That._BigPointer());
134  break;
136  default:
137  _Storage._TrivialData = _That._Storage._TrivialData;
138  break;
139  }
140  }
_Copy_fn * _Copy
Definition: any:72
void *& _BigPointer()&
Definition: any:382
void * _SmallData()&
Definition: any:400
_Any_representation _Rep() const
Definition: any:284
aligned_union_t< _Any_trivial_space_size, void * > _TrivialData
Definition: any:435
_Storage_t _Storage
Definition: any:444
uintptr_t & _TypeData()&
Definition: any:373
_Copy_fn * _Copy
Definition: any:100
Definition: functional:419
const _Any_small_RTTI *& _SmallRTTI()&
Definition: any:409
const _Any_big_RTTI *& _BigRTTI()&
Definition: any:391
any::any ( any &&  _That)
inline
143  { // steal _That's value
144  _Move_from(_That);
145  }
void _Move_from(any &_That)
Definition: any:293
template<class _ValueType , enable_if_t<!is_same< decay_t< _ValueType >, any >::value &&!_Is_specialization< decay_t< _ValueType >, in_place_type_t >::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
any::any ( _ValueType &&  _Value)
inline
152  { // initialize with _Value
153  _Emplace<decay_t<_ValueType>>(_STD forward<_ValueType>(_Value));
154  }
_In_ _Value
Definition: corecrt_wstdlib.h:65
template<class _ValueType , class... _Types, enable_if_t< is_constructible< decay_t< _ValueType >, _Types...>::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
any::any ( in_place_type_t< _ValueType >  ,
_Types &&...  _Args 
)
inlineexplicit
161  { // in-place initialize a value of type decay_t<_ValueType> with _Args...
162  _Emplace<decay_t<_ValueType>>(_STD forward<_Types>(_Args)...);
163  }
template<class _ValueType , class _Elem , class... _Types, enable_if_t< is_constructible< decay_t< _ValueType >, initializer_list< _Elem > &, _Types...>::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
any::any ( in_place_type_t< _ValueType >  ,
initializer_list< _Elem >  _Ilist,
_Types &&...  _Args 
)
inlineexplicit
171  { // in-place initialize a value of type decay_t<_ValueType> with _Ilist and _Args...
172  _Emplace<decay_t<_ValueType>>(_Ilist, _STD forward<_Types>(_Args)...);
173  }
any::~any ( )
inline
176  { // destroy the contained value, if any (pun intended)
177  reset();
178  }
void reset() _NOEXCEPT
Definition: any:224

Member Function Documentation

void*& any::_BigPointer ( )
inlineprivate
383  {
384  return (_Storage._BigStorage._Ptr);
385  }
Definition: functional:419
void* const& any::_BigPointer ( ) const
inlineprivate
387  {
388  return (_Storage._BigStorage._Ptr);
389  }
Definition: functional:419
const _Any_big_RTTI*& any::_BigRTTI ( )
inlineprivate
392  {
393  return (_Storage._BigStorage._RTTI);
394  }
Definition: functional:419
const _Any_big_RTTI* const& any::_BigRTTI ( ) const
inlineprivate
396  {
397  return (_Storage._BigStorage._RTTI);
398  }
Definition: functional:419
template<class _Decayed >
const _Decayed* any::_Cast ( ) const
inline
265  { // if *this contains a value of type _Decayed, return a pointer to it
266  const type_info * const _Info = _TypeInfo();
267  if (_Info && *_Info == typeid(_Decayed))
268  {
269  return (_Cast1<_Decayed>(_Any_is_small<_Decayed>{}, _Any_is_trivial<_Decayed>{}));
270  }
271 
272  return (nullptr_t{});
273  }
const type_info * _TypeInfo() const
Definition: any:288
Definition: vcruntime_typeinfo.h:62
template<class _Decayed >
_Decayed* any::_Cast ( )
inline
277  { // if *this contains a value of type _Decayed, return a pointer to it
278  return (const_cast<_Decayed *>(const_cast<const any *>(this)->_Cast<_Decayed>()));
279  }
template<class _Decayed >
const _Decayed* any::_Cast1 ( false_type  ,
false_type   
) const
inlineprivate
357  { // get a pointer to the contained _Big value of type _Decayed
358  return (static_cast<const _Decayed *>(_BigPointer()));
359  }
void *& _BigPointer()&
Definition: any:382
template<class _Decayed >
const _Decayed* any::_Cast1 ( true_type  ,
false_type   
) const
inlineprivate
363  { // get a pointer to the contained _Small value of type _Decayed
364  return (static_cast<const _Decayed *>(_SmallData()));
365  }
void * _SmallData()&
Definition: any:400
template<class _Decayed >
const _Decayed* any::_Cast1 ( _Any_tag  ,
true_type   
) const
inlineprivate
369  { // get a pointer to the contained _Trivial value of type _Decayed
370  return (reinterpret_cast<const _Decayed *>(&_Storage._TrivialData));
371  }
Definition: functional:419
template<class _Decayed , class... _Types>
void any::_Emplace ( _Types &&...  _Args)
inlineprivate
317  {
318  static_assert(alignof(_Decayed) <= alignof(max_align_t),
319  "Sorry: std::any doesn't support over-aligned types at this time.");
320  _Emplace1<_Decayed>(_Any_is_small<_Decayed>{}, _Any_is_trivial<_Decayed>{},
321  _STD forward<_Types>(_Args)...);
322  }
double max_align_t
Definition: cstddef:11
template<class _Decayed , class... _Types>
void any::_Emplace1 ( false_type  ,
false_type  ,
_Types &&...  _Args 
)
inlineprivate
327  { // emplace construct _Decayed using the _Big representation
328  _BigPointer() = ::new _Decayed(_STD forward<_Types>(_Args)...);
329  _BigRTTI() = &_Any_big_RTTI_obj<_Decayed>;
330  _TypeData() = reinterpret_cast<uintptr_t>(&typeid(_Decayed))
331  | static_cast<uintptr_t>(_Any_representation::_Big);
332  }
void *& _BigPointer()&
Definition: any:382
unsigned int uintptr_t
Definition: vadefs.h:30
uintptr_t & _TypeData()&
Definition: any:373
const _Any_big_RTTI *& _BigRTTI()&
Definition: any:391
template<class _Decayed , class... _Types>
void any::_Emplace1 ( true_type  ,
false_type  ,
_Types &&...  _Args 
)
inlineprivate
337  { // emplace construct _Decayed using the _Small representation
338  _Construct_in_place(reinterpret_cast<_Decayed&>(_Storage._SmallStorage._Data),
339  _STD forward<_Types>(_Args)...);
340  _SmallRTTI() = &_Any_small_RTTI_obj<_Decayed>;
341  _TypeData() = reinterpret_cast<uintptr_t>(&typeid(_Decayed))
342  | static_cast<uintptr_t>(_Any_representation::_Small);
343  }
void _Construct_in_place(_Ty &_Obj, _Types &&..._Args)
Definition: xmemory0:146
unsigned int uintptr_t
Definition: vadefs.h:30
uintptr_t & _TypeData()&
Definition: any:373
Definition: functional:419
const _Any_small_RTTI *& _SmallRTTI()&
Definition: any:409
template<class _Decayed , class... _Types>
void any::_Emplace1 ( _Any_tag  ,
true_type  ,
_Types &&...  _Args 
)
inlineprivate
348  { // emplace construct _Decayed using the _Trivial representation
349  _Construct_in_place(reinterpret_cast<_Decayed&>(_Storage._TrivialData),
350  _STD forward<_Types>(_Args)...);
351  _TypeData() = reinterpret_cast<uintptr_t>(&typeid(_Decayed))
353  }
void _Construct_in_place(_Ty &_Obj, _Types &&..._Args)
Definition: xmemory0:146
unsigned int uintptr_t
Definition: vadefs.h:30
uintptr_t & _TypeData()&
Definition: any:373
Definition: functional:419
void any::_Move_from ( any _That)
inlineprivate
294  {
295  _TypeData() = _That._TypeData();
296  switch (_Rep())
297  {
299  _SmallRTTI() = _That._SmallRTTI();
300  _SmallRTTI()->_Move(_SmallData(), _That._SmallData());
301  break;
303  _BigRTTI() = _That._BigRTTI();
304  _BigPointer() = _That._BigPointer();
305  _That._TypeData() = 0;
306  break;
308  default:
309  _Storage._TrivialData = _That._Storage._TrivialData;
310  break;
311  }
312  }
void *& _BigPointer()&
Definition: any:382
void * _SmallData()&
Definition: any:400
_Any_representation _Rep() const
Definition: any:284
aligned_union_t< _Any_trivial_space_size, void * > _TrivialData
Definition: any:435
_Storage_t _Storage
Definition: any:444
uintptr_t & _TypeData()&
Definition: any:373
Definition: functional:419
const _Any_small_RTTI *& _SmallRTTI()&
Definition: any:409
_Move_fn * _Move
Definition: any:101
const _Any_big_RTTI *& _BigRTTI()&
Definition: any:391
_Any_representation any::_Rep ( ) const
inlineprivate
285  { // extract the representation format from _TypeData
286  return (static_cast<_Any_representation>(_TypeData() & _Rep_mask));
287  }
static constexpr uintptr_t _Rep_mask
Definition: any:282
uintptr_t & _TypeData()&
Definition: any:373
void* any::_SmallData ( )
inlineprivate
401  {
402  return (&_Storage._SmallStorage._Data);
403  }
Definition: functional:419
const void* any::_SmallData ( ) const
inlineprivate
405  {
406  return (&_Storage._SmallStorage._Data);
407  }
Definition: functional:419
const _Any_small_RTTI*& any::_SmallRTTI ( )
inlineprivate
410  {
411  return (_Storage._SmallStorage._RTTI);
412  }
Definition: functional:419
const _Any_small_RTTI* const& any::_SmallRTTI ( ) const
inlineprivate
414  {
415  return (_Storage._SmallStorage._RTTI);
416  }
Definition: functional:419
uintptr_t& any::_TypeData ( )
inlineprivate
374  {
375  return (_Storage._TypeData);
376  }
Definition: functional:419
const uintptr_t& any::_TypeData ( ) const
inlineprivate
378  {
379  return (_Storage._TypeData);
380  }
Definition: functional:419
const type_info* any::_TypeInfo ( ) const
inlineprivate
289  { // extract the type_info from _TypeData
290  return (reinterpret_cast<const type_info *>(_TypeData() & ~_Rep_mask));
291  }
static constexpr uintptr_t _Rep_mask
Definition: any:282
uintptr_t & _TypeData()&
Definition: any:373
template<class _ValueType , class... _Types, enable_if_t< is_constructible< decay_t< _ValueType >, _Types...>::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
void any::emplace ( _Types &&...  _Args)
inline
209  { // replace contained value with an object of type decay_t<_ValueType> initialized from _Args...
210  reset();
211  _Emplace<decay_t<_ValueType>>(_STD forward<_Types>(_Args)...);
212  }
void reset() _NOEXCEPT
Definition: any:224
template<class _ValueType , class _Elem , class... _Types, enable_if_t< is_constructible< decay_t< _ValueType >, initializer_list< _Elem > &, _Types...>::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
void any::emplace ( initializer_list< _Elem >  _Ilist,
_Types &&...  _Args 
)
inline
219  { // replace contained value with an object of type decay_t<_ValueType> initialized from _Ilist and _Args...
220  reset();
221  _Emplace<decay_t<_ValueType>>(_Ilist, _STD forward<_Types>(_Args)...);
222  }
void reset() _NOEXCEPT
Definition: any:224
bool any::has_value ( ) const
inline
248  { // return true iff *this contains a value
249  return (_TypeData() != 0);
250  }
uintptr_t & _TypeData()&
Definition: any:373
any& any::operator= ( const any _That)
inline
182  { // copy _That's value to *this, if any
183  *this = any{_That};
184  return (*this);
185  }
Definition: any:113
any& any::operator= ( any &&  _That)
inline
188  { // move _That's value to *this, if any
189  reset();
190  _Move_from(_That);
191  return (*this);
192  }
void reset() _NOEXCEPT
Definition: any:224
void _Move_from(any &_That)
Definition: any:293
template<class _ValueType , enable_if_t<!is_same< decay_t< _ValueType >, any >::value &&is_copy_constructible< decay_t< _ValueType >>::value, int > = 0>
any& any::operator= ( _ValueType &&  _Value)
inline
198  { // replace contained value with an object of type decay_t<_ValueType> initialized from _Value
199  *this = any{_STD forward<_ValueType>(_Value)};
200  return (*this);
201  }
Definition: any:113
_In_ _Value
Definition: corecrt_wstdlib.h:65
void any::reset ( )
inline
225  { // transition to the empty state
226  switch (_Rep())
227  {
230  break;
233  break;
235  default:
236  break;
237  }
238  _TypeData() = 0;
239  }
void *& _BigPointer()&
Definition: any:382
void * _SmallData()&
Definition: any:400
_Any_representation _Rep() const
Definition: any:284
uintptr_t & _TypeData()&
Definition: any:373
_Destroy_fn * _Destroy
Definition: any:71
const _Any_small_RTTI *& _SmallRTTI()&
Definition: any:409
_Destroy_fn * _Destroy
Definition: any:99
const _Any_big_RTTI *& _BigRTTI()&
Definition: any:391
void any::swap ( any _That)
inline
242  { // exchange the values of *this and _That
243  _That = _STD exchange(*this, _STD move(_That));
244  }
constexpr remove_reference< _Ty >::type && move(_Ty &&_Arg) _NOEXCEPT
Definition: type_traits:1349
_Ty exchange(_Ty &_Val, _Other &&_New_val)
Definition: utility:629
const type_info& any::type ( ) const
inline
253  { // if *this contains a value of type T, return typeid(T); otherwise typeid(void)
254  const type_info * const _Info = _TypeInfo();
255  if (_Info)
256  {
257  return (*_Info);
258  }
259 
260  return (typeid(void));
261  }
const type_info * _TypeInfo() const
Definition: any:288
Definition: vcruntime_typeinfo.h:62

Member Data Documentation

union { ... }
max_align_t any::_Dummy
constexpr uintptr_t any::_Rep_mask = 3
staticprivate
_Storage_t any::_Storage

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