10 #ifndef NONSTD_VARIANT_LITE_HPP
11 #define NONSTD_VARIANT_LITE_HPP
13 #define variant_lite_MAJOR 2
14 #define variant_lite_MINOR 0
15 #define variant_lite_PATCH 0
17 #define variant_lite_VERSION \
18 variant_STRINGIFY(variant_lite_MAJOR) "." variant_STRINGIFY(variant_lite_MINOR) "." variant_STRINGIFY(variant_lite_PATCH)
20 #define variant_STRINGIFY(x) variant_STRINGIFY_(x)
21 #define variant_STRINGIFY_(x) #x
25 #define variant_VARIANT_DEFAULT 0
26 #define variant_VARIANT_NONSTD 1
27 #define variant_VARIANT_STD 2
32 #if __has_include(<nonstd/variant.tweak.hpp>)
33 #include <nonstd/variant.tweak.hpp>
35 #define variant_HAVE_TWEAK_HEADER 1
37 #define variant_HAVE_TWEAK_HEADER 0
43 #ifndef variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO
44 #define variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO 0
47 #ifndef variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO
48 #define variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO 0
53 #ifndef variant_CONFIG_NO_EXCEPTIONS
57 #if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (_HAS_EXCEPTIONS)
58 #define variant_CONFIG_NO_EXCEPTIONS 0
60 #define variant_CONFIG_NO_EXCEPTIONS 1
67 #ifndef variant_CPLUSPLUS
68 #if defined(_MSVC_LANG) && !defined(__clang__)
69 #define variant_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG)
71 #define variant_CPLUSPLUS __cplusplus
75 #define variant_CPP98_OR_GREATER (variant_CPLUSPLUS >= 199711L)
76 #define variant_CPP11_OR_GREATER (variant_CPLUSPLUS >= 201103L)
77 #define variant_CPP11_OR_GREATER_ (variant_CPLUSPLUS >= 201103L)
78 #define variant_CPP14_OR_GREATER (variant_CPLUSPLUS >= 201402L)
79 #define variant_CPP17_OR_GREATER (variant_CPLUSPLUS >= 201703L)
80 #define variant_CPP20_OR_GREATER (variant_CPLUSPLUS >= 202002L)
81 #define variant_CPP23_OR_GREATER (variant_CPLUSPLUS >= 202300L)
85 #if variant_CPP17_OR_GREATER && defined(__has_include)
86 #if __has_include(<variant> )
87 #define variant_HAVE_STD_VARIANT 1
89 #define variant_HAVE_STD_VARIANT 0
92 #define variant_HAVE_STD_VARIANT 0
95 #if !defined(variant_CONFIG_SELECT_VARIANT)
96 #define variant_CONFIG_SELECT_VARIANT (variant_HAVE_STD_VARIANT ? variant_VARIANT_STD : variant_VARIANT_NONSTD)
99 #define variant_USES_STD_VARIANT \
100 ((variant_CONFIG_SELECT_VARIANT == variant_VARIANT_STD) || \
101 ((variant_CONFIG_SELECT_VARIANT == variant_VARIANT_DEFAULT) && variant_HAVE_STD_VARIANT))
107 #ifndef nonstd_lite_HAVE_IN_PLACE_TYPES
108 #define nonstd_lite_HAVE_IN_PLACE_TYPES 1
112 #if variant_CPP17_OR_GREATER
119 using std::in_place_index;
120 using std::in_place_index_t;
121 using std::in_place_t;
122 using std::in_place_type;
123 using std::in_place_type_t;
125 #define nonstd_lite_in_place_t(T) std::in_place_t
126 #define nonstd_lite_in_place_type_t(T) std::in_place_type_t<T>
127 #define nonstd_lite_in_place_index_t(K) std::in_place_index_t<K>
129 #define nonstd_lite_in_place(T) \
131 #define nonstd_lite_in_place_type(T) \
132 std::in_place_type_t<T> {}
133 #define nonstd_lite_in_place_index(K) \
134 std::in_place_index_t<K> {}
155 template <std::
size_t K>
inline in_place_t in_place(detail::in_place_index_tag<K> = detail::in_place_index_tag<K>()) {
159 template <
class T>
inline in_place_t in_place_type(detail::in_place_type_tag<T> = detail::in_place_type_tag<T>()) {
return in_place_t(); }
161 template <std::
size_t K>
inline in_place_t in_place_index(detail::in_place_index_tag<K> = detail::in_place_index_tag<K>()) {
167 #define nonstd_lite_in_place_t(T) nonstd::in_place_t (&)(nonstd::detail::in_place_type_tag<T>)
168 #define nonstd_lite_in_place_type_t(T) nonstd::in_place_t (&)(nonstd::detail::in_place_type_tag<T>)
169 #define nonstd_lite_in_place_index_t(K) nonstd::in_place_t (&)(nonstd::detail::in_place_index_tag<K>)
171 #define nonstd_lite_in_place(T) nonstd::in_place_type<T>
172 #define nonstd_lite_in_place_type(T) nonstd::in_place_type<T>
173 #define nonstd_lite_in_place_index(K) nonstd::in_place_index<K>
190 #define variant_index_tag_t(K) void (&)(nonstd::variants::detail::index_tag_t<K>)
191 #define variant_index_tag(K) nonstd::variants::detail::index_tag<K>
201 #if variant_USES_STD_VARIANT
203 #include <functional>
206 #if !variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO
207 #define variant_size_V(T) nonstd::variant_size<T>::value
210 #if !variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO
211 #define variant_alternative_T(K, T) typename nonstd::variant_alternative<K, T>::type
216 using std::bad_variant_access;
218 using std::monostate;
220 using std::variant_alternative;
221 using std::variant_alternative_t;
222 using std::variant_size;
223 using std::variant_size_v;
227 using std::holds_alternative;
229 using std::operator==;
230 using std::operator!=;
231 using std::operator<;
232 using std::operator<=;
233 using std::operator>;
234 using std::operator>=;
237 constexpr
auto variant_npos = std::variant_npos;
247 #if variant_CONFIG_NO_EXCEPTIONS
255 #define variant_CONFIG_MAX_TYPE_COUNT 16
256 #define variant_CONFIG_MAX_VISITOR_ARG_COUNT 5
260 #ifndef variant_CONFIG_MAX_ALIGN_HACK
261 #define variant_CONFIG_MAX_ALIGN_HACK 0
264 #ifndef variant_CONFIG_ALIGN_AS
268 #ifndef variant_CONFIG_ALIGN_AS_FALLBACK
269 #define variant_CONFIG_ALIGN_AS_FALLBACK double
273 #define variant_BETWEEN(v, lo, hi) ((lo) <= (v) && (v) < (hi))
289 #if defined(_MSC_VER) && !defined(__clang__)
290 #define variant_COMPILER_MSVC_VER (_MSC_VER)
291 #define variant_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * (5 + (_MSC_VER < 1900)))
293 #define variant_COMPILER_MSVC_VER 0
294 #define variant_COMPILER_MSVC_VERSION 0
297 #define variant_COMPILER_VERSION(major, minor, patch) (10 * (10 * (major) + (minor)) + (patch))
299 #if defined(__clang__)
300 #define variant_COMPILER_CLANG_VERSION variant_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
302 #define variant_COMPILER_CLANG_VERSION 0
305 #if defined(__GNUC__) && !defined(__clang__)
306 #define variant_COMPILER_GNUC_VERSION variant_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
308 #define variant_COMPILER_GNUC_VERSION 0
311 #if variant_BETWEEN(variant_COMPILER_MSVC_VER, 1300, 1900)
312 #pragma warning(push)
313 #pragma warning(disable : 4345)
318 #define variant_HAVE(feature) (variant_HAVE_##feature)
321 #define variant_HAS_CPP0X _HAS_CPP0X
323 #define variant_HAS_CPP0X 0
328 #if variant_COMPILER_MSVC_VER >= 1900
329 #undef variant_CPP11_OR_GREATER
330 #define variant_CPP11_OR_GREATER 1
333 #define variant_CPP11_90 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1500)
334 #define variant_CPP11_100 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1600)
335 #define variant_CPP11_110 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1700)
336 #define variant_CPP11_120 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1800)
337 #define variant_CPP11_140 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1900)
338 #define variant_CPP11_141 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1910)
340 #define variant_CPP14_000 (variant_CPP14_OR_GREATER)
341 #define variant_CPP17_000 (variant_CPP17_OR_GREATER)
345 #define variant_HAVE_CONSTEXPR_11 variant_CPP11_140
346 #define variant_HAVE_INITIALIZER_LIST variant_CPP11_120
347 #define variant_HAVE_NOEXCEPT variant_CPP11_140
348 #define variant_HAVE_NULLPTR variant_CPP11_100
349 #define variant_HAVE_OVERRIDE variant_CPP11_140
353 #define variant_HAVE_CONSTEXPR_14 variant_CPP14_000
361 #define variant_HAVE_CONDITIONAL variant_CPP11_120
362 #define variant_HAVE_REMOVE_CV variant_CPP11_120
363 #define variant_HAVE_STD_ADD_POINTER variant_CPP11_100
364 #define variant_HAVE_TYPE_TRAITS variant_CPP11_90
365 #define variant_HAVE_ENABLE_IF variant_CPP11_100
366 #define variant_HAVE_IS_SAME variant_CPP11_100
368 #define variant_HAVE_TR1_TYPE_TRAITS (!!variant_COMPILER_GNUC_VERSION)
369 #define variant_HAVE_TR1_ADD_POINTER (!!variant_COMPILER_GNUC_VERSION || variant_CPP11_90)
373 #if variant_HAVE_CONSTEXPR_11
374 #define variant_constexpr constexpr
376 #define variant_constexpr
379 #if variant_HAVE_CONSTEXPR_14
380 #define variant_constexpr14 constexpr
382 #define variant_constexpr14
385 #if variant_HAVE_NOEXCEPT
386 #define variant_noexcept noexcept
388 #define variant_noexcept
391 #if variant_HAVE_NULLPTR
392 #define variant_nullptr nullptr
394 #define variant_nullptr NULL
397 #if variant_HAVE_OVERRIDE
398 #define variant_override override
400 #define variant_override
405 #if variant_CPP11_OR_GREATER
406 #include <functional>
409 #if variant_HAVE_INITIALIZER_LIST
410 #include <initializer_list>
413 #if variant_HAVE_TYPE_TRAITS
414 #include <type_traits>
415 #elif variant_HAVE_TR1_TYPE_TRAITS
416 #include <tr1/type_traits>
430 #if variant_HAVE_STD_ADD_POINTER
432 using std::add_pointer;
434 #elif variant_HAVE_TR1_ADD_POINTER
436 using std::tr1::add_pointer;
443 template <
class T>
struct add_pointer {
typedef typename remove_reference<T>::type* type; };
447 #if variant_HAVE_REMOVE_CV
449 using std::remove_cv;
463 #if variant_HAVE_CONDITIONAL
465 using std::conditional;
471 template <
class Then,
class Else>
struct conditional<true, Then, Else> {
typedef Then type; };
473 template <
class Then,
class Else>
struct conditional<false, Then, Else> {
typedef Else type; };
477 #if variant_HAVE_ENABLE_IF
479 using std::enable_if;
485 template <
class T>
struct enable_if<true, T> {
typedef T type; };
489 #if variant_HAVE_IS_SAME
496 enum V { value = 0 };
500 enum V { value = 1 };
509 #if variant_CPP11_OR_GREATER
511 #define variant_REQUIRES_T(...) , typename std::enable_if<(__VA_ARGS__), int>::type = 0
513 #define variant_REQUIRES_R(R, ...) typename std::enable_if<(__VA_ARGS__), R>::type
515 #define variant_REQUIRES_A(...) , typename std::enable_if<(__VA_ARGS__), void*>::type = nullptr
519 #define variant_REQUIRES_0(...) template <bool B = (__VA_ARGS__), typename std11::enable_if<B, int>::type = 0>
521 #define variant_REQUIRES_B(...) , bool B = (__VA_ARGS__), typename std11::enable_if<B, int>::type = 0
527 #if variant_CPP17_OR_GREATER
529 using std::is_nothrow_swappable;
530 using std::is_swappable;
532 #elif variant_CPP11_OR_GREATER
538 struct is_swappable {
539 template <typename T, typename = decltype(swap(std::declval<T&>(), std::declval<T&>()))>
static std::true_type test(
int);
541 template <
typename>
static std::false_type test(...);
544 struct is_nothrow_swappable {
547 template <
typename T>
static constexpr
bool test() {
return noexcept(swap(std::declval<T&>(), std::declval<T&>())); }
549 template <
typename T>
static auto test(
int) -> std::integral_constant<bool, test<T>()> {}
551 template <
typename>
static std::false_type test(...);
558 template <
typename T>
struct is_swappable : decltype(detail::is_swappable::test<T>(0)) {};
560 template <
typename T>
struct is_nothrow_swappable : decltype(detail::is_nothrow_swappable::test<T>(0)) {};
572 #define variant_TL1(T1) detail::typelist<T1, detail::nulltype>
573 #define variant_TL2(T1, T2) detail::typelist<T1, variant_TL1(T2)>
574 #define variant_TL3(T1, T2, T3) detail::typelist<T1, variant_TL2(T2, T3)>
575 #define variant_TL4(T1, T2, T3, T4) detail::typelist<T1, variant_TL3(T2, T3, T4)>
576 #define variant_TL5(T1, T2, T3, T4, T5) detail::typelist<T1, variant_TL4(T2, T3, T4, T5)>
577 #define variant_TL6(T1, T2, T3, T4, T5, T6) detail::typelist<T1, variant_TL5(T2, T3, T4, T5, T6)>
578 #define variant_TL7(T1, T2, T3, T4, T5, T6, T7) detail::typelist<T1, variant_TL6(T2, T3, T4, T5, T6, T7)>
579 #define variant_TL8(T1, T2, T3, T4, T5, T6, T7, T8) detail::typelist<T1, variant_TL7(T2, T3, T4, T5, T6, T7, T8)>
580 #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)>
581 #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)>
582 #define variant_TL11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \
583 detail::typelist<T1, variant_TL10(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>
584 #define variant_TL12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \
585 detail::typelist<T1, variant_TL11(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>
586 #define variant_TL13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \
587 detail::typelist<T1, variant_TL12(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)>
588 #define variant_TL14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) \
589 detail::typelist<T1, variant_TL13(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)>
590 #define variant_TL15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) \
591 detail::typelist<T1, variant_TL14(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)>
592 #define variant_TL16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) \
593 detail::typelist<T1, variant_TL15(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)>
597 template <
class T>
struct TX : T {
598 inline TX<T> operator+()
const {
return TX<T>(); }
599 inline TX<T> operator-()
const {
return TX<T>(); }
601 inline TX<T> operator!()
const {
return TX<T>(); }
602 inline TX<T> operator~()
const {
return TX<T>(); }
604 inline TX<T>* operator&()
const {
return variant_nullptr; }
606 template <
class U>
inline TX<T> operator*(U
const&)
const {
return TX<T>(); }
607 template <
class U>
inline TX<T> operator/(U
const&)
const {
return TX<T>(); }
609 template <
class U>
inline TX<T> operator%(U
const&)
const {
return TX<T>(); }
610 template <
class U>
inline TX<T> operator+(U
const&)
const {
return TX<T>(); }
611 template <
class U>
inline TX<T> operator-(U
const&)
const {
return TX<T>(); }
613 template <
class U>
inline TX<T> operator<<(U
const&)
const {
return TX<T>(); }
614 template <
class U>
inline TX<T> operator>>(U
const&)
const {
return TX<T>(); }
616 inline bool operator==(T
const&)
const {
return false; }
617 inline bool operator<(T
const&)
const {
return false; }
619 template <
class U>
inline TX<T> operator&(U
const&)
const {
return TX<T>(); }
620 template <
class U>
inline TX<T> operator|(U
const&)
const {
return TX<T>(); }
621 template <
class U>
inline TX<T> operator^(U
const&)
const {
return TX<T>(); }
623 template <
class U>
inline TX<T> operator&&(U
const&)
const {
return TX<T>(); }
624 template <
class U>
inline TX<T> operator||(U
const&)
const {
return TX<T>(); }
662 template <
class Head,
class Tail>
struct typelist {
672 enum V { value = 0 };
683 enum V { value = (
sizeof(Head) > tail_value) ?
sizeof(Head) : std::size_t(tail_value) };
685 typedef typename std11::conditional<(
sizeof(Head) > tail_value), Head, tail_type>::type type;
688 #if variant_CPP11_OR_GREATER
692 template <
class List>
struct typelist_max_alignof;
694 template <>
struct typelist_max_alignof<
nulltype> {
695 enum V { value = 0 };
698 template <
class Head,
class Tail>
struct typelist_max_alignof<typelist<Head, Tail>> {
700 enum TV { tail_value = size_t(typelist_max_alignof<Tail>::value) };
703 enum V { value = (
alignof(Head) > tail_value) ?
alignof(Head) : std::size_t(tail_value) };
711 enum V { value = 1 };
715 enum V { value = 0 };
718 enum V { value = 0 };
721 enum V { value = 0 };
724 enum V { value = 0 };
727 enum V { value = 0 };
730 enum V { value = 0 };
733 enum V { value = 0 };
736 enum V { value = 0 };
739 enum V { value = 0 };
742 enum V { value = 0 };
745 enum V { value = 0 };
748 enum V { value = 0 };
751 enum V { value = 0 };
754 enum V { value = 0 };
757 enum V { value = 0 };
760 enum V { value = 0 };
764 enum V { value = 0 };
776 enum V { value = -1 };
780 enum V { value = 0 };
788 enum V { value = nextVal == -1 ? -1 : 1 + nextVal };
803 template <class List, std::size_t CmpIndex, std::size_t LastChecked = typelist_size<List>::value>
struct typelist_type_is_unique {
816 enum V { value = 1 };
821 #if variant_CONFIG_MAX_ALIGN_HACK
825 #define variant_UNIQUE(name) variant_UNIQUE2(name, __LINE__)
826 #define variant_UNIQUE2(name, line) variant_UNIQUE3(name, line)
827 #define variant_UNIQUE3(name, line) name##line
829 #define variant_ALIGN_TYPE(type) \
830 type variant_UNIQUE(_t); \
831 struct_t<type> variant_UNIQUE(_st)
833 template <
class T>
struct struct_t { T _; };
836 variant_ALIGN_TYPE(
char);
837 variant_ALIGN_TYPE(
short int);
838 variant_ALIGN_TYPE(
int);
839 variant_ALIGN_TYPE(
long int);
840 variant_ALIGN_TYPE(
float);
841 variant_ALIGN_TYPE(
double);
842 variant_ALIGN_TYPE(
long double);
843 variant_ALIGN_TYPE(
char*);
844 variant_ALIGN_TYPE(
short int*);
845 variant_ALIGN_TYPE(
int*);
846 variant_ALIGN_TYPE(
long int*);
847 variant_ALIGN_TYPE(
float*);
848 variant_ALIGN_TYPE(
double*);
849 variant_ALIGN_TYPE(
long double*);
850 variant_ALIGN_TYPE(
void*);
852 #ifdef HAVE_LONG_LONG
853 variant_ALIGN_TYPE(
long long);
858 Unknown (*variant_UNIQUE(_))(Unknown);
859 Unknown* Unknown::*variant_UNIQUE(_);
860 Unknown (Unknown::*variant_UNIQUE(_))(Unknown);
862 struct_t<Unknown (*)(Unknown)> variant_UNIQUE(_);
863 struct_t<Unknown * Unknown::*> variant_UNIQUE(_);
864 struct_t<Unknown (Unknown::*)(Unknown)> variant_UNIQUE(_);
867 #undef variant_UNIQUE
868 #undef variant_UNIQUE2
869 #undef variant_UNIQUE3
871 #undef variant_ALIGN_TYPE
873 #elif defined(variant_CONFIG_ALIGN_AS)
877 #define variant_ALIGN_AS(unused) variant_CONFIG_ALIGN_AS
883 #define variant_ALIGN_AS(to_align) typename detail::type_of_size<detail::alignment_types, detail::alignment_of<to_align>::value>::type
885 template <
typename T>
struct alignment_of;
894 enum V { value = A < S ? A : S };
902 typedef typename std11::conditional<N ==
sizeof(
typename List::head),
typename List::head,
903 typename type_of_size<typename List::tail, N>::type>::type type;
910 #define variant_ALIGN_TYPE(type) typelist < type, typelist < struct_t<type>
914 typedef variant_ALIGN_TYPE(
char), variant_ALIGN_TYPE(
short), variant_ALIGN_TYPE(
int), variant_ALIGN_TYPE(
long), variant_ALIGN_TYPE(
float),
915 variant_ALIGN_TYPE(
double), variant_ALIGN_TYPE(
long double),
917 variant_ALIGN_TYPE(
char*), variant_ALIGN_TYPE(
short*), variant_ALIGN_TYPE(
int*), variant_ALIGN_TYPE(
long*), variant_ALIGN_TYPE(
float*),
918 variant_ALIGN_TYPE(
double*), variant_ALIGN_TYPE(
long double*),
920 variant_ALIGN_TYPE(Unknown (*)(Unknown)), variant_ALIGN_TYPE(Unknown* Unknown::*), variant_ALIGN_TYPE(Unknown (Unknown::*)(Unknown)),
924 #undef variant_ALIGN_TYPE
928 #if variant_CPP11_OR_GREATER
930 template <
typename T>
inline std::size_t hash(T
const& v) {
return std::hash<T>()(v); }
932 inline std::size_t hash(T0
const&) {
return 0; }
933 inline std::size_t hash(T1
const&) {
return 0; }
934 inline std::size_t hash(T2
const&) {
return 0; }
935 inline std::size_t hash(T3
const&) {
return 0; }
936 inline std::size_t hash(T4
const&) {
return 0; }
937 inline std::size_t hash(T5
const&) {
return 0; }
938 inline std::size_t hash(T6
const&) {
return 0; }
939 inline std::size_t hash(T7
const&) {
return 0; }
940 inline std::size_t hash(T8
const&) {
return 0; }
941 inline std::size_t hash(T9
const&) {
return 0; }
942 inline std::size_t hash(T10
const&) {
return 0; }
943 inline std::size_t hash(T11
const&) {
return 0; }
944 inline std::size_t hash(T12
const&) {
return 0; }
945 inline std::size_t hash(T13
const&) {
return 0; }
946 inline std::size_t hash(T14
const&) {
return 0; }
947 inline std::size_t hash(T15
const&) {
return 0; }
951 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,
952 class T12,
class T13,
class T14,
class T15>
954 typedef signed char type_index_t;
955 typedef variant_TL16(
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15) variant_types;
957 template <
class U>
static U* as(
void* data) {
return reinterpret_cast<U*
>(data); }
959 template <
class U>
static U
const* as(
void const* data) {
return reinterpret_cast<const U*
>(data); }
961 static type_index_t to_index_t(std::size_t index) {
return static_cast<type_index_t
>(index); }
963 static void destroy(type_index_t index,
void* data) {
996 as<T10>(data)->~T10();
999 as<T11>(data)->~T11();
1002 as<T12>(data)->~T12();
1005 as<T13>(data)->~T13();
1008 as<T14>(data)->~T14();
1011 as<T15>(data)->~T15();
1016 #if variant_CPP11_OR_GREATER
1017 template <
class T,
class... Args>
static type_index_t construct_t(
void* data, Args&&... args) {
1018 new(data) T(std::forward<Args>(args)...);
1023 template <std::size_t K,
class... Args>
static type_index_t construct_i(
void* data, Args&&... args) {
1026 construct_t<type>(data, std::forward<Args>(args)...);
1028 return to_index_t(K);
1031 static type_index_t move_construct(type_index_t
const from_index,
void* from_value,
void* to_value) {
1032 switch(from_index) {
1034 new(to_value)
T0(std::move(*as<T0>(from_value)));
1037 new(to_value)
T1(std::move(*as<T1>(from_value)));
1040 new(to_value)
T2(std::move(*as<T2>(from_value)));
1043 new(to_value)
T3(std::move(*as<T3>(from_value)));
1046 new(to_value)
T4(std::move(*as<T4>(from_value)));
1049 new(to_value)
T5(std::move(*as<T5>(from_value)));
1052 new(to_value)
T6(std::move(*as<T6>(from_value)));
1055 new(to_value)
T7(std::move(*as<T7>(from_value)));
1058 new(to_value)
T8(std::move(*as<T8>(from_value)));
1061 new(to_value)
T9(std::move(*as<T9>(from_value)));
1064 new(to_value)
T10(std::move(*as<T10>(from_value)));
1067 new(to_value)
T11(std::move(*as<T11>(from_value)));
1070 new(to_value)
T12(std::move(*as<T12>(from_value)));
1073 new(to_value)
T13(std::move(*as<T13>(from_value)));
1076 new(to_value)
T14(std::move(*as<T14>(from_value)));
1079 new(to_value)
T15(std::move(*as<T15>(from_value)));
1085 static type_index_t move_assign(type_index_t
const from_index,
void* from_value,
void* to_value) {
1086 switch(from_index) {
1088 *as<T0>(to_value) = std::move(*as<T0>(from_value));
1091 *as<T1>(to_value) = std::move(*as<T1>(from_value));
1094 *as<T2>(to_value) = std::move(*as<T2>(from_value));
1097 *as<T3>(to_value) = std::move(*as<T3>(from_value));
1100 *as<T4>(to_value) = std::move(*as<T4>(from_value));
1103 *as<T5>(to_value) = std::move(*as<T5>(from_value));
1106 *as<T6>(to_value) = std::move(*as<T6>(from_value));
1109 *as<T7>(to_value) = std::move(*as<T7>(from_value));
1112 *as<T8>(to_value) = std::move(*as<T8>(from_value));
1115 *as<T9>(to_value) = std::move(*as<T9>(from_value));
1118 *as<T10>(to_value) = std::move(*as<T10>(from_value));
1121 *as<T11>(to_value) = std::move(*as<T11>(from_value));
1124 *as<T12>(to_value) = std::move(*as<T12>(from_value));
1127 *as<T13>(to_value) = std::move(*as<T13>(from_value));
1130 *as<T14>(to_value) = std::move(*as<T14>(from_value));
1133 *as<T15>(to_value) = std::move(*as<T15>(from_value));
1140 static type_index_t copy_construct(type_index_t
const from_index,
const void* from_value,
void* to_value) {
1141 switch(from_index) {
1143 new(to_value)
T0(*as<T0>(from_value));
1146 new(to_value)
T1(*as<T1>(from_value));
1149 new(to_value)
T2(*as<T2>(from_value));
1152 new(to_value)
T3(*as<T3>(from_value));
1155 new(to_value)
T4(*as<T4>(from_value));
1158 new(to_value)
T5(*as<T5>(from_value));
1161 new(to_value)
T6(*as<T6>(from_value));
1164 new(to_value)
T7(*as<T7>(from_value));
1167 new(to_value)
T8(*as<T8>(from_value));
1170 new(to_value)
T9(*as<T9>(from_value));
1173 new(to_value)
T10(*as<T10>(from_value));
1176 new(to_value)
T11(*as<T11>(from_value));
1179 new(to_value)
T12(*as<T12>(from_value));
1182 new(to_value)
T13(*as<T13>(from_value));
1185 new(to_value)
T14(*as<T14>(from_value));
1188 new(to_value)
T15(*as<T15>(from_value));
1194 static type_index_t copy_assign(type_index_t
const from_index,
const void* from_value,
void* to_value) {
1195 switch(from_index) {
1197 *as<T0>(to_value) = *as<T0>(from_value);
1200 *as<T1>(to_value) = *as<T1>(from_value);
1203 *as<T2>(to_value) = *as<T2>(from_value);
1206 *as<T3>(to_value) = *as<T3>(from_value);
1209 *as<T4>(to_value) = *as<T4>(from_value);
1212 *as<T5>(to_value) = *as<T5>(from_value);
1215 *as<T6>(to_value) = *as<T6>(from_value);
1218 *as<T7>(to_value) = *as<T7>(from_value);
1221 *as<T8>(to_value) = *as<T8>(from_value);
1224 *as<T9>(to_value) = *as<T9>(from_value);
1227 *as<T10>(to_value) = *as<T10>(from_value);
1230 *as<T11>(to_value) = *as<T11>(from_value);
1233 *as<T12>(to_value) = *as<T12>(from_value);
1236 *as<T13>(to_value) = *as<T13>(from_value);
1239 *as<T14>(to_value) = *as<T14>(from_value);
1242 *as<T15>(to_value) = *as<T15>(from_value);
1255 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,
1256 class T12,
class T13,
class T14,
class T15>
1265 inline variant_constexpr
bool operator<(
monostate,
monostate) variant_noexcept {
return false; }
1266 inline variant_constexpr
bool operator>(
monostate,
monostate) variant_noexcept {
return false; }
1267 inline variant_constexpr
bool operator<=(monostate, monostate) variant_noexcept {
return true; }
1268 inline variant_constexpr
bool operator>=(monostate, monostate) variant_noexcept {
return true; }
1269 inline variant_constexpr
bool operator==(monostate, monostate) variant_noexcept {
return true; }
1270 inline variant_constexpr
bool operator!=(monostate, monostate) variant_noexcept {
return false; }
1278 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,
1279 class T12,
class T13,
class T14,
class T15>
1280 struct variant_size<
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>> {
1281 enum _ { value =
detail::typelist_size<variant_TL16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)>::value };
1284 #if variant_CPP14_OR_GREATER
1288 #if !variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO
1289 #define variant_size_V(T) nonstd::variant_size<T>::value
1296 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,
1297 class T11,
class T12,
class T13,
class T14,
class T15>
1298 struct variant_alternative<K,
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>> {
1300 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;
1303 #if variant_CPP11_OR_GREATER
1307 #if !variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO
1308 #define variant_alternative_T(K, T) typename nonstd::variant_alternative<K, T>::type
1316 #if variant_CPP11_OR_GREATER
1317 variant_constexpr std::size_t variant_npos =
static_cast<std::size_t
>(-1);
1319 static const std::size_t variant_npos =
static_cast<std::size_t
>(-1);
1322 #if !variant_CONFIG_NO_EXCEPTIONS
1326 class bad_variant_access :
public std::exception {
1328 #if variant_CPP11_OR_GREATER
1329 virtual const char* what() const variant_noexcept variant_override
1331 virtual const char* what()
const throw()
1334 return "bad variant access";
1342 template <
class T0,
class T1 = detail::T1,
class T2 = detail::T2,
class T3 = detail::T3,
class T4 = detail::T4,
class T5 = detail::T5,
1343 class T6 = detail::T6,
class T7 = detail::T7,
class T8 = detail::T8,
class T9 = detail::T9,
class T10 = detail::T10,
1344 class T11 = detail::T11,
class T12 = detail::T12,
class T13 = detail::T13,
class T14 = detail::T14,
class T15 = detail::T15>
1346 typedef detail::helper<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> helper_type;
1347 typedef variant_TL16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) variant_types;
1357 #if variant_CPP11_OR_GREATER
1358 template <variant_index_tag_t(0) = variant_index_tag(0) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 0>::value)>
1364 template <variant_index_tag_t(1) = variant_index_tag(1) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 1>::value)>
1370 template <variant_index_tag_t(2) = variant_index_tag(2) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 2>::value)>
1376 template <variant_index_tag_t(3) = variant_index_tag(3) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 3>::value)>
1382 template <variant_index_tag_t(4) = variant_index_tag(4) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 4>::value)>
1388 template <variant_index_tag_t(5) = variant_index_tag(5) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 5>::value)>
1394 template <variant_index_tag_t(6) = variant_index_tag(6) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 6>::value)>
1400 template <variant_index_tag_t(7) = variant_index_tag(7) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 7>::value)>
1406 template <variant_index_tag_t(8) = variant_index_tag(8) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 8>::value)>
1412 template <variant_index_tag_t(9) = variant_index_tag(9) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 9>::value)>
1418 template <variant_index_tag_t(10) = variant_index_tag(10) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 10>::value)>
1421 new(ptr()) T10(t10);
1424 template <variant_index_tag_t(11) = variant_index_tag(11) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 11>::value)>
1427 new(ptr()) T11(t11);
1430 template <variant_index_tag_t(12) = variant_index_tag(12) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 12>::value)>
1433 new(ptr()) T12(t12);
1436 template <variant_index_tag_t(13) = variant_index_tag(13) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 13>::value)>
1439 new(ptr()) T13(t13);
1442 template <variant_index_tag_t(14) = variant_index_tag(14) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 14>::value)>
1445 new(ptr()) T14(t14);
1448 template <variant_index_tag_t(15) = variant_index_tag(15) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 15>::value)>
1451 new(ptr()) T15(t15);
1498 new(ptr()) T10(t10);
1502 new(ptr()) T11(t11);
1506 new(ptr()) T12(t12);
1510 new(ptr()) T13(t13);
1514 new(ptr()) T14(t14);
1518 new(ptr()) T15(t15);
1523 #if variant_CPP11_OR_GREATER
1524 template <variant_index_tag_t(0) = variant_index_tag(0) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 0>::value)>
1527 new(ptr()) T0(std::move(t0));
1530 template <variant_index_tag_t(1) = variant_index_tag(1) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 1>::value)>
1533 new(ptr()) T1(std::move(t1));
1536 template <variant_index_tag_t(2) = variant_index_tag(2) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 2>::value)>
1539 new(ptr()) T2(std::move(t2));
1542 template <variant_index_tag_t(3) = variant_index_tag(3) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 3>::value)>
1545 new(ptr()) T3(std::move(t3));
1548 template <variant_index_tag_t(4) = variant_index_tag(4) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 4>::value)>
1551 new(ptr()) T4(std::move(t4));
1554 template <variant_index_tag_t(5) = variant_index_tag(5) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 5>::value)>
1557 new(ptr()) T5(std::move(t5));
1560 template <variant_index_tag_t(6) = variant_index_tag(6) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 6>::value)>
1563 new(ptr()) T6(std::move(t6));
1566 template <variant_index_tag_t(7) = variant_index_tag(7) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 7>::value)>
1569 new(ptr()) T7(std::move(t7));
1572 template <variant_index_tag_t(8) = variant_index_tag(8) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 8>::value)>
1575 new(ptr()) T8(std::move(t8));
1578 template <variant_index_tag_t(9) = variant_index_tag(9) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 9>::value)>
1581 new(ptr()) T9(std::move(t9));
1584 template <variant_index_tag_t(10) = variant_index_tag(10) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 10>::value)>
1587 new(ptr()) T10(std::move(t10));
1590 template <variant_index_tag_t(11) = variant_index_tag(11) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 11>::value)>
1593 new(ptr()) T11(std::move(t11));
1596 template <variant_index_tag_t(12) = variant_index_tag(12) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 12>::value)>
1599 new(ptr()) T12(std::move(t12));
1602 template <variant_index_tag_t(13) = variant_index_tag(13) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 13>::value)>
1605 new(ptr()) T13(std::move(t13));
1608 template <variant_index_tag_t(14) = variant_index_tag(14) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 14>::value)>
1611 new(ptr()) T14(std::move(t14));
1614 template <variant_index_tag_t(15) = variant_index_tag(15) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 15>::value)>
1617 new(ptr()) T15(std::move(t15));
1622 : type_index(other.type_index) {
1623 (void)helper_type::copy_construct(other.type_index, other.ptr(), ptr());
1626 #if variant_CPP11_OR_GREATER
1629 std::is_nothrow_move_constructible<T0>::value&& std::is_nothrow_move_constructible<T1>::value&&
1630 std::is_nothrow_move_constructible<T2>::value&& std::is_nothrow_move_constructible<T3>::value&&
1631 std::is_nothrow_move_constructible<T4>::value&& std::is_nothrow_move_constructible<T5>::value&&
1632 std::is_nothrow_move_constructible<T6>::value&& std::is_nothrow_move_constructible<T7>::value&&
1633 std::is_nothrow_move_constructible<T8>::value&& std::is_nothrow_move_constructible<T9>::value&&
1634 std::is_nothrow_move_constructible<T10>::value&& std::is_nothrow_move_constructible<T11>::value&&
1635 std::is_nothrow_move_constructible<T12>::value&& std::is_nothrow_move_constructible<T13>::value&&
1636 std::is_nothrow_move_constructible<T14>::value&& std::is_nothrow_move_constructible<T15>::value)
1637 : type_index(other.type_index) {
1638 (void)helper_type::move_construct(other.type_index, other.ptr(), ptr());
1643 template <
class T,
class... Args variant_REQUIRES_T(std::is_constructible<T, Args...>::value)>
1644 explicit variant(nonstd_lite_in_place_type_t(T), Args&&... args) {
1645 type_index = variant_npos_internal();
1646 type_index = helper_type::template construct_t<T>(ptr(), std::forward<Args>(args)...);
1649 template <
class T,
class U,
class... Args variant_REQUIRES_T(std::is_constructible<T, std::initializer_list<U>&, Args...>::value)>
1650 explicit variant(nonstd_lite_in_place_type_t(T), std::initializer_list<U> il, Args&&... args) {
1651 type_index = variant_npos_internal();
1652 type_index = helper_type::template construct_t<T>(ptr(), il, std::forward<Args>(args)...);
1655 template <std::size_t K,
class... Args variant_REQUIRES_T(std::is_constructible<type_at_t<K>, Args...>::value)>
1656 explicit variant(nonstd_lite_in_place_index_t(K), Args&&... args) {
1657 type_index = variant_npos_internal();
1658 type_index = helper_type::template construct_i<K>(ptr(), std::forward<Args>(args)...);
1661 template <
size_t K,
class U,
1662 class... Args variant_REQUIRES_T(std::is_constructible<type_at_t<K>, std::initializer_list<U>&, Args...>::value)>
1663 explicit variant(nonstd_lite_in_place_index_t(K), std::initializer_list<U> il, Args&&... args) {
1664 type_index = variant_npos_internal();
1665 type_index = helper_type::template construct_i<K>(ptr(), il, std::forward<Args>(args)...);
1673 if(!valueless_by_exception()) {
1674 helper_type::destroy(type_index, ptr());
1680 variant& operator=(
variant const& other) {
return copy_assign(other); }
1682 #if variant_CPP11_OR_GREATER
1685 std::is_nothrow_move_assignable<T0>::value&& std::is_nothrow_move_assignable<T1>::value&&
1686 std::is_nothrow_move_assignable<T2>::value&& std::is_nothrow_move_assignable<T3>::value&&
1687 std::is_nothrow_move_assignable<T4>::value&& std::is_nothrow_move_assignable<T5>::value&&
1688 std::is_nothrow_move_assignable<T6>::value&& std::is_nothrow_move_assignable<T7>::value&&
1689 std::is_nothrow_move_assignable<T8>::value&& std::is_nothrow_move_assignable<T9>::value&&
1690 std::is_nothrow_move_assignable<T10>::value&& std::is_nothrow_move_assignable<T11>::value&&
1691 std::is_nothrow_move_assignable<T12>::value&& std::is_nothrow_move_assignable<T13>::value&&
1692 std::is_nothrow_move_assignable<T14>::value&& std::is_nothrow_move_assignable<T15>::value) {
1693 return move_assign(std::move(other));
1696 template <variant_index_tag_t(0) = variant_index_tag(0) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 0>::value)>
1698 return assign_value<0>(std::move(t0));
1701 template <variant_index_tag_t(1) = variant_index_tag(1) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 1>::value)>
1703 return assign_value<1>(std::move(t1));
1706 template <variant_index_tag_t(2) = variant_index_tag(2) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 2>::value)>
1708 return assign_value<2>(std::move(t2));
1711 template <variant_index_tag_t(3) = variant_index_tag(3) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 3>::value)>
1713 return assign_value<3>(std::move(t3));
1716 template <variant_index_tag_t(4) = variant_index_tag(4) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 4>::value)>
1718 return assign_value<4>(std::move(t4));
1721 template <variant_index_tag_t(5) = variant_index_tag(5) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 5>::value)>
1723 return assign_value<5>(std::move(t5));
1726 template <variant_index_tag_t(6) = variant_index_tag(6) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 6>::value)>
1728 return assign_value<6>(std::move(t6));
1731 template <variant_index_tag_t(7) = variant_index_tag(7) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 7>::value)>
1733 return assign_value<7>(std::move(t7));
1736 template <variant_index_tag_t(8) = variant_index_tag(8) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 8>::value)>
1738 return assign_value<8>(std::move(t8));
1741 template <variant_index_tag_t(9) = variant_index_tag(9) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 9>::value)>
1743 return assign_value<9>(std::move(t9));
1746 template <variant_index_tag_t(10) = variant_index_tag(10) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 10>::value)>
1747 variant& operator=(T10&& t10) {
1748 return assign_value<10>(std::move(t10));
1751 template <variant_index_tag_t(11) = variant_index_tag(11) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 11>::value)>
1752 variant& operator=(T11&& t11) {
1753 return assign_value<11>(std::move(t11));
1756 template <variant_index_tag_t(12) = variant_index_tag(12) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 12>::value)>
1757 variant& operator=(T12&& t12) {
1758 return assign_value<12>(std::move(t12));
1761 template <variant_index_tag_t(13) = variant_index_tag(13) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 13>::value)>
1762 variant& operator=(T13&& t13) {
1763 return assign_value<13>(std::move(t13));
1766 template <variant_index_tag_t(14) = variant_index_tag(14) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 14>::value)>
1767 variant& operator=(T14&& t14) {
1768 return assign_value<14>(std::move(t14));
1771 template <variant_index_tag_t(15) = variant_index_tag(15) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 15>::value)>
1772 variant& operator=(T15&& t15) {
1773 return assign_value<15>(std::move(t15));
1778 #if variant_CPP11_OR_GREATER
1780 template <variant_index_tag_t(0) = variant_index_tag(0) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 0>::value)>
1781 variant& operator=(T0
const& t0) {
1782 return assign_value<0>(t0);
1785 template <variant_index_tag_t(1) = variant_index_tag(1) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 1>::value)>
1786 variant& operator=(T1
const& t1) {
1787 return assign_value<1>(t1);
1790 template <variant_index_tag_t(2) = variant_index_tag(2) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 2>::value)>
1791 variant& operator=(T2
const& t2) {
1792 return assign_value<2>(t2);
1795 template <variant_index_tag_t(3) = variant_index_tag(3) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 3>::value)>
1796 variant& operator=(T3
const& t3) {
1797 return assign_value<3>(t3);
1800 template <variant_index_tag_t(4) = variant_index_tag(4) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 4>::value)>
1801 variant& operator=(T4
const& t4) {
1802 return assign_value<4>(t4);
1805 template <variant_index_tag_t(5) = variant_index_tag(5) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 5>::value)>
1806 variant& operator=(T5
const& t5) {
1807 return assign_value<5>(t5);
1810 template <variant_index_tag_t(6) = variant_index_tag(6) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 6>::value)>
1811 variant& operator=(T6
const& t6) {
1812 return assign_value<6>(t6);
1815 template <variant_index_tag_t(7) = variant_index_tag(7) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 7>::value)>
1816 variant& operator=(T7
const& t7) {
1817 return assign_value<7>(t7);
1820 template <variant_index_tag_t(8) = variant_index_tag(8) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 8>::value)>
1821 variant& operator=(T8
const& t8) {
1822 return assign_value<8>(t8);
1825 template <variant_index_tag_t(9) = variant_index_tag(9) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 9>::value)>
1826 variant& operator=(T9
const& t9) {
1827 return assign_value<9>(t9);
1830 template <variant_index_tag_t(10) = variant_index_tag(10) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 10>::value)>
1831 variant& operator=(T10
const& t10) {
1832 return assign_value<10>(t10);
1835 template <variant_index_tag_t(11) = variant_index_tag(11) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 11>::value)>
1836 variant& operator=(T11
const& t11) {
1837 return assign_value<11>(t11);
1840 template <variant_index_tag_t(12) = variant_index_tag(12) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 12>::value)>
1841 variant& operator=(T12
const& t12) {
1842 return assign_value<12>(t12);
1845 template <variant_index_tag_t(13) = variant_index_tag(13) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 13>::value)>
1846 variant& operator=(T13
const& t13) {
1847 return assign_value<13>(t13);
1850 template <variant_index_tag_t(14) = variant_index_tag(14) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 14>::value)>
1851 variant& operator=(T14
const& t14) {
1852 return assign_value<14>(t14);
1855 template <variant_index_tag_t(15) = variant_index_tag(15) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 15>::value)>
1856 variant& operator=(T15
const& t15) {
1857 return assign_value<15>(t15);
1862 variant& operator=(T0
const& t0) {
return assign_value<0>(t0); }
1863 variant& operator=(T1
const& t1) {
return assign_value<1>(t1); }
1864 variant& operator=(T2
const& t2) {
return assign_value<2>(t2); }
1865 variant& operator=(T3
const& t3) {
return assign_value<3>(t3); }
1866 variant& operator=(T4
const& t4) {
return assign_value<4>(t4); }
1867 variant& operator=(T5
const& t5) {
return assign_value<5>(t5); }
1868 variant& operator=(T6
const& t6) {
return assign_value<6>(t6); }
1869 variant& operator=(T7
const& t7) {
return assign_value<7>(t7); }
1870 variant& operator=(T8
const& t8) {
return assign_value<8>(t8); }
1871 variant& operator=(T9
const& t9) {
return assign_value<9>(t9); }
1872 variant& operator=(T10
const& t10) {
return assign_value<10>(t10); }
1873 variant& operator=(T11
const& t11) {
return assign_value<11>(t11); }
1874 variant& operator=(T12
const& t12) {
return assign_value<12>(t12); }
1875 variant& operator=(T13
const& t13) {
return assign_value<13>(t13); }
1876 variant& operator=(T14
const& t14) {
return assign_value<14>(t14); }
1877 variant& operator=(T15
const& t15) {
return assign_value<15>(t15); }
1881 std::size_t index()
const {
return variant_npos_internal() == type_index ? variant_npos :
static_cast<std::size_t
>(type_index); }
1885 #if variant_CPP11_OR_GREATER
1887 template <
class T,
class... Args variant_REQUIRES_T(std::is_constructible<T, Args...>::value)
1889 T& emplace(Args&&... args) {
1890 helper_type::destroy(type_index, ptr());
1891 type_index = variant_npos_internal();
1892 type_index = helper_type::template construct_t<T>(ptr(), std::forward<Args>(args)...);
1897 template <
class T,
class U,
1898 class... Args variant_REQUIRES_T(std::is_constructible<T, std::initializer_list<U>&, Args...>::value)
1900 T& emplace(std::initializer_list<U> il, Args&&... args) {
1901 helper_type::destroy(type_index, ptr());
1902 type_index = variant_npos_internal();
1903 type_index = helper_type::template construct_t<T>(ptr(), il, std::forward<Args>(args)...);
1908 template <
size_t K,
class... Args variant_REQUIRES_T(std::is_constructible<type_at_t<K>, Args...>::value)>
1909 variant_alternative_t<K, variant>& emplace(Args&&... args) {
1910 return this->
template emplace<type_at_t<K>>(std::forward<Args>(args)...);
1913 template <
size_t K,
class U,
1914 class... Args variant_REQUIRES_T(std::is_constructible<type_at_t<K>, std::initializer_list<U>&, Args...>::value)>
1915 variant_alternative_t<K, variant>& emplace(std::initializer_list<U> il, Args&&... args) {
1916 return this->
template emplace<type_at_t<K>>(il, std::forward<Args>(args)...);
1923 bool valueless_by_exception()
const {
return type_index == variant_npos_internal(); }
1928 #if variant_CPP11_OR_GREATER
1930 std::is_nothrow_move_constructible<T0>::value&& std17::is_nothrow_swappable<T0>::value&& std::is_nothrow_move_constructible<
1931 T1>::value&& std17::is_nothrow_swappable<T1>::value&& std::is_nothrow_move_constructible<T2>::value&&
1932 std17::is_nothrow_swappable<T2>::value&& std::is_nothrow_move_constructible<T3>::value&& std17::is_nothrow_swappable<
1933 T3>::value&& std::is_nothrow_move_constructible<T4>::value&& std17::is_nothrow_swappable<T4>::value&&
1934 std::is_nothrow_move_constructible<T5>::value&& std17::is_nothrow_swappable<
1935 T5>::value&& std::is_nothrow_move_constructible<T6>::value&& std17::is_nothrow_swappable<T6>::value&&
1936 std::is_nothrow_move_constructible<T7>::value&& std17::is_nothrow_swappable<
1937 T7>::value&& std::is_nothrow_move_constructible<T8>::value&& std17::is_nothrow_swappable<T8>::value&&
1938 std::is_nothrow_move_constructible<T9>::value&& std17::is_nothrow_swappable<T9>::value&&
1939 std::is_nothrow_move_constructible<T10>::value&& std17::is_nothrow_swappable<T10>::value&&
1940 std::is_nothrow_move_constructible<T11>::value&& std17::is_nothrow_swappable<T11>::value&&
1941 std::is_nothrow_move_constructible<T12>::value&& std17::is_nothrow_swappable<T12>::value&&
1942 std::is_nothrow_move_constructible<T13>::value&& std17::is_nothrow_swappable<T13>::value&&
1943 std::is_nothrow_move_constructible<T14>::value&& std17::is_nothrow_swappable<T14>::value&&
1944 std::is_nothrow_move_constructible<T15>::value&& std17::is_nothrow_swappable<T15>::value
1949 if(valueless_by_exception() && other.valueless_by_exception()) {
1951 }
else if(type_index == other.type_index) {
1952 this->swap_value(type_index, other);
1954 #if variant_CPP11_OR_GREATER
1955 variant tmp(std::move(*
this));
1956 *
this = std::move(other);
1957 other = std::move(tmp);
1970 template <
class T>
static variant_constexpr std::size_t index_of() variant_noexcept {
1974 template <
class T> T& get() {
1975 #if variant_CONFIG_NO_EXCEPTIONS
1976 assert(index_of<T>() == index());
1978 if(index_of<T>() != index()) {
1979 throw bad_variant_access();
1985 template <
class T> T
const& get()
const {
1986 #if variant_CONFIG_NO_EXCEPTIONS
1987 assert(index_of<T>() == index());
1989 if(index_of<T>() != index()) {
1990 throw bad_variant_access();
1993 return *as<const T>();
1997 return this->
template get<typename detail::typelist_type_at<variant_types, K>::type>();
2001 return this->
template get<typename detail::typelist_type_at<variant_types, K>::type>();
2005 typedef typename helper_type::type_index_t type_index_t;
2007 void* ptr() variant_noexcept {
return &data; }
2009 void const* ptr()
const variant_noexcept {
return &data; }
2011 template <
class U> U* as() {
return reinterpret_cast<U*
>(ptr()); }
2013 template <
class U> U
const* as()
const {
return reinterpret_cast<U const*
>(ptr()); }
2015 template <
class U>
static variant_constexpr std::size_t to_size_t(U index) {
return static_cast<std::size_t
>(index); }
2017 variant_constexpr type_index_t variant_npos_internal()
const variant_noexcept {
return static_cast<type_index_t
>(-1); }
2020 if(valueless_by_exception() && other.valueless_by_exception()) {
2022 }
else if(!valueless_by_exception() && other.valueless_by_exception()) {
2023 helper_type::destroy(type_index, ptr());
2024 type_index = variant_npos_internal();
2025 }
else if(index() == other.index()) {
2026 type_index = helper_type::copy_assign(other.type_index, other.ptr(), ptr());
2028 helper_type::destroy(type_index, ptr());
2029 type_index = variant_npos_internal();
2030 type_index = helper_type::copy_construct(other.type_index, other.ptr(), ptr());
2035 #if variant_CPP11_OR_GREATER
2038 if(valueless_by_exception() && other.valueless_by_exception()) {
2040 }
else if(!valueless_by_exception() && other.valueless_by_exception()) {
2041 helper_type::destroy(type_index, ptr());
2042 type_index = variant_npos_internal();
2043 }
else if(index() == other.index()) {
2044 type_index = helper_type::move_assign(other.type_index, other.ptr(), ptr());
2046 helper_type::destroy(type_index, ptr());
2047 type_index = variant_npos_internal();
2048 type_index = helper_type::move_construct(other.type_index, other.ptr(), ptr());
2053 template <std::
size_t K,
class T>
variant& assign_value(T&& value) {
2055 *as<T>() = std::forward<T>(value);
2057 helper_type::destroy(type_index, ptr());
2058 type_index = variant_npos_internal();
2059 new(ptr()) T(std::forward<T>(value));
2067 template <std::
size_t K,
class T>
variant& assign_value(T
const& value) {
2071 helper_type::destroy(type_index, ptr());
2072 type_index = variant_npos_internal();
2073 new(ptr()) T(value);
2079 void swap_value(type_index_t index,
variant& other) {
2083 swap(this->get<0>(), other.get<0>());
2086 swap(this->get<1>(), other.get<1>());
2089 swap(this->get<2>(), other.get<2>());
2092 swap(this->get<3>(), other.get<3>());
2095 swap(this->get<4>(), other.get<4>());
2098 swap(this->get<5>(), other.get<5>());
2101 swap(this->get<6>(), other.get<6>());
2104 swap(this->get<7>(), other.get<7>());
2107 swap(this->get<8>(), other.get<8>());
2110 swap(this->get<9>(), other.get<9>());
2113 swap(this->get<10>(), other.get<10>());
2116 swap(this->get<11>(), other.get<11>());
2119 swap(this->get<12>(), other.get<12>());
2122 swap(this->get<13>(), other.get<13>());
2125 swap(this->get<14>(), other.get<14>());
2128 swap(this->get<15>(), other.get<15>());
2136 #if variant_CPP11_OR_GREATER
2138 enum { data_align = detail::typelist_max_alignof<variant_types>::value };
2140 using aligned_storage_t =
typename std::aligned_storage<data_size, data_align>::type;
2141 aligned_storage_t data;
2143 #elif variant_CONFIG_MAX_ALIGN_HACK
2146 unsigned char data[data_size];
2147 } aligned_storage_t;
2149 detail::max_align_t hack;
2150 aligned_storage_t data;
2155 typedef variant_ALIGN_AS(max_type) align_as_type;
2158 align_as_type data[1 + (data_size - 1) /
sizeof(align_as_type)];
2159 } aligned_storage_t;
2160 aligned_storage_t data;
2166 type_index_t type_index;
2171 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,
2172 class T12,
class T13,
class T14,
class T15>
2173 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 {
2174 return v.index() ==
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>::template index_of<T>();
2177 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,
2178 class T12,
class T13,
class T14,
class T15>
2179 inline R& get(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>& v,
2180 nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) {
2181 return v.template get<R>();
2184 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,
2185 class T12,
class T13,
class T14,
class T15>
2186 inline R
const& get(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const& v,
2187 nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) {
2188 return v.template get<R>();
2191 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,
2192 class T11,
class T12,
class T13,
class T14,
class T15>
2193 inline typename variant_alternative<K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>::type&
2194 get(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>& v,
2195 nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) {
2196 #if variant_CONFIG_NO_EXCEPTIONS
2197 assert(K == v.index());
2199 if(K != v.index()) {
2200 throw bad_variant_access();
2203 return v.template get<K>();
2206 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,
2207 class T11,
class T12,
class T13,
class T14,
class T15>
2208 inline typename variant_alternative<K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>::type
const&
2209 get(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const& v,
2210 nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) {
2211 #if variant_CONFIG_NO_EXCEPTIONS
2212 assert(K == v.index());
2214 if(K != v.index()) {
2215 throw bad_variant_access();
2218 return v.template get<K>();
2221 #if variant_CPP11_OR_GREATER
2223 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,
2224 class T12,
class T13,
class T14,
class T15>
2225 inline R&& get(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>&& v,
2226 nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) {
2227 return std::move(v.template get<R>());
2230 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,
2231 class T12,
class T13,
class T14,
class T15>
2232 inline R
const&& get(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const&& v,
2233 nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) {
2234 return std::move(v.template get<R>());
2237 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,
2238 class T11,
class T12,
class T13,
class T14,
class T15>
2239 inline typename variant_alternative<K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>::type&&
2240 get(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>&& v,
2241 nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) {
2242 #if variant_CONFIG_NO_EXCEPTIONS
2243 assert(K == v.index());
2245 if(K != v.index()) {
2246 throw bad_variant_access();
2249 return std::move(v.template get<K>());
2252 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,
2253 class T11,
class T12,
class T13,
class T14,
class T15>
2254 inline typename variant_alternative<K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>::type
const&&
2255 get(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const&& v,
2256 nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) {
2257 #if variant_CONFIG_NO_EXCEPTIONS
2258 assert(K == v.index());
2260 if(K != v.index()) {
2261 throw bad_variant_access();
2264 return std::move(v.template get<K>());
2269 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,
2270 class T12,
class T13,
class T14,
class T15>
2271 inline typename std11::add_pointer<T>::type get_if(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>* pv,
2272 nonstd_lite_in_place_type_t(T) = nonstd_lite_in_place_type(T)) {
2273 return (pv->index() == variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>::template index_of<T>())
2278 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,
2279 class T12,
class T13,
class T14,
class T15>
2280 inline typename std11::add_pointer<const T>::type
2281 get_if(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const* pv,
2282 nonstd_lite_in_place_type_t(T) = nonstd_lite_in_place_type(T)) {
2283 return (pv->index() == variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>::template index_of<T>())
2288 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,
2289 class T11,
class T12,
class T13,
class T14,
class T15>
2290 inline typename std11::add_pointer<
2291 typename variant_alternative<K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>::type>::type
2292 get_if(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>* pv,
2293 nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) {
2294 return (pv->index() == K) ? &get<K>(*pv) : variant_nullptr;
2297 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,
2298 class T11,
class T12,
class T13,
class T14,
class T15>
2299 inline typename std11::add_pointer<
2300 const typename variant_alternative<K, variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>::type>::type
2301 get_if(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const* pv,
2302 nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) {
2303 return (pv->index() == K) ? &get<K>(*pv) : variant_nullptr;
2308 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,
2309 class T12,
class T13,
class T14,
2311 #if variant_CPP11_OR_GREATER
2313 std::is_move_constructible<T0>::value&& std17::is_swappable<T0>::value&& std::is_move_constructible<
2314 T1>::value&& std17::is_swappable<T1>::value&& std::is_move_constructible<T2>::value&& std17::is_swappable<T2>::value&&
2315 std::is_move_constructible<T3>::value&& std17::is_swappable<T3>::value&& std::is_move_constructible<T4>::value&&
2316 std17::is_swappable<T4>::value&& std::is_move_constructible<T5>::value&& std17::is_swappable<T5>::value&&
2317 std::is_move_constructible<T6>::value&& std17::is_swappable<T6>::value&& std::is_move_constructible<
2318 T7>::value&& std17::is_swappable<T7>::value&& std::is_move_constructible<T8>::value&&
2319 std17::is_swappable<T8>::value&& std::is_move_constructible<T9>::value&& std17::is_swappable<T9>::value&&
2320 std::is_move_constructible<T10>::value&& std17::is_swappable<T10>::value&& std::is_move_constructible<
2321 T11>::value&& std17::is_swappable<T11>::value&& std::is_move_constructible<T12>::value&&
2322 std17::is_swappable<T12>::value&& std::is_move_constructible<T13>::value&& std17::is_swappable<
2323 T13>::value&& std::is_move_constructible<T14>::value&& std17::is_swappable<T14>::value&&
2324 std::is_move_constructible<T15>::value&& std17::is_swappable<T15>::value)
2327 inline void swap(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>& a,
2328 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>& b)
2329 #if variant_CPP11_OR_GREATER
2330 noexcept(noexcept(a.swap(b)))
2343 template <
typename Visitor,
typename T>
static R apply(Visitor
const& v, T
const& arg) {
return v(arg); }
2347 template <
typename Visitor,
typename T>
static R apply(Visitor
const&, T) {
2355 template <
typename R,
typename Visitor,
typename V1>
struct VisitorUnwrapper;
2357 #if variant_CPP11_OR_GREATER
2358 template <
size_t NumVars,
typename R,
typename Visitor,
typename... T>
2360 template <
size_t NumVars,
typename R,
typename Visitor,
typename T1,
typename T2 = S0,
typename T3 = S0,
typename T4 = S0,
typename T5 = S0>
2365 const Visitor& visitor;
2374 template <
typename T> R operator()(
const T& val1)
const {
return visitor(val1, val2); }
2378 const Visitor& visitor;
2389 template <
typename T> R operator()(
const T& val1)
const {
return visitor(val1, val2, val3); }
2393 const Visitor& visitor;
2406 template <
typename T> R operator()(
const T& val1)
const {
return visitor(val1, val2, val3, val4); }
2409 template <
typename R,
typename Visitor,
typename T2,
typename T3,
typename T4,
typename T5>
2411 const Visitor& visitor;
2426 template <
typename T> R operator()(
const T& val1)
const {
return visitor(val1, val2, val3, val4, val5); }
2430 const Visitor& visitor;
2437 template <
typename T1> R operator()(
T1 const& val1)
const {
2442 template <
typename T1,
typename T2> R operator()(
T1 const& val1,
T2 const& val2)
const {
2447 template <
typename T1,
typename T2,
typename T3> R operator()(
T1 const& val1,
T2 const& val2,
T3 const& val3)
const {
2452 template <
typename T1,
typename T2,
typename T3,
typename T4>
2453 R operator()(
T1 const& val1,
T2 const& val2,
T3 const& val3,
T4 const& val4)
const {
2458 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
2459 R operator()(
T1 const& val1,
T2 const& val2,
T3 const& val3,
T4 const& val4,
T5 const& val5)
const {
2466 template <
typename Visitor,
typename V1>
static R apply(
const Visitor& v,
const V1& arg) {
2467 switch(arg.index()) {
2469 return apply_visitor<0>(v, arg);
2471 return apply_visitor<1>(v, arg);
2473 return apply_visitor<2>(v, arg);
2475 return apply_visitor<3>(v, arg);
2477 return apply_visitor<4>(v, arg);
2479 return apply_visitor<5>(v, arg);
2481 return apply_visitor<6>(v, arg);
2483 return apply_visitor<7>(v, arg);
2485 return apply_visitor<8>(v, arg);
2487 return apply_visitor<9>(v, arg);
2489 return apply_visitor<10>(v, arg);
2491 return apply_visitor<11>(v, arg);
2493 return apply_visitor<12>(v, arg);
2495 return apply_visitor<13>(v, arg);
2497 return apply_visitor<14>(v, arg);
2499 return apply_visitor<15>(v, arg);
2507 template <
size_t Idx,
typename Visitor,
typename V1>
static R apply_visitor(
const Visitor& v,
const V1& arg) {
2509 #if variant_CPP11_OR_GREATER
2517 #if variant_CPP11_OR_GREATER
2518 template <
typename Visitor,
typename V1,
typename V2,
typename... V>
2519 static R apply(
const Visitor& v,
const V1& arg1,
const V2& arg2,
const V... args) {
2521 Unwrapper unwrapper(v, arg1);
2522 return apply(unwrapper, arg2, args...);
2526 template <
typename Visitor,
typename V1,
typename V2>
static R apply(
const Visitor& v, V1
const& arg1, V2
const& arg2) {
2528 Unwrapper unwrapper(v, arg1);
2529 return apply(unwrapper, arg2);
2532 template <
typename Visitor,
typename V1,
typename V2,
typename V3>
2533 static R apply(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3) {
2535 Unwrapper unwrapper(v, arg1);
2536 return apply(unwrapper, arg2, arg3);
2539 template <
typename Visitor,
typename V1,
typename V2,
typename V3,
typename V4>
2540 static R apply(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3, V4
const& arg4) {
2542 Unwrapper unwrapper(v, arg1);
2543 return apply(unwrapper, arg2, arg3, arg4);
2546 template <
typename Visitor,
typename V1,
typename V2,
typename V3,
typename V4,
typename V5>
2547 static R apply(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3, V4
const& arg4, V5
const& arg5) {
2549 Unwrapper unwrapper(v, arg1);
2550 return apply(unwrapper, arg2, arg3, arg4, arg5);
2556 #if variant_CPP11_OR_GREATER
2557 template <
size_t NumVars,
typename Visitor,
typename... V>
struct VisitorImpl {
2558 typedef decltype(std::declval<Visitor>()(get<0>(
static_cast<const V&
>(std::declval<V>()))...)) result_type;
2564 #if variant_CPP11_OR_GREATER
2566 template <
typename Visitor,
typename... V>
2567 inline auto visit(Visitor
const& v, V
const&... vars) ->
typename detail::VisitorImpl<
sizeof...(V), Visitor, V...>::result_type {
2568 typedef detail::VisitorImpl<
sizeof...(V), Visitor, V...> impl_type;
2569 return impl_type::applicator_type::apply(v, vars...);
2573 template <
typename R,
typename Visitor,
typename V1>
inline R visit(
const Visitor& v, V1
const& arg1) {
2574 return detail::VisitorApplicator<R>::apply(v, arg1);
2577 template <
typename R,
typename Visitor,
typename V1,
typename V2>
inline R visit(
const Visitor& v, V1
const& arg1, V2
const& arg2) {
2578 return detail::VisitorApplicator<R>::apply(v, arg1, arg2);
2581 template <
typename R,
typename Visitor,
typename V1,
typename V2,
typename V3>
2582 inline R visit(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3) {
2583 return detail::VisitorApplicator<R>::apply(v, arg1, arg2, arg3);
2586 template <
typename R,
typename Visitor,
typename V1,
typename V2,
typename V3,
typename V4>
2587 inline R visit(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3, V4
const& arg4) {
2588 return detail::VisitorApplicator<R>::apply(v, arg1, arg2, arg3, arg4);
2591 template <
typename R,
typename Visitor,
typename V1,
typename V2,
typename V3,
typename V4,
typename V5>
2592 inline R visit(
const Visitor& v, V1
const& arg1, V2
const& arg2, V3
const& arg3, V4
const& arg4, V5
const& arg5) {
2593 return detail::VisitorApplicator<R>::apply(v, arg1, arg2, arg3, arg4, arg5);
2603 static inline bool equal(Variant
const& v, Variant
const& w) {
2606 return get<0>(v) == get<0>(w);
2608 return get<1>(v) == get<1>(w);
2610 return get<2>(v) == get<2>(w);
2612 return get<3>(v) == get<3>(w);
2614 return get<4>(v) == get<4>(w);
2616 return get<5>(v) == get<5>(w);
2618 return get<6>(v) == get<6>(w);
2620 return get<7>(v) == get<7>(w);
2622 return get<8>(v) == get<8>(w);
2624 return get<9>(v) == get<9>(w);
2626 return get<10>(v) == get<10>(w);
2628 return get<11>(v) == get<11>(w);
2630 return get<12>(v) == get<12>(w);
2632 return get<13>(v) == get<13>(w);
2634 return get<14>(v) == get<14>(w);
2636 return get<15>(v) == get<15>(w);
2643 static inline bool less_than(Variant
const& v, Variant
const& w) {
2646 return get<0>(v) < get<0>(w);
2648 return get<1>(v) < get<1>(w);
2650 return get<2>(v) < get<2>(w);
2652 return get<3>(v) < get<3>(w);
2654 return get<4>(v) < get<4>(w);
2656 return get<5>(v) < get<5>(w);
2658 return get<6>(v) < get<6>(w);
2660 return get<7>(v) < get<7>(w);
2662 return get<8>(v) < get<8>(w);
2664 return get<9>(v) < get<9>(w);
2666 return get<10>(v) < get<10>(w);
2668 return get<11>(v) < get<11>(w);
2670 return get<12>(v) < get<12>(w);
2672 return get<13>(v) < get<13>(w);
2674 return get<14>(v) < get<14>(w);
2676 return get<15>(v) < get<15>(w);
2686 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,
2687 class T12,
class T13,
class T14,
class T15>
2688 inline bool operator==(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const& v,
2689 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const& w) {
2690 if(v.index() != w.index())
2692 else if(v.valueless_by_exception())
2695 return detail::Comparator<variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>::equal(v, w);
2698 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,
2699 class T12,
class T13,
class T14,
class T15>
2700 inline bool operator!=(
variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const& v,
2701 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const& w) {
2705 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,
2706 class T12,
class T13,
class T14,
class T15>
2707 inline bool operator<(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const& v,
2708 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const& w) {
2709 if(w.valueless_by_exception())
2711 else if(v.valueless_by_exception())
2713 else if(v.index() < w.index())
2715 else if(v.index() > w.index())
2718 return detail::Comparator<variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>::less_than(v, w);
2721 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,
2722 class T12,
class T13,
class T14,
class T15>
2723 inline bool operator>(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const& v,
2724 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const& w) {
2728 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,
2729 class T12,
class T13,
class T14,
class T15>
2730 inline bool operator<=(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const& v,
2731 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const& w) {
2735 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,
2736 class T12,
class T13,
class T14,
class T15>
2737 inline bool operator>=(variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const& v,
2738 variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
const& w) {
2744 using namespace variants;
2748 #if variant_CPP11_OR_GREATER
2754 template <>
struct hash<nonstd::monostate> {
2758 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,
2759 class T12,
class T13,
class T14,
class T15>
2760 struct hash<nonstd::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>> {
2762 operator()(
nonstd::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> const& v)
const variant_noexcept {
2763 namespace nvd = nonstd::variants::detail;
2767 return nvd::hash(0) ^ nvd::hash(get<0>(v));
2769 return nvd::hash(1) ^ nvd::hash(get<1>(v));
2771 return nvd::hash(2) ^ nvd::hash(get<2>(v));
2773 return nvd::hash(3) ^ nvd::hash(get<3>(v));
2775 return nvd::hash(4) ^ nvd::hash(get<4>(v));
2777 return nvd::hash(5) ^ nvd::hash(get<5>(v));
2779 return nvd::hash(6) ^ nvd::hash(get<6>(v));
2781 return nvd::hash(7) ^ nvd::hash(get<7>(v));
2783 return nvd::hash(8) ^ nvd::hash(get<8>(v));
2785 return nvd::hash(9) ^ nvd::hash(get<9>(v));
2787 return nvd::hash(10) ^ nvd::hash(get<10>(v));
2789 return nvd::hash(11) ^ nvd::hash(get<11>(v));
2791 return nvd::hash(12) ^ nvd::hash(get<12>(v));
2793 return nvd::hash(13) ^ nvd::hash(get<13>(v));
2795 return nvd::hash(14) ^ nvd::hash(get<14>(v));
2797 return nvd::hash(15) ^ nvd::hash(get<15>(v));
2809 #if variant_BETWEEN(variant_COMPILER_MSVC_VER, 1300, 1900)
2810 #pragma warning(pop)