@@ -1087,7 +1087,7 @@ namespace mpark {
1087
1087
#pragma warning(disable : 4100)
1088
1088
#endif
1089
1089
template <typename Alt>
1090
- inline void operator ()(Alt &alt) const noexcept { alt.~Alt (); }
1090
+ inline constexpr void operator ()(Alt &alt) const noexcept { alt.~Alt (); }
1091
1091
#ifdef _MSC_VER
1092
1092
#pragma warning(pop)
1093
1093
#endif
@@ -1115,11 +1115,11 @@ namespace mpark {
1115
1115
MPARK_INHERITING_CTOR (destructor, super) \
1116
1116
using super::operator =; \
1117
1117
\
1118
- destructor (const destructor &) = default ; \
1119
- destructor (destructor &&) = default ; \
1118
+ constexpr destructor (const destructor &) = default; \
1119
+ constexpr destructor (destructor &&) = default; \
1120
1120
definition \
1121
- destructor &operator =(const destructor &) = default ; \
1122
- destructor &operator =(destructor &&) = default ; \
1121
+ constexpr destructor &operator =(const destructor &) = default ; \
1122
+ constexpr destructor &operator =(destructor &&) = default ; \
1123
1123
\
1124
1124
protected: \
1125
1125
destroy \
@@ -1128,14 +1128,14 @@ namespace mpark {
1128
1128
MPARK_VARIANT_DESTRUCTOR (
1129
1129
Trait::TriviallyAvailable,
1130
1130
~destructor () = default ;,
1131
- inline void destroy () noexcept {
1131
+ constexpr inline void destroy () noexcept {
1132
1132
this ->index_ = static_cast <index_t <Ts...>>(-1 );
1133
1133
});
1134
1134
1135
1135
MPARK_VARIANT_DESTRUCTOR (
1136
1136
Trait::Available,
1137
1137
~destructor () { destroy (); },
1138
- inline void destroy () noexcept {
1138
+ constexpr inline void destroy () noexcept {
1139
1139
if (!this ->valueless_by_exception ()) {
1140
1140
visitation::alt::visit_alt (dtor{}, *this );
1141
1141
}
@@ -1161,22 +1161,22 @@ namespace mpark {
1161
1161
#ifndef MPARK_GENERIC_LAMBDAS
1162
1162
struct ctor {
1163
1163
template <typename LhsAlt, typename RhsAlt>
1164
- inline void operator ()(LhsAlt &lhs_alt, RhsAlt &&rhs_alt) const {
1164
+ inline constexpr void operator ()(LhsAlt &lhs_alt, RhsAlt &&rhs_alt) const {
1165
1165
constructor::construct_alt (lhs_alt,
1166
1166
lib::forward<RhsAlt>(rhs_alt).value );
1167
1167
}
1168
1168
};
1169
1169
#endif
1170
1170
1171
1171
template <std::size_t I, typename T, typename ... Args>
1172
- inline static T &construct_alt (alt<I, T> &a, Args &&... args) {
1172
+ constexpr static T &construct_alt (alt<I, T> &a, Args &&... args) {
1173
1173
auto *result = ::new (static_cast <void *>(lib::addressof (a)))
1174
1174
alt<I, T>(in_place_t {}, lib::forward<Args>(args)...);
1175
1175
return result->value ;
1176
1176
}
1177
1177
1178
1178
template <typename Rhs>
1179
- inline static void generic_construct (constructor &lhs, Rhs &&rhs) {
1179
+ constexpr static void generic_construct (constructor &lhs, Rhs &&rhs) {
1180
1180
lhs.destroy ();
1181
1181
if (!rhs.valueless_by_exception ()) {
1182
1182
visitation::alt::visit_alt_at (
@@ -1200,30 +1200,30 @@ namespace mpark {
1200
1200
template <typename Traits, Trait = Traits::move_constructible_trait>
1201
1201
class move_constructor ;
1202
1202
1203
- #define MPARK_VARIANT_MOVE_CONSTRUCTOR (move_constructible_trait, definition ) \
1204
- template <typename ... Ts> \
1205
- class move_constructor <traits<Ts...>, move_constructible_trait> \
1206
- : public constructor<traits<Ts...>> { \
1207
- using super = constructor<traits<Ts...>>; \
1208
- \
1209
- public: \
1210
- MPARK_INHERITING_CTOR (move_constructor, super) \
1211
- using super::operator =; \
1212
- \
1213
- move_constructor (const move_constructor &) = default ; \
1214
- definition \
1215
- ~move_constructor () = default ; \
1216
- move_constructor &operator =(const move_constructor &) = default ; \
1217
- move_constructor &operator =(move_constructor &&) = default ; \
1203
+ #define MPARK_VARIANT_MOVE_CONSTRUCTOR (move_constructible_trait, definition ) \
1204
+ template <typename ... Ts> \
1205
+ class move_constructor <traits<Ts...>, move_constructible_trait> \
1206
+ : public constructor<traits<Ts...>> { \
1207
+ using super = constructor<traits<Ts...>>; \
1208
+ \
1209
+ public: \
1210
+ MPARK_INHERITING_CTOR (move_constructor, super) \
1211
+ using super::operator =; \
1212
+ \
1213
+ constexpr move_constructor (const move_constructor &) = default; \
1214
+ definition \
1215
+ ~move_constructor () = default ; \
1216
+ constexpr move_constructor &operator =(const move_constructor &) = default ; \
1217
+ constexpr move_constructor &operator =(move_constructor &&) = default ; \
1218
1218
}
1219
1219
1220
1220
MPARK_VARIANT_MOVE_CONSTRUCTOR (
1221
1221
Trait::TriviallyAvailable,
1222
- move_constructor (move_constructor &&that) = default;);
1222
+ constexpr move_constructor (move_constructor &&that) = default;);
1223
1223
1224
1224
MPARK_VARIANT_MOVE_CONSTRUCTOR (
1225
1225
Trait::Available,
1226
- move_constructor (move_constructor &&that) noexcept (
1226
+ constexpr move_constructor (move_constructor &&that) noexcept (
1227
1227
lib::all<std::is_nothrow_move_constructible<Ts>::value...>::value)
1228
1228
: move_constructor(valueless_t {}) {
1229
1229
this ->generic_construct (*this , lib::move (that));
@@ -1238,30 +1238,30 @@ namespace mpark {
1238
1238
template <typename Traits, Trait = Traits::copy_constructible_trait>
1239
1239
class copy_constructor ;
1240
1240
1241
- #define MPARK_VARIANT_COPY_CONSTRUCTOR (copy_constructible_trait, definition ) \
1242
- template <typename ... Ts> \
1243
- class copy_constructor <traits<Ts...>, copy_constructible_trait> \
1244
- : public move_constructor<traits<Ts...>> { \
1245
- using super = move_constructor<traits<Ts...>>; \
1246
- \
1247
- public: \
1248
- MPARK_INHERITING_CTOR (copy_constructor, super) \
1249
- using super::operator =; \
1250
- \
1251
- definition \
1252
- copy_constructor (copy_constructor &&) = default ; \
1253
- ~copy_constructor () = default ; \
1254
- copy_constructor &operator =(const copy_constructor &) = default ; \
1255
- copy_constructor &operator =(copy_constructor &&) = default ; \
1241
+ #define MPARK_VARIANT_COPY_CONSTRUCTOR (copy_constructible_trait, definition ) \
1242
+ template <typename ... Ts> \
1243
+ class copy_constructor <traits<Ts...>, copy_constructible_trait> \
1244
+ : public move_constructor<traits<Ts...>> { \
1245
+ using super = move_constructor<traits<Ts...>>; \
1246
+ \
1247
+ public: \
1248
+ MPARK_INHERITING_CTOR (copy_constructor, super) \
1249
+ using super::operator =; \
1250
+ \
1251
+ definition \
1252
+ constexpr copy_constructor (copy_constructor &&) = default; \
1253
+ ~copy_constructor () = default ; \
1254
+ constexpr copy_constructor &operator =(const copy_constructor &) = default ; \
1255
+ constexpr copy_constructor &operator =(copy_constructor &&) = default ; \
1256
1256
}
1257
1257
1258
1258
MPARK_VARIANT_COPY_CONSTRUCTOR (
1259
1259
Trait::TriviallyAvailable,
1260
- copy_constructor (const copy_constructor &that) = default;);
1260
+ constexpr copy_constructor (const copy_constructor &that) = default;);
1261
1261
1262
1262
MPARK_VARIANT_COPY_CONSTRUCTOR (
1263
1263
Trait::Available,
1264
- copy_constructor (const copy_constructor &that)
1264
+ constexpr copy_constructor (const copy_constructor &that)
1265
1265
: copy_constructor(valueless_t {}) {
1266
1266
this ->generic_construct (*this , that);
1267
1267
});
@@ -1281,7 +1281,7 @@ namespace mpark {
1281
1281
using super::operator =;
1282
1282
1283
1283
template <std::size_t I, typename ... Args>
1284
- inline /* auto & */ auto emplace (Args &&... args)
1284
+ constexpr /* auto & */ auto emplace (Args &&... args)
1285
1285
-> decltype(this ->construct_alt (access::base::get_alt<I>(*this ),
1286
1286
lib::forward<Args>(args)...)) {
1287
1287
this ->destroy ();
@@ -1296,15 +1296,15 @@ namespace mpark {
1296
1296
template <typename That>
1297
1297
struct assigner {
1298
1298
template <typename ThisAlt, typename ThatAlt>
1299
- inline void operator ()(ThisAlt &this_alt, ThatAlt &&that_alt) const {
1299
+ constexpr void operator ()(ThisAlt &this_alt, ThatAlt &&that_alt) const {
1300
1300
self->assign_alt (this_alt, lib::forward<ThatAlt>(that_alt).value );
1301
1301
}
1302
1302
assignment *self;
1303
1303
};
1304
1304
#endif
1305
1305
1306
1306
template <std::size_t I, typename T, typename Arg>
1307
- inline void assign_alt (alt<I, T> &a, Arg &&arg) {
1307
+ constexpr void assign_alt (alt<I, T> &a, Arg &&arg) {
1308
1308
if (this ->index () == I) {
1309
1309
#ifdef _MSC_VER
1310
1310
#pragma warning(push)
@@ -1332,7 +1332,7 @@ namespace mpark {
1332
1332
}
1333
1333
1334
1334
template <typename That>
1335
- inline void generic_assign (That &&that) {
1335
+ inline constexpr void generic_assign (That &&that) {
1336
1336
if (this ->valueless_by_exception () && that.valueless_by_exception ()) {
1337
1337
// do nothing.
1338
1338
} else if (that.valueless_by_exception ()) {
@@ -1447,12 +1447,12 @@ namespace mpark {
1447
1447
impl &operator =(impl &&) = default ;
1448
1448
1449
1449
template <std::size_t I, typename Arg>
1450
- inline void assign (Arg &&arg) {
1450
+ inline constexpr void assign (Arg &&arg) {
1451
1451
this ->assign_alt (access::base::get_alt<I>(*this ),
1452
1452
lib::forward<Arg>(arg));
1453
1453
}
1454
1454
1455
- inline void swap (impl &that) {
1455
+ inline constexpr void swap (impl &that) {
1456
1456
if (this ->valueless_by_exception () && that.valueless_by_exception ()) {
1457
1457
// do nothing.
1458
1458
} else if (this ->index () == that.index ()) {
@@ -1499,7 +1499,7 @@ namespace mpark {
1499
1499
#ifndef MPARK_GENERIC_LAMBDAS
1500
1500
struct swapper {
1501
1501
template <typename ThisAlt, typename ThatAlt>
1502
- inline void operator ()(ThisAlt &this_alt, ThatAlt &that_alt) const {
1502
+ inline constexpr void operator ()(ThisAlt &this_alt, ThatAlt &that_alt) const {
1503
1503
using std::swap;
1504
1504
swap (this_alt.value , that_alt.value );
1505
1505
}
@@ -1705,7 +1705,7 @@ namespace mpark {
1705
1705
lib::enable_if_t <(std::is_assignable<T &, Arg>::value &&
1706
1706
std::is_constructible<T, Arg>::value),
1707
1707
int > = 0 >
1708
- inline variant &operator =(Arg &&arg) noexcept (
1708
+ inline constexpr variant &operator =(Arg &&arg) noexcept (
1709
1709
(std::is_nothrow_assignable<T &, Arg>::value &&
1710
1710
std::is_nothrow_constructible<T, Arg>::value)) {
1711
1711
impl_.template assign <I>(lib::forward<Arg>(arg));
@@ -1717,7 +1717,7 @@ namespace mpark {
1717
1717
typename ... Args,
1718
1718
typename T = lib::type_pack_element_t <I, Ts...>,
1719
1719
lib::enable_if_t <std::is_constructible<T, Args...>::value, int > = 0 >
1720
- inline T &emplace (Args &&... args) {
1720
+ inline constexpr T &emplace (Args &&... args) {
1721
1721
return impl_.template emplace <I>(lib::forward<Args>(args)...);
1722
1722
}
1723
1723
@@ -1730,7 +1730,7 @@ namespace mpark {
1730
1730
std::initializer_list<Up> &,
1731
1731
Args...>::value,
1732
1732
int > = 0 >
1733
- inline T &emplace (std::initializer_list<Up> il, Args &&... args) {
1733
+ inline constexpr T &emplace (std::initializer_list<Up> il, Args &&... args) {
1734
1734
return impl_.template emplace <I>(il, lib::forward<Args>(args)...);
1735
1735
}
1736
1736
@@ -1739,7 +1739,7 @@ namespace mpark {
1739
1739
typename ... Args,
1740
1740
std::size_t I = detail::find_index_sfinae<T, Ts...>::value,
1741
1741
lib::enable_if_t <std::is_constructible<T, Args...>::value, int > = 0 >
1742
- inline T &emplace (Args &&... args) {
1742
+ inline constexpr T &emplace (Args &&... args) {
1743
1743
return impl_.template emplace <I>(lib::forward<Args>(args)...);
1744
1744
}
1745
1745
@@ -1752,7 +1752,7 @@ namespace mpark {
1752
1752
std::initializer_list<Up> &,
1753
1753
Args...>::value,
1754
1754
int > = 0 >
1755
- inline T &emplace (std::initializer_list<Up> il, Args &&... args) {
1755
+ inline constexpr T &emplace (std::initializer_list<Up> il, Args &&... args) {
1756
1756
return impl_.template emplace <I>(il, lib::forward<Args>(args)...);
1757
1757
}
1758
1758
@@ -1772,7 +1772,7 @@ namespace mpark {
1772
1772
lib::dependent_type<lib::is_swappable<Ts>,
1773
1773
Dummy>::value)...>::value,
1774
1774
int > = 0 >
1775
- inline void swap (variant &that) noexcept (
1775
+ inline constexpr void swap (variant &that) noexcept (
1776
1776
lib::all<(std::is_nothrow_move_constructible<Ts>::value &&
1777
1777
lib::is_nothrow_swappable<Ts>::value)...>::value) {
1778
1778
impl_.swap (that.impl_ );
@@ -2093,7 +2093,7 @@ namespace mpark {
2093
2093
#endif
2094
2094
2095
2095
template <typename ... Ts>
2096
- inline auto swap (variant<Ts...> &lhs,
2096
+ inline constexpr auto swap (variant<Ts...> &lhs,
2097
2097
variant<Ts...> &rhs) noexcept (noexcept (lhs.swap(rhs)))
2098
2098
-> decltype(lhs.swap(rhs)) {
2099
2099
lhs.swap (rhs);
@@ -2147,7 +2147,7 @@ namespace std {
2147
2147
using argument_type = mpark::variant<Ts...>;
2148
2148
using result_type = std::size_t ;
2149
2149
2150
- inline result_type operator ()(const argument_type &v) const {
2150
+ inline constexpr result_type operator ()(const argument_type &v) const {
2151
2151
using mpark::detail::visitation::variant;
2152
2152
std::size_t result =
2153
2153
v.valueless_by_exception ()
@@ -2172,7 +2172,7 @@ namespace std {
2172
2172
#ifndef MPARK_GENERIC_LAMBDAS
2173
2173
struct hasher {
2174
2174
template <typename Alt>
2175
- inline std::size_t operator ()(const Alt &alt) const {
2175
+ inline constexpr std::size_t operator ()(const Alt &alt) const {
2176
2176
using alt_type = mpark::lib::decay_t <Alt>;
2177
2177
using value_type =
2178
2178
mpark::lib::remove_const_t <typename alt_type::value_type>;
@@ -2191,7 +2191,7 @@ namespace std {
2191
2191
using argument_type = mpark::monostate;
2192
2192
using result_type = std::size_t ;
2193
2193
2194
- inline result_type operator ()(const argument_type &) const noexcept {
2194
+ inline constexpr result_type operator ()(const argument_type &) const noexcept {
2195
2195
return 66740831 ; // return a fundamentally attractive random value.
2196
2196
}
2197
2197
};
0 commit comments