@@ -1087,7 +1087,7 @@ namespace mpark {
10871087#pragma warning(disable : 4100)
10881088#endif
10891089 template <typename Alt>
1090- inline void operator ()(Alt &alt) const noexcept { alt.~Alt (); }
1090+ inline constexpr void operator ()(Alt &alt) const noexcept { alt.~Alt (); }
10911091#ifdef _MSC_VER
10921092#pragma warning(pop)
10931093#endif
@@ -1115,11 +1115,11 @@ namespace mpark {
11151115 MPARK_INHERITING_CTOR (destructor, super) \
11161116 using super::operator =; \
11171117 \
1118- destructor (const destructor &) = default ; \
1119- destructor (destructor &&) = default ; \
1118+ constexpr destructor (const destructor &) = default; \
1119+ constexpr destructor (destructor &&) = default; \
11201120 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 ; \
11231123 \
11241124 protected: \
11251125 destroy \
@@ -1128,14 +1128,14 @@ namespace mpark {
11281128 MPARK_VARIANT_DESTRUCTOR (
11291129 Trait::TriviallyAvailable,
11301130 ~destructor () = default ;,
1131- inline void destroy () noexcept {
1131+ constexpr inline void destroy () noexcept {
11321132 this ->index_ = static_cast <index_t <Ts...>>(-1 );
11331133 });
11341134
11351135 MPARK_VARIANT_DESTRUCTOR (
11361136 Trait::Available,
11371137 ~destructor () { destroy (); },
1138- inline void destroy () noexcept {
1138+ constexpr inline void destroy () noexcept {
11391139 if (!this ->valueless_by_exception ()) {
11401140 visitation::alt::visit_alt (dtor{}, *this );
11411141 }
@@ -1161,22 +1161,22 @@ namespace mpark {
11611161#ifndef MPARK_GENERIC_LAMBDAS
11621162 struct ctor {
11631163 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 {
11651165 constructor::construct_alt (lhs_alt,
11661166 lib::forward<RhsAlt>(rhs_alt).value );
11671167 }
11681168 };
11691169#endif
11701170
11711171 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) {
11731173 auto *result = ::new (static_cast <void *>(lib::addressof (a)))
11741174 alt<I, T>(in_place_t {}, lib::forward<Args>(args)...);
11751175 return result->value ;
11761176 }
11771177
11781178 template <typename Rhs>
1179- inline static void generic_construct (constructor &lhs, Rhs &&rhs) {
1179+ constexpr static void generic_construct (constructor &lhs, Rhs &&rhs) {
11801180 lhs.destroy ();
11811181 if (!rhs.valueless_by_exception ()) {
11821182 visitation::alt::visit_alt_at (
@@ -1200,30 +1200,30 @@ namespace mpark {
12001200 template <typename Traits, Trait = Traits::move_constructible_trait>
12011201 class move_constructor ;
12021202
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 ; \
12181218 }
12191219
12201220 MPARK_VARIANT_MOVE_CONSTRUCTOR (
12211221 Trait::TriviallyAvailable,
1222- move_constructor (move_constructor &&that) = default;);
1222+ constexpr move_constructor (move_constructor &&that) = default;);
12231223
12241224 MPARK_VARIANT_MOVE_CONSTRUCTOR (
12251225 Trait::Available,
1226- move_constructor (move_constructor &&that) noexcept (
1226+ constexpr move_constructor (move_constructor &&that) noexcept (
12271227 lib::all<std::is_nothrow_move_constructible<Ts>::value...>::value)
12281228 : move_constructor(valueless_t {}) {
12291229 this ->generic_construct (*this , lib::move (that));
@@ -1238,30 +1238,30 @@ namespace mpark {
12381238 template <typename Traits, Trait = Traits::copy_constructible_trait>
12391239 class copy_constructor ;
12401240
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 ; \
12561256 }
12571257
12581258 MPARK_VARIANT_COPY_CONSTRUCTOR (
12591259 Trait::TriviallyAvailable,
1260- copy_constructor (const copy_constructor &that) = default;);
1260+ constexpr copy_constructor (const copy_constructor &that) = default;);
12611261
12621262 MPARK_VARIANT_COPY_CONSTRUCTOR (
12631263 Trait::Available,
1264- copy_constructor (const copy_constructor &that)
1264+ constexpr copy_constructor (const copy_constructor &that)
12651265 : copy_constructor(valueless_t {}) {
12661266 this ->generic_construct (*this , that);
12671267 });
@@ -1281,7 +1281,7 @@ namespace mpark {
12811281 using super::operator =;
12821282
12831283 template <std::size_t I, typename ... Args>
1284- inline /* auto & */ auto emplace (Args &&... args)
1284+ constexpr /* auto & */ auto emplace (Args &&... args)
12851285 -> decltype(this ->construct_alt (access::base::get_alt<I>(*this ),
12861286 lib::forward<Args>(args)...)) {
12871287 this ->destroy ();
@@ -1296,15 +1296,15 @@ namespace mpark {
12961296 template <typename That>
12971297 struct assigner {
12981298 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 {
13001300 self->assign_alt (this_alt, lib::forward<ThatAlt>(that_alt).value );
13011301 }
13021302 assignment *self;
13031303 };
13041304#endif
13051305
13061306 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) {
13081308 if (this ->index () == I) {
13091309#ifdef _MSC_VER
13101310#pragma warning(push)
@@ -1332,7 +1332,7 @@ namespace mpark {
13321332 }
13331333
13341334 template <typename That>
1335- inline void generic_assign (That &&that) {
1335+ inline constexpr void generic_assign (That &&that) {
13361336 if (this ->valueless_by_exception () && that.valueless_by_exception ()) {
13371337 // do nothing.
13381338 } else if (that.valueless_by_exception ()) {
@@ -1447,12 +1447,12 @@ namespace mpark {
14471447 impl &operator =(impl &&) = default ;
14481448
14491449 template <std::size_t I, typename Arg>
1450- inline void assign (Arg &&arg) {
1450+ inline constexpr void assign (Arg &&arg) {
14511451 this ->assign_alt (access::base::get_alt<I>(*this ),
14521452 lib::forward<Arg>(arg));
14531453 }
14541454
1455- inline void swap (impl &that) {
1455+ inline constexpr void swap (impl &that) {
14561456 if (this ->valueless_by_exception () && that.valueless_by_exception ()) {
14571457 // do nothing.
14581458 } else if (this ->index () == that.index ()) {
@@ -1499,7 +1499,7 @@ namespace mpark {
14991499#ifndef MPARK_GENERIC_LAMBDAS
15001500 struct swapper {
15011501 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 {
15031503 using std::swap;
15041504 swap (this_alt.value , that_alt.value );
15051505 }
@@ -1705,7 +1705,7 @@ namespace mpark {
17051705 lib::enable_if_t <(std::is_assignable<T &, Arg>::value &&
17061706 std::is_constructible<T, Arg>::value),
17071707 int > = 0 >
1708- inline variant &operator =(Arg &&arg) noexcept (
1708+ inline constexpr variant &operator =(Arg &&arg) noexcept (
17091709 (std::is_nothrow_assignable<T &, Arg>::value &&
17101710 std::is_nothrow_constructible<T, Arg>::value)) {
17111711 impl_.template assign <I>(lib::forward<Arg>(arg));
@@ -1717,7 +1717,7 @@ namespace mpark {
17171717 typename ... Args,
17181718 typename T = lib::type_pack_element_t <I, Ts...>,
17191719 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) {
17211721 return impl_.template emplace <I>(lib::forward<Args>(args)...);
17221722 }
17231723
@@ -1730,7 +1730,7 @@ namespace mpark {
17301730 std::initializer_list<Up> &,
17311731 Args...>::value,
17321732 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) {
17341734 return impl_.template emplace <I>(il, lib::forward<Args>(args)...);
17351735 }
17361736
@@ -1739,7 +1739,7 @@ namespace mpark {
17391739 typename ... Args,
17401740 std::size_t I = detail::find_index_sfinae<T, Ts...>::value,
17411741 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) {
17431743 return impl_.template emplace <I>(lib::forward<Args>(args)...);
17441744 }
17451745
@@ -1752,7 +1752,7 @@ namespace mpark {
17521752 std::initializer_list<Up> &,
17531753 Args...>::value,
17541754 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) {
17561756 return impl_.template emplace <I>(il, lib::forward<Args>(args)...);
17571757 }
17581758
@@ -1772,7 +1772,7 @@ namespace mpark {
17721772 lib::dependent_type<lib::is_swappable<Ts>,
17731773 Dummy>::value)...>::value,
17741774 int > = 0 >
1775- inline void swap (variant &that) noexcept (
1775+ inline constexpr void swap (variant &that) noexcept (
17761776 lib::all<(std::is_nothrow_move_constructible<Ts>::value &&
17771777 lib::is_nothrow_swappable<Ts>::value)...>::value) {
17781778 impl_.swap (that.impl_ );
@@ -2093,7 +2093,7 @@ namespace mpark {
20932093#endif
20942094
20952095 template <typename ... Ts>
2096- inline auto swap (variant<Ts...> &lhs,
2096+ inline constexpr auto swap (variant<Ts...> &lhs,
20972097 variant<Ts...> &rhs) noexcept (noexcept (lhs.swap(rhs)))
20982098 -> decltype(lhs.swap(rhs)) {
20992099 lhs.swap (rhs);
@@ -2147,7 +2147,7 @@ namespace std {
21472147 using argument_type = mpark::variant<Ts...>;
21482148 using result_type = std::size_t ;
21492149
2150- inline result_type operator ()(const argument_type &v) const {
2150+ inline constexpr result_type operator ()(const argument_type &v) const {
21512151 using mpark::detail::visitation::variant;
21522152 std::size_t result =
21532153 v.valueless_by_exception ()
@@ -2172,7 +2172,7 @@ namespace std {
21722172#ifndef MPARK_GENERIC_LAMBDAS
21732173 struct hasher {
21742174 template <typename Alt>
2175- inline std::size_t operator ()(const Alt &alt) const {
2175+ inline constexpr std::size_t operator ()(const Alt &alt) const {
21762176 using alt_type = mpark::lib::decay_t <Alt>;
21772177 using value_type =
21782178 mpark::lib::remove_const_t <typename alt_type::value_type>;
@@ -2191,7 +2191,7 @@ namespace std {
21912191 using argument_type = mpark::monostate;
21922192 using result_type = std::size_t ;
21932193
2194- inline result_type operator ()(const argument_type &) const noexcept {
2194+ inline constexpr result_type operator ()(const argument_type &) const noexcept {
21952195 return 66740831 ; // return a fundamentally attractive random value.
21962196 }
21972197 };
0 commit comments