Skip to content

Commit 4febf97

Browse files
committedDec 14, 2016
avoid expensive instantiation of tuple constructor in noexcept
1 parent 6317a0b commit 4febf97

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed
 

‎include/mapbox/variant.hpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,23 @@ struct direct_type<T>
107107

108108
#if __cpp_lib_logical_traits >= 201510L
109109

110+
using std::conjunction;
110111
using std::disjunction;
111112

112113
#else
113114

115+
template <typename...>
116+
struct conjunction : std::true_type {};
117+
118+
template <typename B1>
119+
struct conjunction<B1> : B1 {};
120+
121+
template <typename B1, typename B2>
122+
struct conjunction<B1, B2> : std::conditional<B1::value, B2, B1>::type {};
123+
124+
template <typename B1, typename... Bs>
125+
struct conjunction<B1, Bs...> : std::conditional<B1::value, conjunction<Bs...>, B1>::type {};
126+
114127
template <typename...>
115128
struct disjunction : std::false_type {};
116129

@@ -595,7 +608,8 @@ class variant
595608
helper_type::copy(old.type_index, &old.data, &data);
596609
}
597610

598-
VARIANT_INLINE variant(variant<Types...>&& old) noexcept(std::is_nothrow_move_constructible<types>::value)
611+
VARIANT_INLINE variant(variant<Types...>&& old)
612+
noexcept(detail::conjunction<std::is_nothrow_move_constructible<Types>...>::value)
599613
: type_index(old.type_index)
600614
{
601615
helper_type::move(old.type_index, &old.data, &data);

0 commit comments

Comments
 (0)
Please sign in to comment.