Skip to content

Commit

Permalink
[abseil] Fix CompressedTuple move constructor on MSVC (microsoft#10721)
Browse files Browse the repository at this point in the history
* [abseil] Fix CompressedTuple move constructor on MSVC

* [abseil] Add comment for new patch
  • Loading branch information
LilyWangL authored Apr 17, 2020

Verified

This commit was signed with the committer’s verified signature.
jorenham Joren Hammudoglu
1 parent 4d8237b commit 87ebede
Showing 3 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ports/abseil/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: abseil
Version: 2020-03-03-2
Version: 2020-03-03-3
Homepage: https://github.com/abseil/abseil-cpp
Description: an open-source collection designed to augment the C++ standard library.
Abseil is an open-source collection of C++ library code designed to augment the C++ standard library. The Abseil library code is collected from Google's own C++ code base, has been extensively tested and used in production, and is the same code we depend on in our daily coding lives.
65 changes: 65 additions & 0 deletions ports/abseil/fix-MSVCbuildfail.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
diff --git a/absl/container/internal/compressed_tuple.h b/absl/container/internal/compressed_tuple.h
index 4bfe92f..02bfd03 100644
--- a/absl/container/internal/compressed_tuple.h
+++ b/absl/container/internal/compressed_tuple.h
@@ -169,9 +169,33 @@ constexpr bool ShouldAnyUseBase() {
}

template <typename T, typename V>
-using TupleMoveConstructible = typename std::conditional<
- std::is_reference<T>::value, std::is_convertible<V, T>,
- std::is_constructible<T, V&&>>::type;
+using TupleElementMoveConstructible =
+ typename std::conditional<std::is_reference<T>::value,
+ std::is_convertible<V, T>,
+ 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

@@ -217,17 +241,18 @@ class ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple
explicit constexpr CompressedTuple(const Ts&... base)
: CompressedTuple::CompressedTupleImpl(absl::in_place, base...) {}

- template <typename... Vs,
+ template <typename First, typename... Vs,
absl::enable_if_t<
absl::conjunction<
// Ensure we are not hiding default copy/move constructors.
absl::negation<std::is_same<void(CompressedTuple),
- void(absl::decay_t<Vs>...)>>,
- internal_compressed_tuple::TupleMoveConstructible<
- Ts, Vs&&>...>::value,
+ void(absl::decay_t<First>)>>,
+ internal_compressed_tuple::TupleItemsMoveConstructible<
+ CompressedTuple<Ts...>, First, Vs...>>::value,
bool> = true>
- explicit constexpr CompressedTuple(Vs&&... base)
+ explicit constexpr CompressedTuple(First&& first, Vs&&... base)
: CompressedTuple::CompressedTupleImpl(absl::in_place,
+ absl::forward<First>(first),
absl::forward<Vs>(base)...) {}

template <int I>
1 change: 1 addition & 0 deletions ports/abseil/portfile.cmake
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ vcpkg_from_github(
PATCHES
fix-lnk2019-error.patch
fix-uwp-build.patch
fix-MSVCbuildfail.patch #This patch is an upstream commit, the related PR: https://github.com/abseil/abseil-cpp/pull/637
)

set(CMAKE_CXX_STANDARD )

0 comments on commit 87ebede

Please sign in to comment.