Fix CompressedTuple move constructor on MSVC (#637)

pull/638/head
i-do-cpp 5 years ago committed by GitHub
parent a877af1f29
commit b92f35f65f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 39
      absl/container/internal/compressed_tuple.h

@ -169,10 +169,34 @@ constexpr bool ShouldAnyUseBase() {
} }
template <typename T, typename V> template <typename T, typename V>
using TupleMoveConstructible = typename std::conditional< using TupleElementMoveConstructible =
std::is_reference<T>::value, std::is_convertible<V, T>, typename std::conditional<std::is_reference<T>::value,
std::is_convertible<V, T>,
std::is_constructible<T, V&&>>::type; std::is_constructible<T, V&&>>::type;
template <bool SizeMatches, class T, class... Vs>
struct TupleMoveConstructible : std::false_type {};
template <class... Ts, class... Vs>
struct TupleMoveConstructible<true, CompressedTuple<Ts...>, Vs...>
: std::integral_constant<
bool, absl::conjunction<
TupleElementMoveConstructible<Ts, Vs&&>...>::value> {};
template <typename T>
struct compressed_tuple_size;
template <typename... Es>
struct compressed_tuple_size<CompressedTuple<Es...>>
: public std::integral_constant<std::size_t, sizeof...(Es)> {};
template <class T, class... Vs>
struct TupleItemsMoveConstructible
: std::integral_constant<
bool, TupleMoveConstructible<compressed_tuple_size<T>::value ==
sizeof...(Vs),
T, Vs...>::value> {};
} // namespace internal_compressed_tuple } // namespace internal_compressed_tuple
// Helper class to perform the Empty Base Class Optimization. // Helper class to perform the Empty Base Class Optimization.
@ -217,17 +241,18 @@ class ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple
explicit constexpr CompressedTuple(const Ts&... base) explicit constexpr CompressedTuple(const Ts&... base)
: CompressedTuple::CompressedTupleImpl(absl::in_place, base...) {} : CompressedTuple::CompressedTupleImpl(absl::in_place, base...) {}
template <typename... Vs, template <typename First, typename... Vs,
absl::enable_if_t< absl::enable_if_t<
absl::conjunction< absl::conjunction<
// Ensure we are not hiding default copy/move constructors. // Ensure we are not hiding default copy/move constructors.
absl::negation<std::is_same<void(CompressedTuple), absl::negation<std::is_same<void(CompressedTuple),
void(absl::decay_t<Vs>...)>>, void(absl::decay_t<First>)>>,
internal_compressed_tuple::TupleMoveConstructible< internal_compressed_tuple::TupleItemsMoveConstructible<
Ts, Vs&&>...>::value, CompressedTuple<Ts...>, First, Vs...>>::value,
bool> = true> bool> = true>
explicit constexpr CompressedTuple(Vs&&... base) explicit constexpr CompressedTuple(First&& first, Vs&&... base)
: CompressedTuple::CompressedTupleImpl(absl::in_place, : CompressedTuple::CompressedTupleImpl(absl::in_place,
absl::forward<First>(first),
absl::forward<Vs>(base)...) {} absl::forward<Vs>(base)...) {}
template <int I> template <int I>

Loading…
Cancel
Save