10 #ifndef NONSTD_VARIANT_LITE_HPP 11 #define NONSTD_VARIANT_LITE_HPP 13 #define variant_lite_MAJOR 1 14 #define variant_lite_MINOR 1 15 #define variant_lite_PATCH 0 17 #define variant_lite_VERSION variant_STRINGIFY(variant_lite_MAJOR) "." variant_STRINGIFY(variant_lite_MINOR) "." variant_STRINGIFY(variant_lite_PATCH) 19 #define variant_STRINGIFY( x ) variant_STRINGIFY_( x ) 20 #define variant_STRINGIFY_( x ) #x 24 #define variant_VARIANT_DEFAULT 0 25 #define variant_VARIANT_NONSTD 1 26 #define variant_VARIANT_STD 2 28 #if !defined( variant_CONFIG_SELECT_VARIANT ) 29 # define variant_CONFIG_SELECT_VARIANT ( variant_HAVE_STD_VARIANT ? variant_VARIANT_STD : variant_VARIANT_NONSTD ) 32 #ifndef variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO 33 # define variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO 0 36 #ifndef variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO 37 # define variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO 0 43 #ifndef variant_CPLUSPLUS 44 # if defined(_MSVC_LANG ) && !defined(__clang__) 45 # define variant_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG ) 47 # define variant_CPLUSPLUS __cplusplus 51 #define variant_CPP98_OR_GREATER ( variant_CPLUSPLUS >= 199711L ) 52 #define variant_CPP11_OR_GREATER ( variant_CPLUSPLUS >= 201103L ) 53 #define variant_CPP11_OR_GREATER_ ( variant_CPLUSPLUS >= 201103L ) 54 #define variant_CPP14_OR_GREATER ( variant_CPLUSPLUS >= 201402L ) 55 #define variant_CPP17_OR_GREATER ( variant_CPLUSPLUS >= 201703L ) 56 #define variant_CPP20_OR_GREATER ( variant_CPLUSPLUS >= 202000L ) 60 #if variant_CPP17_OR_GREATER && defined(__has_include ) 61 # if __has_include( <variant> ) 62 # define variant_HAVE_STD_VARIANT 1 64 # define variant_HAVE_STD_VARIANT 0 67 # define variant_HAVE_STD_VARIANT 0 70 #define variant_USES_STD_VARIANT ( (variant_CONFIG_SELECT_VARIANT == variant_VARIANT_STD) || ((variant_CONFIG_SELECT_VARIANT == variant_VARIANT_DEFAULT) && variant_HAVE_STD_VARIANT) ) 76 #ifndef nonstd_lite_HAVE_IN_PLACE_TYPES 77 #define nonstd_lite_HAVE_IN_PLACE_TYPES 1 81 #if variant_CPP17_OR_GREATER 90 using std::in_place_t;
91 using std::in_place_type_t;
92 using std::in_place_index_t;
94 #define nonstd_lite_in_place_t( T) std::in_place_t 95 #define nonstd_lite_in_place_type_t( T) std::in_place_type_t<T> 96 #define nonstd_lite_in_place_index_t(K) std::in_place_index_t<K> 98 #define nonstd_lite_in_place( T) std::in_place_t{} 99 #define nonstd_lite_in_place_type( T) std::in_place_type_t<T>{} 100 #define nonstd_lite_in_place_index(K) std::in_place_index_t<K>{} 104 #else // variant_CPP17_OR_GREATER 112 struct in_place_type_tag {};
114 template< std::
size_t K >
115 struct in_place_index_tag {};
119 struct in_place_t {};
122 inline in_place_t
in_place( detail::in_place_type_tag<T> = detail::in_place_type_tag<T>() )
127 template< std::
size_t K >
128 inline in_place_t
in_place( detail::in_place_index_tag<K> = detail::in_place_index_tag<K>() )
134 inline in_place_t
in_place_type( detail::in_place_type_tag<T> = detail::in_place_type_tag<T>() )
139 template< std::
size_t K >
140 inline in_place_t
in_place_index( detail::in_place_index_tag<K> = detail::in_place_index_tag<K>() )
147 #define nonstd_lite_in_place_t( T) nonstd::in_place_t(&)( nonstd::detail::in_place_type_tag<T> ) 148 #define nonstd_lite_in_place_type_t( T) nonstd::in_place_t(&)( nonstd::detail::in_place_type_tag<T> ) 149 #define nonstd_lite_in_place_index_t(K) nonstd::in_place_t(&)( nonstd::detail::in_place_index_tag<K> ) 151 #define nonstd_lite_in_place( T) nonstd::in_place_type<T> 152 #define nonstd_lite_in_place_type( T) nonstd::in_place_type<T> 153 #define nonstd_lite_in_place_index(K) nonstd::in_place_index<K> 157 #endif // variant_CPP17_OR_GREATER 158 #endif // nonstd_lite_HAVE_IN_PLACE_TYPES 164 #if variant_USES_STD_VARIANT 166 #include <functional> 169 #if ! variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO 170 # define variant_size_V(T) nonstd::variant_size<T>::value 173 #if ! variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO 174 # define variant_alternative_T(K,T) typename nonstd::variant_alternative<K,T >::type 180 using std::monostate;
181 using std::bad_variant_access;
182 using std::variant_size;
183 using std::variant_size_v;
184 using std::variant_alternative;
185 using std::variant_alternative_t;
192 using std::operator==;
193 using std::operator!=;
194 using std::operator<;
195 using std::operator<=;
196 using std::operator>;
197 using std::operator>=;
203 #else // variant_USES_STD_VARIANT 213 #ifndef variant_CONFIG_MAX_ALIGN_HACK 214 # define variant_CONFIG_MAX_ALIGN_HACK 0 217 #ifndef variant_CONFIG_ALIGN_AS 221 #ifndef variant_CONFIG_ALIGN_AS_FALLBACK 222 # define variant_CONFIG_ALIGN_AS_FALLBACK double 226 #define variant_BETWEEN( v, lo, hi ) ( lo <= v && v < hi ) 241 #if defined(_MSC_VER ) && !defined(__clang__) 242 # define variant_COMPILER_MSVC_VER (_MSC_VER ) 243 # define variant_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) ) 245 # define variant_COMPILER_MSVC_VER 0 246 # define variant_COMPILER_MSVC_VERSION 0 249 #define variant_COMPILER_VERSION( major, minor, patch ) ( 10 * ( 10 * (major) + (minor) ) + (patch) ) 251 #if defined(__clang__) 252 # define variant_COMPILER_CLANG_VERSION variant_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) 254 # define variant_COMPILER_CLANG_VERSION 0 257 #if defined(__GNUC__) && !defined(__clang__) 258 # define variant_COMPILER_GNUC_VERSION variant_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) 260 # define variant_COMPILER_GNUC_VERSION 0 263 #if variant_BETWEEN( variant_COMPILER_MSVC_VER, 1300, 1900 ) 264 # pragma warning( push ) 265 # pragma warning( disable: 4345 ) // initialization behavior changed 270 #define variant_HAVE( feature ) ( variant_HAVE_##feature ) 273 # define variant_HAS_CPP0X _HAS_CPP0X 275 # define variant_HAS_CPP0X 0 280 #if variant_COMPILER_MSVC_VER >= 1900 281 # undef variant_CPP11_OR_GREATER 282 # define variant_CPP11_OR_GREATER 1 285 #define variant_CPP11_90 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1500) 286 #define variant_CPP11_100 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1600) 287 #define variant_CPP11_110 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1700) 288 #define variant_CPP11_120 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1800) 289 #define variant_CPP11_140 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1900) 290 #define variant_CPP11_141 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1910) 292 #define variant_CPP14_000 (variant_CPP14_OR_GREATER) 293 #define variant_CPP17_000 (variant_CPP17_OR_GREATER) 297 #define variant_HAVE_CONSTEXPR_11 variant_CPP11_140 298 #define variant_HAVE_INITIALIZER_LIST variant_CPP11_120 299 #define variant_HAVE_NOEXCEPT variant_CPP11_140 300 #define variant_HAVE_NULLPTR variant_CPP11_100 301 #define variant_HAVE_OVERRIDE variant_CPP11_140 305 #define variant_HAVE_CONSTEXPR_14 variant_CPP14_000 313 #define variant_HAVE_TR1_TYPE_TRAITS (!! variant_COMPILER_GNUC_VERSION ) 314 #define variant_HAVE_TR1_ADD_POINTER (!! variant_COMPILER_GNUC_VERSION ) 316 #define variant_HAVE_CONDITIONAL variant_CPP11_120 317 #define variant_HAVE_REMOVE_CV variant_CPP11_120 318 #define variant_HAVE_STD_ADD_POINTER variant_CPP11_90 319 #define variant_HAVE_TYPE_TRAITS variant_CPP11_90 323 #if variant_HAVE_CONSTEXPR_11 324 # define variant_constexpr constexpr 326 # define variant_constexpr 329 #if variant_HAVE_CONSTEXPR_14 330 # define variant_constexpr14 constexpr 332 # define variant_constexpr14 335 #if variant_HAVE_NOEXCEPT 336 # define variant_noexcept noexcept 338 # define variant_noexcept 341 #if variant_HAVE_NULLPTR 342 # define variant_nullptr nullptr 344 # define variant_nullptr NULL 347 #if variant_HAVE_OVERRIDE 348 # define variant_override override 350 # define variant_override 355 #if variant_CPP11_OR_GREATER 356 # include <functional> 359 #if variant_HAVE_INITIALIZER_LIST 360 # include <initializer_list> 363 #if variant_HAVE_TYPE_TRAITS 364 # include <type_traits> 365 #elif variant_HAVE_TR1_TYPE_TRAITS 366 # include <tr1/type_traits> 371 #if variant_CPP11_OR_GREATER 373 # define variant_REQUIRES_T(...) \ 374 , typename = typename std::enable_if<__VA_ARGS__>::type 376 # define variant_REQUIRES_R(R, ...) \ 377 typename std::enable_if<__VA_ARGS__, R>::type 379 # define variant_REQUIRES_A(...) \ 380 , typename std::enable_if<__VA_ARGS__, void*>::type = variant_nullptr 394 #if variant_HAVE_STD_ADD_POINTER 396 using std::add_pointer;
398 #elif variant_HAVE_TR1_ADD_POINTER 400 using std::tr1::add_pointer;
412 #endif // variant_HAVE_STD_ADD_POINTER 414 #if variant_HAVE_REMOVE_CV 416 using std::remove_cv;
432 #endif // variant_HAVE_REMOVE_CV 434 #if variant_HAVE_CONDITIONAL 436 using std::conditional;
440 template<
bool Cond,
class Then,
class Else >
443 template<
class Then,
class Else >
446 template<
class Then,
class Else >
449 #endif // variant_HAVE_CONDITIONAL 453 #define variant_TL1( T1 ) detail::typelist< T1, detail::nulltype > 454 #define variant_TL2( T1, T2) detail::typelist< T1, variant_TL1( T2) > 455 #define variant_TL3( T1, T2, T3) detail::typelist< T1, variant_TL2( T2, T3) > 456 #define variant_TL4( T1, T2, T3, T4) detail::typelist< T1, variant_TL3( T2, T3, T4) > 457 #define variant_TL5( T1, T2, T3, T4, T5) detail::typelist< T1, variant_TL4( T2, T3, T4, T5) > 458 #define variant_TL6( T1, T2, T3, T4, T5, T6) detail::typelist< T1, variant_TL5( T2, T3, T4, T5, T6) > 459 #define variant_TL7( T1, T2, T3, T4, T5, T6, T7) detail::typelist< T1, variant_TL6( T2, T3, T4, T5, T6, T7) > 460 #define variant_TL8( T1, T2, T3, T4, T5, T6, T7, T8) detail::typelist< T1, variant_TL7( T2, T3, T4, T5, T6, T7, T8) > 461 #define variant_TL9( T1, T2, T3, T4, T5, T6, T7, T8, T9) detail::typelist< T1, variant_TL8( T2, T3, T4, T5, T6, T7, T8, T9) > 462 #define variant_TL10( T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) detail::typelist< T1, variant_TL9( T2, T3, T4, T5, T6, T7, T8, T9, T10) > 463 #define variant_TL11( T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) detail::typelist< T1, variant_TL10( T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) > 464 #define variant_TL12( T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) detail::typelist< T1, variant_TL11( T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) > 465 #define variant_TL13( T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) detail::typelist< T1, variant_TL12( T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) > 466 #define variant_TL14( T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) detail::typelist< T1, variant_TL13( T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) > 467 #define variant_TL15( T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) detail::typelist< T1, variant_TL14( T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) > 468 #define variant_TL16( T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) detail::typelist< T1, variant_TL15( T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) > 495 inline bool operator< ( T
const & )
const {
return false; }
505 struct S0{};
typedef TX<S0>
T0;
506 struct S1{};
typedef TX<S1>
T1;
507 struct S2{};
typedef TX<S2>
T2;
508 struct S3{};
typedef TX<S3>
T3;
509 struct S4{};
typedef TX<S4>
T4;
510 struct S5{};
typedef TX<S5>
T5;
511 struct S6{};
typedef TX<S6>
T6;
512 struct S7{};
typedef TX<S7>
T7;
513 struct S8{};
typedef TX<S8>
T8;
514 struct S9{};
typedef TX<S9>
T9;
525 template<
class Head,
class Tail >
534 template<
class List >
540 enum V { value = 0 } ;
544 template<
class Head,
class Tail >
553 enum V { value = (
sizeof( Head ) > tail_value) ?
sizeof( Head ) : std::size_t( tail_value ) } ;
558 #if variant_CPP11_OR_GREATER 562 template<
class List >
563 struct typelist_max_alignof;
566 struct typelist_max_alignof<
nulltype >
568 enum V { value = 0 } ;
571 template<
class Head,
class Tail >
572 struct typelist_max_alignof< typelist<Head, Tail> >
575 enum TV { tail_value = size_t( typelist_max_alignof<Tail>::value ) };
578 enum V { value = (
alignof( Head ) > tail_value) ?
alignof( Head ) : std::size_t( tail_value ) };
585 template<
class List >
611 template<
class Head,
class Tail >
619 template<
class List,
class T >
625 enum V { value = -1 };
628 template<
class Tail,
class T >
631 enum V { value = 0 };
634 template<
class Head,
class Tail,
class T >
641 enum V { value = nextVal == -1 ? -1 : 1 + nextVal } ;
646 template<
class List, std::
size_t i>
649 template<
class Head,
class Tail >
655 template<
class Head,
class Tail, std::
size_t i >
661 #if variant_CONFIG_MAX_ALIGN_HACK 665 #define variant_UNIQUE( name ) variant_UNIQUE2( name, __LINE__ ) 666 #define variant_UNIQUE2( name, line ) variant_UNIQUE3( name, line ) 667 #define variant_UNIQUE3( name, line ) name ## line 669 #define variant_ALIGN_TYPE( type ) \ 670 type variant_UNIQUE( _t ); struct_t< type > variant_UNIQUE( _st ) 693 #ifdef HAVE_LONG_LONG 699 Unknown ( * variant_UNIQUE(_) )( Unknown );
700 Unknown * Unknown::* variant_UNIQUE(_);
701 Unknown ( Unknown::* variant_UNIQUE(_) )( Unknown );
703 struct_t< Unknown ( * )( Unknown) > variant_UNIQUE(_);
704 struct_t< Unknown * Unknown::* > variant_UNIQUE(_);
705 struct_t< Unknown ( Unknown::* )(Unknown) > variant_UNIQUE(_);
708 #undef variant_UNIQUE 709 #undef variant_UNIQUE2 710 #undef variant_UNIQUE3 712 #undef variant_ALIGN_TYPE 714 #elif defined( variant_CONFIG_ALIGN_AS ) // variant_CONFIG_MAX_ALIGN_HACK 718 #define variant_ALIGN_AS( unused ) \ 719 variant_CONFIG_ALIGN_AS 721 #else // variant_CONFIG_MAX_ALIGN_HACK 725 #define variant_ALIGN_AS( to_align ) \ 726 typename detail::type_of_size< detail::alignment_types, detail::alignment_of< to_align >::value >::type 728 template<
typename T >
731 template<
typename T >
739 template<
size_t A,
size_t S >
742 enum V { value = A < S ? A : S };
745 template<
typename T >
752 template<
typename List,
size_t N >
756 N ==
sizeof(
typename List::head ),
767 template<
typename T>
770 #define variant_ALIGN_TYPE( type ) \ 771 typelist< type , typelist< struct_t< type > 797 > > > > > > > > > > > > > >
798 > > > > > > > > > > > > > >
802 #undef variant_ALIGN_TYPE 804 #endif // variant_CONFIG_MAX_ALIGN_HACK 806 template<
typename T>
807 inline std::size_t
hash( T
const & v )
810 unsigned const int a = 54059;
811 unsigned const int b = 76963;
812 unsigned const int h0 = 37;
815 unsigned char const * s = reinterpret_cast<unsigned char const *>( &v );
817 for ( std::size_t i = 0; i <
sizeof(v); ++i, ++s )
819 h = (h * a) ^ (*s * b);
828 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
832 typedef variant_TL16(
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15 ) variant_types;
835 static U *
as(
void * data )
837 return reinterpret_cast<U*>( data );
841 static U
const *
as(
void const * data )
843 return reinterpret_cast<const U*>( data );
848 return static_cast<type_index_t>( index );
855 case 0: as<T0>( data )->~T0();
break;
856 case 1: as<T1>( data )->~T1();
break;
857 case 2: as<T2>( data )->~T2();
break;
858 case 3: as<T3>( data )->~T3();
break;
859 case 4: as<T4>( data )->~T4();
break;
860 case 5: as<T5>( data )->~T5();
break;
861 case 6: as<T6>( data )->~T6();
break;
862 case 7: as<T7>( data )->~T7();
break;
863 case 8: as<T8>( data )->~T8();
break;
864 case 9: as<T9>( data )->~T9();
break;
865 case 10: as<T10>( data )->~T10();
break;
866 case 11: as<T11>( data )->~T11();
break;
867 case 12: as<T12>( data )->~T12();
break;
868 case 13: as<T13>( data )->~T13();
break;
869 case 14: as<T14>( data )->~T14();
break;
870 case 15: as<T15>( data )->~T15();
break;
875 #if variant_CPP11_OR_GREATER 876 template<
class T,
class... Args >
877 static type_index_t construct_t(
void * data, Args&&... args )
879 new( data ) T( std::forward<Args>(args)... );
884 template< std::size_t K,
class... Args >
885 static type_index_t construct_i(
void * data, Args&&... args )
889 construct_t< type >( data, std::forward<Args>(args)... );
896 switch ( from_index )
898 case 0:
new( to_value )
T0( std::forward<T0>( *as<T0>( from_value ) ) );
break;
899 case 1:
new( to_value )
T1( std::forward<T1>( *as<T1>( from_value ) ) );
break;
900 case 2:
new( to_value )
T2( std::forward<T2>( *as<T2>( from_value ) ) );
break;
901 case 3:
new( to_value )
T3( std::forward<T3>( *as<T3>( from_value ) ) );
break;
902 case 4:
new( to_value )
T4( std::forward<T4>( *as<T4>( from_value ) ) );
break;
903 case 5:
new( to_value )
T5( std::forward<T5>( *as<T5>( from_value ) ) );
break;
904 case 6:
new( to_value )
T6( std::forward<T6>( *as<T6>( from_value ) ) );
break;
905 case 7:
new( to_value )
T7( std::forward<T7>( *as<T7>( from_value ) ) );
break;
906 case 8:
new( to_value )
T8( std::forward<T8>( *as<T8>( from_value ) ) );
break;
907 case 9:
new( to_value )
T9( std::forward<T9>( *as<T9>( from_value ) ) );
break;
908 case 10:
new( to_value )
T10( std::forward<T10>( *as<T10>( from_value ) ) );
break;
909 case 11:
new( to_value )
T11( std::forward<T11>( *as<T11>( from_value ) ) );
break;
910 case 12:
new( to_value )
T12( std::forward<T12>( *as<T12>( from_value ) ) );
break;
911 case 13:
new( to_value )
T13( std::forward<T13>( *as<T13>( from_value ) ) );
break;
912 case 14:
new( to_value )
T14( std::forward<T14>( *as<T14>( from_value ) ) );
break;
913 case 15:
new( to_value )
T15( std::forward<T15>( *as<T15>( from_value ) ) );
break;
922 switch ( from_index )
924 case 0:
new( to_value )
T0( *as<T0>( from_value ) );
break;
925 case 1:
new( to_value )
T1( *as<T1>( from_value ) );
break;
926 case 2:
new( to_value )
T2( *as<T2>( from_value ) );
break;
927 case 3:
new( to_value )
T3( *as<T3>( from_value ) );
break;
928 case 4:
new( to_value )
T4( *as<T4>( from_value ) );
break;
929 case 5:
new( to_value )
T5( *as<T5>( from_value ) );
break;
930 case 6:
new( to_value )
T6( *as<T6>( from_value ) );
break;
931 case 7:
new( to_value )
T7( *as<T7>( from_value ) );
break;
932 case 8:
new( to_value )
T8( *as<T8>( from_value ) );
break;
933 case 9:
new( to_value )
T9( *as<T9>( from_value ) );
break;
934 case 10:
new( to_value )
T10( *as<T10>( from_value ) );
break;
935 case 11:
new( to_value )
T11( *as<T11>( from_value ) );
break;
936 case 12:
new( to_value )
T12( *as<T12>( from_value ) );
break;
937 case 13:
new( to_value )
T13( *as<T13>( from_value ) );
break;
938 case 14:
new( to_value )
T14( *as<T14>( from_value ) );
break;
939 case 15:
new( to_value )
T15( *as<T15>( from_value ) );
break;
952 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
969 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
970 struct variant_size<
variant<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15> >
972 enum _ { value =
detail::typelist_size<
variant_TL16(
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15) >::value };
975 #if variant_CPP14_OR_GREATER 980 #if ! variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO 981 # define variant_size_V(T) nonstd::variant_size<T>::value 986 template< std::
size_t K,
class T >
989 template< std::
size_t K,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
990 struct variant_alternative< K,
variant<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15> >
992 typedef typename detail::typelist_type_at<
variant_TL16(
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15), K>
::type type;
995 #if variant_CPP11_OR_GREATER 996 template< std::
size_t K,
class T >
1000 #if ! variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO 1001 # define variant_alternative_T(K,T) typename nonstd::variant_alternative<K,T >::type 1009 #if variant_CPP11_OR_GREATER 1018 #if variant_CPP11_OR_GREATER 1021 virtual const char*
what()
const throw()
1024 return "bad variant access";
1048 typedef detail::helper< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > helper_type;
1049 typedef variant_TL16(
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15 ) variant_types;
1072 #if variant_CPP11_OR_GREATER 1073 variant(
T0 && t0 ) : type_index( 0 ) {
new( ptr() )
T0( std::move(t0) ); }
1074 variant(
T1 && t1 ) : type_index( 1 ) {
new( ptr() )
T1( std::move(t1) ); }
1075 variant(
T2 && t2 ) : type_index( 2 ) {
new( ptr() )
T2( std::move(t2) ); }
1076 variant(
T3 && t3 ) : type_index( 3 ) {
new( ptr() )
T3( std::move(t3) ); }
1077 variant(
T4 && t4 ) : type_index( 4 ) {
new( ptr() )
T4( std::move(t4) ); }
1078 variant(
T5 && t5 ) : type_index( 5 ) {
new( ptr() )
T5( std::move(t5) ); }
1079 variant(
T6 && t6 ) : type_index( 6 ) {
new( ptr() )
T6( std::move(t6) ); }
1080 variant(
T7 && t7 ) : type_index( 7 ) {
new( ptr() )
T7( std::move(t7) ); }
1081 variant(
T8 && t8 ) : type_index( 8 ) {
new( ptr() )
T8( std::move(t8) ); }
1082 variant(
T9 && t9 ) : type_index( 9 ) {
new( ptr() )
T9( std::move(t9) ); }
1083 variant(
T10 && t10 ) : type_index( 10 ) {
new( ptr() )
T10( std::move(t10) ); }
1084 variant(
T11 && t11 ) : type_index( 11 ) {
new( ptr() )
T11( std::move(t11) ); }
1085 variant(
T12 && t12 ) : type_index( 12 ) {
new( ptr() )
T12( std::move(t12) ); }
1086 variant(
T13 && t13 ) : type_index( 13 ) {
new( ptr() )
T13( std::move(t13) ); }
1087 variant(
T14 && t14 ) : type_index( 14 ) {
new( ptr() )
T14( std::move(t14) ); }
1088 variant(
T15 && t15 ) : type_index( 15 ) {
new( ptr() )
T15( std::move(t15) ); }
1093 : type_index( other.type_index )
1098 #if variant_CPP11_OR_GREATER 1101 std::is_nothrow_move_constructible<T0>::value &&
1102 std::is_nothrow_move_constructible<T1>::value &&
1103 std::is_nothrow_move_constructible<T2>::value &&
1104 std::is_nothrow_move_constructible<T3>::value &&
1105 std::is_nothrow_move_constructible<T4>::value &&
1106 std::is_nothrow_move_constructible<T5>::value &&
1107 std::is_nothrow_move_constructible<T6>::value &&
1108 std::is_nothrow_move_constructible<T7>::value &&
1109 std::is_nothrow_move_constructible<T8>::value &&
1110 std::is_nothrow_move_constructible<T9>::value &&
1111 std::is_nothrow_move_constructible<T10>::value &&
1112 std::is_nothrow_move_constructible<T11>::value &&
1113 std::is_nothrow_move_constructible<T12>::value &&
1114 std::is_nothrow_move_constructible<T13>::value &&
1115 std::is_nothrow_move_constructible<T14>::value &&
1116 std::is_nothrow_move_constructible<T15>::value)
1117 : type_index( other.type_index )
1119 (void) helper_type::move( other.type_index, other.ptr(), ptr() );
1122 template< std::
size_t K >
1123 using type_at_t =
typename detail::typelist_type_at< variant_types, K >::type;
1125 template<
class T,
class... Args
1126 variant_REQUIRES_T( std::is_constructible< T, Args...>::value )
1130 type_index = variant_npos_internal();
1131 type_index = helper_type::template construct_t<T>( ptr(), std::forward<Args>(args)... );
1134 template<
class T,
class U,
class... Args
1135 variant_REQUIRES_T( std::is_constructible< T, std::initializer_list<U>&, Args...>::value )
1139 type_index = variant_npos_internal();
1140 type_index = helper_type::template construct_t<T>( ptr(), il, std::forward<Args>(args)... );
1143 template< std::size_t K,
class... Args
1144 variant_REQUIRES_T( std::is_constructible< type_at_t<K>, Args...>::value )
1148 type_index = variant_npos_internal();
1149 type_index = helper_type::template construct_i<K>( ptr(), std::forward<Args>(args)... );
1152 template<
size_t K,
class U,
class... Args
1153 variant_REQUIRES_T( std::is_constructible< type_at_t<K>, std::initializer_list<U>&, Args...>::value )
1157 type_index = variant_npos_internal();
1158 type_index = helper_type::template construct_i<K>( ptr(), il, std::forward<Args>(args)... );
1161 #endif // variant_CPP11_OR_GREATER 1170 return copy_assign( other );
1173 #if variant_CPP11_OR_GREATER 1176 std::is_nothrow_move_assignable<T0>::value &&
1177 std::is_nothrow_move_assignable<T1>::value &&
1178 std::is_nothrow_move_assignable<T2>::value &&
1179 std::is_nothrow_move_assignable<T3>::value &&
1180 std::is_nothrow_move_assignable<T4>::value &&
1181 std::is_nothrow_move_assignable<T5>::value &&
1182 std::is_nothrow_move_assignable<T6>::value &&
1183 std::is_nothrow_move_assignable<T7>::value &&
1184 std::is_nothrow_move_assignable<T8>::value &&
1185 std::is_nothrow_move_assignable<T9>::value &&
1186 std::is_nothrow_move_assignable<T10>::value &&
1187 std::is_nothrow_move_assignable<T11>::value &&
1188 std::is_nothrow_move_assignable<T12>::value &&
1189 std::is_nothrow_move_assignable<T13>::value &&
1190 std::is_nothrow_move_assignable<T14>::value &&
1191 std::is_nothrow_move_assignable<T15>::value)
1193 return move_assign( std::forward<variant>( other ) );
1196 variant &
operator=(
T0 && t0 ) {
return move_assign_value<T0,0>( std::forward<T0>( t0 ) ); }
1197 variant &
operator=(
T1 && t1 ) {
return move_assign_value<T1,1>( std::forward<T1>( t1 ) ); }
1198 variant &
operator=(
T2 && t2 ) {
return move_assign_value<T2,2>( std::forward<T2>( t2 ) ); }
1199 variant &
operator=(
T3 && t3 ) {
return move_assign_value<T3,3>( std::forward<T3>( t3 ) ); }
1200 variant &
operator=(
T4 && t4 ) {
return move_assign_value<T4,4>( std::forward<T4>( t4 ) ); }
1201 variant &
operator=(
T5 && t5 ) {
return move_assign_value<T5,5>( std::forward<T5>( t5 ) ); }
1202 variant &
operator=(
T6 && t6 ) {
return move_assign_value<T6,6>( std::forward<T6>( t6 ) ); }
1203 variant &
operator=(
T7 && t7 ) {
return move_assign_value<T7,7>( std::forward<T7>( t7 ) ); }
1204 variant &
operator=(
T8 && t8 ) {
return move_assign_value<T8,8>( std::forward<T8>( t8 ) ); }
1205 variant &
operator=(
T9 && t9 ) {
return move_assign_value<T9,9>( std::forward<T9>( t9 ) ); }
1206 variant &
operator=(
T10 && t10 ) {
return move_assign_value<T10,10>( std::forward<T10>( t10 ) ); }
1207 variant &
operator=(
T11 && t11 ) {
return move_assign_value<T11,11>( std::forward<T11>( t11 ) ); }
1208 variant &
operator=(
T12 && t12 ) {
return move_assign_value<T12,12>( std::forward<T12>( t12 ) ); }
1209 variant &
operator=(
T13 && t13 ) {
return move_assign_value<T13,13>( std::forward<T13>( t13 ) ); }
1210 variant &
operator=(
T14 && t14 ) {
return move_assign_value<T14,14>( std::forward<T14>( t14 ) ); }
1211 variant &
operator=(
T15 && t15 ) {
return move_assign_value<T15,15>( std::forward<T15>( t15 ) ); }
1235 return variant_npos_internal() == type_index ?
variant_npos : static_cast<std::size_t>( type_index );
1240 return type_index == variant_npos_internal();
1243 #if variant_CPP11_OR_GREATER 1244 template<
class T,
class... Args
1245 variant_REQUIRES_T( std::is_constructible< T, Args...>::value )
1247 T& emplace( Args&&... args )
1250 type_index = variant_npos_internal();
1251 type_index = helper_type::template construct_t<T>( ptr(), std::forward<Args>(args)... );
1256 template<
class T,
class U,
class... Args
1257 variant_REQUIRES_T( std::is_constructible< T, std::initializer_list<U>&, Args...>::value )
1259 T& emplace( std::initializer_list<U> il, Args&&... args )
1262 type_index = variant_npos_internal();
1263 type_index = helper_type::template construct_t<T>( ptr(), il, std::forward<Args>(args)... );
1268 template<
size_t K,
class... Args
1269 variant_REQUIRES_T( std::is_constructible< type_at_t<K>, Args...>::value )
1271 variant_alternative_t<K, variant> & emplace( Args&&... args )
1273 return this->
template emplace< type_at_t<K> >( std::forward<Args>(args)... );
1276 template<
size_t K,
class U,
class... Args
1277 variant_REQUIRES_T( std::is_constructible< type_at_t<K>, std::initializer_list<U>&, Args...>::value )
1279 variant_alternative_t<K, variant> & emplace( std::initializer_list<U> il, Args&&... args )
1281 return this->
template emplace< type_at_t<K> >( il, std::forward<Args>(args)... );
1284 #endif // variant_CPP11_OR_GREATER 1292 else if ( type_index == other.type_index )
1294 this->swap_value( type_index, other );
1317 const std::size_t i = index_of<T>();
1319 if ( i !=
index() || i == max_index() )
1330 const std::size_t i = index_of<T>();
1332 if ( i !=
index() || i == max_index() )
1337 return *as<const T>();
1340 template< std::
size_t K >
1344 return this->
template get< typename detail::typelist_type_at< variant_types, K >::type >();
1347 template< std::
size_t K >
1351 return this->
template get< typename detail::typelist_type_at< variant_types, K >::type >();
1370 return reinterpret_cast<U*>( ptr() );
1374 U
const * as()
const 1376 return reinterpret_cast<U const *>( ptr() );
1380 static std::size_t to_size_t( U
index )
1382 return static_cast<std::size_t >(
index );
1392 return static_cast<type_index_t>( -1 );
1404 type_index = variant_npos_internal();
1406 else if (
index() == other.index() )
1416 type_index = variant_npos_internal();
1417 #if variant_CPP11_OR_GREATER 1418 type_index = helper_type::move( other.type_index, tmp.ptr(), ptr() );
1426 #if variant_CPP11_OR_GREATER 1437 type_index = variant_npos_internal();
1439 else if (
index() == other.index() )
1441 type_index = helper_type::move( other.type_index, other.ptr(), ptr() );
1446 type_index = variant_npos_internal();
1447 type_index = helper_type::move( other.type_index, other.ptr(), ptr() );
1452 template<
class T, std::
size_t K >
1453 variant & move_assign_value( T && value )
1457 *as<T>() = std::forward<T>( value );
1462 type_index = variant_npos_internal();
1463 new( ptr() ) T( std::forward<T>( value ) );
1469 template<
class T, std::
size_t K >
1470 variant & copy_assign_value( T
const & value )
1479 type_index = variant_npos_internal();
1480 new( ptr() ) T( value );
1486 #endif // variant_CPP11_OR_GREATER 1493 case 0:
swap( this->get<0>(), other.get<0>() );
break;
1494 case 1:
swap( this->get<1>(), other.get<1>() );
break;
1495 case 2:
swap( this->get<2>(), other.get<2>() );
break;
1496 case 3:
swap( this->get<3>(), other.get<3>() );
break;
1497 case 4:
swap( this->get<4>(), other.get<4>() );
break;
1498 case 5:
swap( this->get<5>(), other.get<5>() );
break;
1499 case 6:
swap( this->get<6>(), other.get<6>() );
break;
1500 case 7:
swap( this->get<7>(), other.get<7>() );
break;
1501 case 8:
swap( this->get<8>(), other.get<8>() );
break;
1502 case 9:
swap( this->get<9>(), other.get<9>() );
break;
1503 case 10:
swap( this->get<10>(), other.get<10>() );
break;
1504 case 11:
swap( this->get<11>(), other.get<11>() );
break;
1505 case 12:
swap( this->get<12>(), other.get<12>() );
break;
1506 case 13:
swap( this->get<13>(), other.get<13>() );
break;
1507 case 14:
swap( this->get<14>(), other.get<14>() );
break;
1508 case 15:
swap( this->get<15>(), other.get<15>() );
break;
1514 enum { data_size = detail::typelist_max< variant_types >::value };
1516 #if variant_CPP11_OR_GREATER 1518 enum { data_align = detail::typelist_max_alignof< variant_types >::value };
1520 using aligned_storage_t =
typename std::aligned_storage< data_size, data_align >::type;
1521 aligned_storage_t data;
1523 #elif variant_CONFIG_MAX_ALIGN_HACK 1525 typedef union {
unsigned char data[ data_size ]; } aligned_storage_t;
1527 detail::max_align_t hack;
1528 aligned_storage_t data;
1531 typedef typename detail::typelist_max< variant_types >::type max_type;
1533 typedef variant_ALIGN_AS( max_type ) align_as_type;
1535 typedef union { align_as_type data[ 1 + ( data_size - 1 ) /
sizeof(align_as_type) ]; } aligned_storage_t;
1536 aligned_storage_t data;
1540 #endif // variant_CONFIG_MAX_ALIGN_HACK 1542 type_index_t type_index;
1545 template<
class T,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1546 inline bool holds_alternative(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & v )
variant_noexcept 1548 return v.index() == v.template index_of<T>();
1551 template<
class R,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1552 inline R &
get(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> & v,
nonstd_lite_in_place_type_t(R) =
nonstd_lite_in_place_type(R) )
1554 return v.template get<R>();
1557 template<
class R,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1558 inline R
const &
get(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & v,
nonstd_lite_in_place_type_t(R) =
nonstd_lite_in_place_type(R) )
1560 return v.template get<R>();
1563 template< std::
size_t K,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1564 inline typename variant_alternative< K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> >::type &
1565 get(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> & v,
nonstd_lite_in_place_index_t(K) =
nonstd_lite_in_place_index(K) )
1567 if ( K != v.
index() )
1572 return v.template get<K>();
1575 template< std::
size_t K,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1576 inline typename variant_alternative< K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> >::type
const &
1577 get(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & v,
nonstd_lite_in_place_index_t(K) =
nonstd_lite_in_place_index(K) )
1579 if ( K != v.
index() )
1584 return v.template get<K>();
1587 #if variant_CPP11_OR_GREATER 1589 template<
class R,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1590 inline R &&
get(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> && v,
nonstd_lite_in_place_type_t(R) =
nonstd_lite_in_place_type(R) )
1592 return std::move(v.template get<R>());
1595 template<
class R,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1596 inline R
const &&
get( variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const && v,
nonstd_lite_in_place_type_t(R) =
nonstd_lite_in_place_type(R) )
1598 return std::move(v.template get<R>());
1601 template< std::
size_t K,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1602 inline typename variant_alternative< K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> >::type &&
1603 get( variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> && v,
nonstd_lite_in_place_index_t(K) =
nonstd_lite_in_place_index(K) )
1605 if ( K != v.
index() )
1607 throw bad_variant_access();
1610 return std::move(v.template get<K>());
1613 template< std::
size_t K,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1614 inline typename variant_alternative< K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> >::type
const &&
1615 get( variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const && v,
nonstd_lite_in_place_index_t(K) =
nonstd_lite_in_place_index(K) )
1617 if ( K != v.
index() )
1619 throw bad_variant_access();
1622 return std::move(v.template get<K>());
1625 #endif // variant_CPP11_OR_GREATER 1627 template<
class T,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1629 get_if(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> * pv,
nonstd_lite_in_place_type_t(T) =
nonstd_lite_in_place_type(T) )
1634 template<
class T,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1636 get_if(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const * pv,
nonstd_lite_in_place_type_t(T) =
nonstd_lite_in_place_type(T))
1641 template< std::
size_t K,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1642 inline typename detail::add_pointer< typename variant_alternative<K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> >::type >::type
1643 get_if(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> * pv,
nonstd_lite_in_place_index_t(K) =
nonstd_lite_in_place_index(K) )
1648 template< std::
size_t K,
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1649 inline typename detail::add_pointer< const typename variant_alternative<K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> >::type >::type
1650 get_if(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const * pv,
nonstd_lite_in_place_index_t(K) =
nonstd_lite_in_place_index(K) )
1655 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
1657 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> & a,
1658 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> & b )
variant_noexcept 1668 template<
typename R,
typename VT >
1671 template<
typename Visitor,
typename T >
1672 static R
apply(Visitor
const& v, T
const& arg)
1678 template<
typename R,
typename VT >
1681 template<
typename Visitor,
typename T >
1688 template<
typename R>
1691 template<
typename R,
typename Visitor,
typename V1 >
1694 #if variant_CPP11_OR_GREATER 1695 template<
size_t NumVars,
typename R,
typename Visitor,
typename ... T >
1697 template<
size_t NumVars,
typename R,
typename Visitor,
typename T1,
typename T2 = S0,
typename T3 = S0,
typename T4 = S0,
typename T5 = S0 >
1701 template<
typename R,
typename Visitor,
typename T2 >
1714 template<
typename T>
1717 return visitor(val1, val2);
1721 template<
typename R,
typename Visitor,
typename T2,
typename T3 >
1736 template<
typename T>
1739 return visitor(val1, val2, val3);
1743 template<
typename R,
typename Visitor,
typename T2,
typename T3,
typename T4 >
1760 template<
typename T>
1763 return visitor(val1, val2, val3, val4);
1767 template<
typename R,
typename Visitor,
typename T2,
typename T3,
typename T4,
typename T5 >
1786 template<
typename T>
1789 return visitor(val1, val2, val3, val4, val5);
1795 template<
typename R,
typename Visitor,
typename V2>
1796 struct VisitorUnwrapper
1808 template<
typename T1 >
1815 template<
typename T1,
typename T2 >
1822 template<
typename T1,
typename T2,
typename T3 >
1829 template<
typename T1,
typename T2,
typename T3,
typename T4 >
1836 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5 >
1846 template<
typename R>
1847 struct VisitorApplicator
1849 template<
typename Visitor,
typename V1>
1850 static R
apply(
const Visitor& v,
const V1& arg)
1852 switch( arg.index() )
1854 case 0:
return apply_visitor<0>(v, arg);
1855 case 1:
return apply_visitor<1>(v, arg);
1856 case 2:
return apply_visitor<2>(v, arg);
1857 case 3:
return apply_visitor<3>(v, arg);
1858 case 4:
return apply_visitor<4>(v, arg);
1859 case 5:
return apply_visitor<5>(v, arg);
1860 case 6:
return apply_visitor<6>(v, arg);
1861 case 7:
return apply_visitor<7>(v, arg);
1862 case 8:
return apply_visitor<8>(v, arg);
1863 case 9:
return apply_visitor<9>(v, arg);
1864 case 10:
return apply_visitor<10>(v, arg);
1865 case 11:
return apply_visitor<11>(v, arg);
1866 case 12:
return apply_visitor<12>(v, arg);
1867 case 13:
return apply_visitor<13>(v, arg);
1868 case 14:
return apply_visitor<14>(v, arg);
1869 case 15:
return apply_visitor<15>(v, arg);
1871 default:
return R();
1875 template<
size_t Idx,
typename Visitor,
typename V1>
1879 #if variant_CPP11_OR_GREATER 1887 #if variant_CPP11_OR_GREATER 1888 template<
typename Visitor,
typename V1,
typename V2,
typename ... V>
1889 static R
apply(
const Visitor& v,
const V1& arg1,
const V2& arg2,
const V ... args)
1892 Unwrapper unwrapper(v, arg1);
1893 return apply(unwrapper, arg2, args ...);
1897 template<
typename Visitor,
typename V1,
typename V2 >
1898 static R
apply(
const Visitor& v, V1
const& arg1, V2
const& arg2)
1901 Unwrapper unwrapper(v, arg1);
1902 return apply(unwrapper, arg2);
1905 template<
typename Visitor,
typename V1,
typename V2,
typename V3 >
1906 static R
apply(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3)
1909 Unwrapper unwrapper(v, arg1);
1910 return apply(unwrapper, arg2, arg3);
1913 template<
typename Visitor,
typename V1,
typename V2,
typename V3,
typename V4 >
1914 static R
apply(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3, V4
const& arg4)
1917 Unwrapper unwrapper(v, arg1);
1918 return apply(unwrapper, arg2, arg3, arg4);
1921 template<
typename Visitor,
typename V1,
typename V2,
typename V3,
typename V4,
typename V5 >
1922 static R
apply(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3, V4
const& arg4, V5
const& arg5)
1925 Unwrapper unwrapper(v, arg1);
1926 return apply(unwrapper, arg2, arg3, arg4, arg5);
1932 #if variant_CPP11_OR_GREATER 1933 template<
size_t NumVars,
typename Visitor,
typename ... V >
1936 typedef decltype(std::declval<Visitor>()(get<0>(static_cast<const V&>(std::declval<V>()))...)) result_type;
1937 typedef VisitorApplicator<result_type> applicator_type;
1942 #if variant_CPP11_OR_GREATER 1944 template<
typename Visitor,
typename ... V >
1945 inline auto visit(Visitor
const& v, V
const& ... vars) ->
typename detail::VisitorImpl<
sizeof ... (V), Visitor, V... > ::result_type
1947 typedef detail::VisitorImpl<sizeof ... (V), Visitor, V... > impl_type;
1948 return impl_type::applicator_type::apply(v, vars...);
1952 template<
typename R,
typename Visitor,
typename V1 >
1953 inline R
visit(
const Visitor& v, V1
const& arg1)
1958 template<
typename R,
typename Visitor,
typename V1,
typename V2 >
1959 inline R
visit(
const Visitor& v, V1
const& arg1, V2
const& arg2)
1964 template<
typename R,
typename Visitor,
typename V1,
typename V2,
typename V3 >
1965 inline R
visit(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3)
1970 template<
typename R,
typename Visitor,
typename V1,
typename V2,
typename V3,
typename V4 >
1971 inline R
visit(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3, V4
const& arg4)
1976 template<
typename R,
typename Visitor,
typename V1,
typename V2,
typename V3,
typename V4,
typename V5 >
1977 inline R
visit(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3, V4
const& arg4, V5
const& arg5)
1987 template<
class Variant >
1990 static inline bool equal( Variant
const & v, Variant
const & w )
1994 case 0:
return get<0>( v ) == get<0>( w );
1995 case 1:
return get<1>( v ) == get<1>( w );
1996 case 2:
return get<2>( v ) == get<2>( w );
1997 case 3:
return get<3>( v ) == get<3>( w );
1998 case 4:
return get<4>( v ) == get<4>( w );
1999 case 5:
return get<5>( v ) == get<5>( w );
2000 case 6:
return get<6>( v ) == get<6>( w );
2001 case 7:
return get<7>( v ) == get<7>( w );
2002 case 8:
return get<8>( v ) == get<8>( w );
2003 case 9:
return get<9>( v ) == get<9>( w );
2004 case 10:
return get<10>( v ) == get<10>( w );
2005 case 11:
return get<11>( v ) == get<11>( w );
2006 case 12:
return get<12>( v ) == get<12>( w );
2007 case 13:
return get<13>( v ) == get<13>( w );
2008 case 14:
return get<14>( v ) == get<14>( w );
2009 case 15:
return get<15>( v ) == get<15>( w );
2011 default:
return false;
2015 static inline bool less_than( Variant
const & v, Variant
const & w )
2019 case 0:
return get<0>( v ) < get<0>( w );
2020 case 1:
return get<1>( v ) < get<1>( w );
2021 case 2:
return get<2>( v ) < get<2>( w );
2022 case 3:
return get<3>( v ) < get<3>( w );
2023 case 4:
return get<4>( v ) < get<4>( w );
2024 case 5:
return get<5>( v ) < get<5>( w );
2025 case 6:
return get<6>( v ) < get<6>( w );
2026 case 7:
return get<7>( v ) < get<7>( w );
2027 case 8:
return get<8>( v ) < get<8>( w );
2028 case 9:
return get<9>( v ) < get<9>( w );
2029 case 10:
return get<10>( v ) < get<10>( w );
2030 case 11:
return get<11>( v ) < get<11>( w );
2031 case 12:
return get<12>( v ) < get<12>( w );
2032 case 13:
return get<13>( v ) < get<13>( w );
2033 case 14:
return get<14>( v ) < get<14>( w );
2034 case 15:
return get<15>( v ) < get<15>( w );
2036 default:
return false;
2043 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
2045 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & v,
2046 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & w )
2050 else return detail::Comparator< variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> >::equal( v, w );
2053 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
2055 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & v,
2056 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & w )
2058 return ! ( v == w );
2061 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
2063 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & v,
2064 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & w )
2068 else if ( v.
index() < w.
index() )
return true;
2069 else if ( v.
index() > w.
index() )
return false;
2070 else return detail::Comparator< variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> >::less_than( v, w );
2073 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
2075 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & v,
2076 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & w )
2081 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
2083 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & v,
2084 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & w )
2089 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
2091 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & v,
2092 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & w )
2099 using namespace variants;
2103 #if variant_CPP11_OR_GREATER 2118 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
class T6,
class T7,
class T8,
class T9,
class T10,
class T11,
class T12,
class T13,
class T14,
class T15 >
2119 struct hash<
nonstd::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> >
2121 std::size_t operator()(
nonstd::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const & v )
const variant_noexcept 2129 #endif // variant_CPP11_OR_GREATER 2131 #if variant_BETWEEN( variant_COMPILER_MSVC_VER, 1300, 1900 ) 2132 # pragma warning( pop ) 2135 #endif // variant_USES_STD_VARIANT 2137 #endif // NONSTD_VARIANT_LITE_HPP
TX< T > operator-() const
TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_)
bool operator<(T const &) const
variant & operator=(T2 const &t2)
static R apply(Visitor const &v, T const &arg)
std::size_t index() const
conditional<(sizeof(Head) > tail_value), Head, tail_type >::type type
static R apply(Visitor const &, T)
static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4, V5 const &arg5)
static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3)
static bool equal(Variant const &v, Variant const &w)
static R apply_visitor(const Visitor &v, const V1 &arg)
variant(variant const &other)
variant_constexpr bool operator>=(monostate, monostate) variant_noexcept
TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_, T3 const &val3_)
R operator()(T1 const &val1, T2 const &val2, T3 const &val3) const
nonstd::variants::variant_alternative< K, variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > >::type detail::typelist_type_at< variant_TL16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15), K >::type type
VisitorUnwrapper(const Visitor &visitor_, const V2 &r_)
static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2)
typedef variant_ALIGN_TYPE(char)
R & get(variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > &v, nonstd_lite_in_place_type_t(R)=nonstd_lite_in_place_type(R))
#define variant_TL16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)
TX< T > operator &&(U const &) const
bool valueless_by_exception() const
variant & operator=(variant const &other)
conditional< N==sizeof(typename List::head), typename List::head, typename type_of_size< typename List::tail, N >::type >::type type
#define nonstd_lite_in_place_index(K)
variant_constexpr bool operator<(monostate, monostate) variant_noexcept
variant & operator=(T7 const &t7)
static const std::size_t variant_npos
R operator()(T1 const &val1, T2 const &val2, T3 const &val3, T4 const &val4, T5 const &val5) const
TX< T > operator *(U const &) const
R operator()(const T &val1) const
static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4)
in_place_t in_place_index(detail::in_place_index_tag< K >=detail::in_place_index_tag< K >())
variant_constexpr std::size_t index_of() const variant_noexcept
TX< T > operator||(U const &) const
std::size_t hash(T const &v)
TX< T > operator/(U const &) const
variant_constexpr bool operator>(monostate, monostate) variant_noexcept
#define nonstd_lite_in_place_type(T)
nonstd::variants::variant_size< variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > >::_ _
R operator()(T1 const &val1, T2 const &val2) const
void swap(variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > &a, variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > &b) variant_noexcept
#define variant_constexpr
void swap(variant &other) variant_noexcept
#define variant_CONFIG_ALIGN_AS_FALLBACK
variant & operator=(T11 const &t11)
TX< T > operator<<(U const &) const
TX< T > operator+() const
variant & operator=(T3 const &t3)
TX< T > operator>>(U const &) const
variant & operator=(T9 const &t9)
static U const * as(void const *data)
variant & operator=(T6 const &t6)
variant_constexpr bool operator<=(monostate, monostate) variant_noexcept
#define nonstd_lite_in_place_index_t(K)
TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_, T3 const &val3_, T4 const &val4_, T5 const &val5_)
variant_constexpr bool operator==(monostate, monostate) variant_noexcept
detail::add_pointer< const typename variant_alternative< K, variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > >::type >::type get_if(variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > const *pv, nonstd_lite_in_place_index_t(K)=nonstd_lite_in_place_index(K))
variant_CONFIG_ALIGN_AS_FALLBACK type
TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_, T3 const &val3_, T4 const &val4_)
detail::add_pointer< T >::type get_if(variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > *pv, nonstd_lite_in_place_type_t(T)=nonstd_lite_in_place_type(T))
variant & operator=(T8 const &t8)
variant_alternative< K, variant >::type & get()
TX< T > operator!() const
variant & operator=(T0 const &t0)
static void destroy(type_index_t index, void *data)
static type_index_t to_index_t(std::size_t index)
static U * as(void *data)
remove_reference< T >::type * type
TX< T > operator|(U const &) const
variant & operator=(T5 const &t5)
static type_index_t copy(type_index_t const from_index, const void *from_value, void *to_value)
in_place_t in_place_type(detail::in_place_type_tag< T >=detail::in_place_type_tag< T >())
variant_constexpr bool operator!=(monostate, monostate) variant_noexcept
bool holds_alternative(variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > const &v) variant_noexcept
R operator()(T1 const &val1) const
R operator()(T1 const &val1, T2 const &val2, T3 const &val3, T4 const &val4) const
R operator()(const T &val1) const
TX< T > operator^(U const &) const
virtual const char * what() const
variant & operator=(T14 const &t14)
R operator()(const T &val1) const
variant & operator=(T13 const &t13)
TX< T > * operator &() const
variant & operator=(T1 const &t1)
variant & operator=(T12 const &t12)
R operator()(const T &val1) const
TX< T > operator~() const
typelist_type_at< Tail, i - 1 >::type type
variant_alternative< K, variant >::type const & get() const
remove_volatile< typename remove_const< T >::type >::type type
variant_alternative< K, variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > >::type const & get(variant< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 > const &v, nonstd_lite_in_place_index_t(K)=nonstd_lite_in_place_index(K))
static R apply(const Visitor &v, const V1 &arg)
variant & operator=(T15 const &t15)
TX< T > operator%(U const &) const
bool operator==(T const &) const
R visit(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4, V5 const &arg5)
variant & operator=(T4 const &t4)
in_place_t in_place(detail::in_place_type_tag< T >=detail::in_place_type_tag< T >())
static bool less_than(Variant const &v, Variant const &w)
typedef variant_TL16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) variant_types
#define nonstd_lite_in_place_type_t(T)
variant & operator=(T10 const &t10)
R visit(const Visitor &v, V1 const &arg1)