30#ifndef _GLIBCXX_EXPERIMENTAL_ANY
31#define _GLIBCXX_EXPERIMENTAL_ANY 1
34#pragma GCC system_header
39#if __cplusplus >= 201402L
65#define __cpp_lib_experimental_any 201411
74 virtual const char*
what() const noexcept {
return "bad any_cast"; }
78 [[gnu::noreturn]]
inline void __throw_bad_any_cast()
110 template<
typename _Tp,
typename _Safe = is_nothrow_move_constructible<_Tp>,
111 bool _Fits = (sizeof(_Tp) <= sizeof(_Storage))
112 && (alignof(_Tp) <= alignof(_Storage))>
113 using _Internal = std::
integral_constant<
bool, _Safe::value && _Fits>;
115 template<
typename _Tp>
118 template<
typename _Tp>
121 template<
typename _Tp>
126 template<
typename _Tp,
typename _Decayed = decay_t<_Tp>>
166 template <
typename _ValueType,
typename _Tp = _Decay<_ValueType>,
167 typename _Mgr = _Manager<_Tp>,
168 typename enable_if<is_constructible<_Tp, _ValueType&&>::value,
175 "The contained object must be CopyConstructible");
179 template <
typename _ValueType,
typename _Tp = _Decay<_ValueType>,
180 typename _Mgr = _Manager<_Tp>,
181 typename enable_if<!is_constructible<_Tp, _ValueType&&>::value,
188 "The contained object must be CopyConstructible");
212 else if (
this != &__rhs)
223 template<
typename _ValueType>
246 if (
empty() && __rhs.empty())
249 if (!
empty() && !__rhs.empty())
265 any* __empty =
empty() ? this : &__rhs;
266 any* __full =
empty() ? &__rhs :
this;
290 template<
typename _Tp>
309 template<
typename _Tp>
314 template<
typename _Tp>
320 template<
typename _Up>
330 template<
typename _Tp>
336 template<
typename _Up>
346 inline void swap(
any& __x,
any& __y)
noexcept { __x.swap(__y); }
358 template<
typename _ValueType>
362 "Template argument must be a reference or CopyConstructible type");
366 __throw_bad_any_cast();
381 template<
typename _ValueType>
385 "Template argument must be a reference or CopyConstructible type");
389 __throw_bad_any_cast();
392 template<
typename _ValueType,
399 "Template argument must be a reference or CopyConstructible type");
403 __throw_bad_any_cast();
406 template<
typename _ValueType,
410 inline _ValueType
any_cast(any&& __any)
413 "Template argument must be a reference or CopyConstructible type");
417 __throw_bad_any_cast();
422 template<
typename _Tp>
423 enable_if_t<is_object<_Tp>::value,
void*>
424 __any_caster(
const any* __any)
428 using _Up = remove_cv_t<_Tp>;
433 using __is_copyable = is_copy_constructible<_Up>;
437 using _Vp = __conditional_t<__and_<__does_not_decay, __is_copyable>{},
442 || __any->type() ==
typeid(_Tp)
454 template<
typename _Tp>
455 enable_if_t<!is_object<_Tp>::value, _Tp*>
456 __any_caster(
const any*)
noexcept
471 template<
typename _ValueType>
475 return static_cast<_ValueType*
>(__any_caster<_ValueType>(__any));
479 template<
typename _ValueType>
483 return static_cast<_ValueType*
>(__any_caster<_ValueType>(__any));
488 template<
typename _Tp>
498 __arg->
_M_obj =
const_cast<_Tp*
>(__ptr);
522 template<
typename _Tp>
532 __arg->
_M_obj =
const_cast<_Tp*
>(__ptr);
#define _GLIBCXX_VISIBILITY(V)
#define _GLIBCXX_NODISCARD
#define _GLIBCXX_END_NAMESPACE_VERSION
#define _GLIBCXX_BEGIN_NAMESPACE_VERSION
typename __conditional< _Cond >::template type< _If, _Else > __conditional_t
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
_ValueType any_cast(const any &__any)
Access the contained object.
static void _S_manage(_Op __which, const any *__anyp, _Arg *__arg)
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
static void _S_manage(_Op __which, const any *__anyp, _Arg *__arg)
ISO C++ entities toplevel namespace is std.
Namespace for features defined in ISO Technical Specifications.
Define a member typedef type only if a boolean constant is true.
virtual const char * what() const noexcept
Exception class thrown by a failed any_cast.
bool empty() const noexcept
Reports whether there is a contained object or not.
any(const any &__other)
Copy constructor, copies the state of __other.
__conditional_t< _Internal< _Tp >::value, _Manager_internal< _Tp >, _Manager_external< _Tp > > _Manager
any(any &&__other) noexcept
Move constructor, transfer the state from __other.
any & operator=(any &&__rhs) noexcept
Move assignment operator.
const type_info & type() const noexcept
The typeid of the contained object, or typeid(void) if empty.
friend enable_if_t< is_object< _Tp >::value, void * > __any_caster(const any *__any)
void clear() noexcept
If not empty, destroy the contained object.
any() noexcept
Default constructor, creates an empty object.
void swap(any &__rhs) noexcept
Exchange state with another object.
~any()
Destructor, calls clear().
void(* _M_manager)(_Op, const any *, _Arg *)
any & operator=(const any &__rhs)
Copy the state of another object.
static constexpr bool __is_valid_cast()
any(_ValueType &&__value)
Construct with a copy of __value as the contained object.
enable_if_t<!is_same< any, decay_t< _ValueType > >::value, any & > operator=(_ValueType &&__rhs)
Store a copy of __rhs as the contained object.
enable_if_t<!is_same< _Decayed, any >::value, _Decayed > _Decay
A type-safe container of any type.
unsigned char _M_buffer[sizeof(_M_ptr)]
_Storage & operator=(const _Storage &)=delete
_Storage(const _Storage &)=delete
static void _S_create(_Storage &__storage, _Up &&__value)
static void _S_create(_Storage &__storage, _Up &&__value)
const std::type_info * _M_typeinfo
static void _S_manage(_Op, const any *, _Arg *)