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);
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)>
1359 variant(T0
const& t0)
1364 template <variant_index_tag_t(1) = variant_index_tag(1) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 1>::value)>
1365 variant(T1
const& t1)
1370 template <variant_index_tag_t(2) = variant_index_tag(2) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 2>::value)>
1371 variant(T2
const& t2)
1376 template <variant_index_tag_t(3) = variant_index_tag(3) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 3>::value)>
1377 variant(T3
const& t3)
1382 template <variant_index_tag_t(4) = variant_index_tag(4) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 4>::value)>
1383 variant(T4
const& t4)
1388 template <variant_index_tag_t(5) = variant_index_tag(5) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 5>::value)>
1389 variant(T5
const& t5)
1394 template <variant_index_tag_t(6) = variant_index_tag(6) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 6>::value)>
1395 variant(T6
const& t6)
1400 template <variant_index_tag_t(7) = variant_index_tag(7) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 7>::value)>
1401 variant(T7
const& t7)
1406 template <variant_index_tag_t(8) = variant_index_tag(8) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 8>::value)>
1407 variant(T8
const& t8)
1412 template <variant_index_tag_t(9) = variant_index_tag(9) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 9>::value)>
1413 variant(T9
const& t9)
1418 template <variant_index_tag_t(10) = variant_index_tag(10) variant_REQUIRES_B(detail::typelist_type_is_unique<variant_types, 10>::value)>
1419 variant(T10
const& t10)
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)>
1425 variant(T11
const& t11)
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)>
1431 variant(T12
const& t12)
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)>
1437 variant(T13
const& t13)
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)>
1443 variant(T14
const& t14)
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)>
1449 variant(T15
const& t15)
1451 new(ptr()) T15(t15);
1456 variant(T0
const& t0)
1460 variant(T1
const& t1)
1464 variant(T2
const& t2)
1468 variant(T3
const& t3)
1472 variant(T4
const& t4)
1476 variant(T5
const& t5)
1480 variant(T6
const& t6)
1484 variant(T7
const& t7)
1488 variant(T8
const& t8)
1492 variant(T9
const& t9)
1496 variant(T10
const& t10)
1498 new(ptr()) T10(t10);
1500 variant(T11
const& t11)
1502 new(ptr()) T11(t11);
1504 variant(T12
const& t12)
1506 new(ptr()) T12(t12);
1508 variant(T13
const& t13)
1510 new(ptr()) T13(t13);
1512 variant(T14
const& t14)
1514 new(ptr()) T14(t14);
1516 variant(T15
const& t15)
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));
1621 variant(variant
const& other)
1622 : type_index(other.type_index) {
1623 (void)helper_type::copy_construct(other.type_index, other.ptr(), ptr());
1626#if variant_CPP11_OR_GREATER
1628 variant(variant&& other)
noexcept(
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
1684 variant& operator=(variant&& other)
noexcept(
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)>
1697 variant& operator=(T0&& t0) {
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)>
1702 variant& operator=(T1&& t1) {
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)>
1707 variant& operator=(T2&& t2) {
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)>
1712 variant& operator=(T3&& t3) {
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)>
1717 variant& operator=(T4&& t4) {
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)>
1722 variant& operator=(T5&& t5) {
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)>
1727 variant& operator=(T6&& t6) {
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)>
1732 variant& operator=(T7&& t7) {
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)>
1737 variant& operator=(T8&& t8) {
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)>
1742 variant& operator=(T9&& t9) {
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)
1888 variant_REQUIRES_T(detail::typelist_contains_unique_type<variant_types, T>::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)
1899 variant_REQUIRES_T(detail::typelist_contains_unique_type<variant_types, T>::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(); }
1927 void swap(variant& other)
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); }
2019 variant& copy_assign(variant
const& other) {
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
2037 variant& move_assign(variant&& other) {
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;