about summary refs log tree commit diff
path: root/absl/types/internal/variant.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-07-09T14·37-0700
committerMatt Calabrese <calabrese@google.com>2019-07-10T14·42+0000
commit44efe96dfca674a17b45ca53fc77fb69f1e29bf4 (patch)
tree535a4285b21f34061af5e73eadc4c675c86592e3 /absl/types/internal/variant.h
parent3c98fcc0461bd2a4b9c149d4748a7373a225cf4b (diff)
Export of internal Abseil changes.
--
9c4ef32276054fba6a116c01cd4b3fd278f59ece by Andy Soffer <asoffer@google.com>:

Remove support for unused arbitrary-width output in FastUniformBits. Width
should be inferred from the requested return UIntType.

PiperOrigin-RevId: 257189319

--
e3326329d02171a301cc3d6ae617ed448472b728 by Abseil Team <absl-team@google.com>:

Update comments to make clear that absl::Format(std::string *, ...) appends to the provided string.

PiperOrigin-RevId: 257058043

--
e2096b06d714fba3ea2c885d670a42efd872765c by Xiaoyi Zhang <zhangxy@google.com>:

Fix compilation error on MSVC 2017. The root cause seems to be a compiler bug
in VS 2017 about pack expansion with multiple parameter packs, specifically `MakeVisitationMatrixImpl::Run` is triggering compiler error "error C3528: 'BoundIndices': the number of elements in this pack expansion does not match the number of elements in 'EndIndices'".
Work around this issue by using only one parameter pack `CurrIndices` in `MakeVisitationMatrixImpl::Run`.

PiperOrigin-RevId: 257040381

--
9ab75ff27b2513583fffc1233e6568aa96be36f7 by Matt Calabrese <calabrese@google.com>:

Internal change.

PiperOrigin-RevId: 257039041
GitOrigin-RevId: 9c4ef32276054fba6a116c01cd4b3fd278f59ece
Change-Id: I5f708bb03aff93948502394a413260af2a8a273b
Diffstat (limited to 'absl/types/internal/variant.h')
-rw-r--r--absl/types/internal/variant.h48
1 files changed, 30 insertions, 18 deletions
diff --git a/absl/types/internal/variant.h b/absl/types/internal/variant.h
index 85201b4ae1f9..19de2e137593 100644
--- a/absl/types/internal/variant.h
+++ b/absl/types/internal/variant.h
@@ -204,7 +204,7 @@ template <class Op, class... Vs>
 using VisitIndicesResultT = typename VisitIndicesResultImpl<Op, Vs...>::type;
 
 template <class ReturnType, class FunctionObject, class EndIndices,
-          std::size_t... BoundIndices>
+          class BoundIndices>
 struct MakeVisitationMatrix;
 
 template <class ReturnType, class FunctionObject, std::size_t... Indices>
@@ -218,7 +218,7 @@ constexpr ReturnType call_with_indices(FunctionObject&& function) {
 
 template <class ReturnType, class FunctionObject, std::size_t... BoundIndices>
 struct MakeVisitationMatrix<ReturnType, FunctionObject, index_sequence<>,
-                            BoundIndices...> {
+                            index_sequence<BoundIndices...>> {
   using ResultType = ReturnType (*)(FunctionObject&&);
   static constexpr ResultType Run() {
     return &call_with_indices<ReturnType, FunctionObject,
@@ -226,24 +226,34 @@ struct MakeVisitationMatrix<ReturnType, FunctionObject, index_sequence<>,
   }
 };
 
+template <typename Is, std::size_t J>
+struct AppendToIndexSequence;
+
+template <typename Is, std::size_t J>
+using AppendToIndexSequenceT = typename AppendToIndexSequence<Is, J>::type;
+
+template <std::size_t... Is, std::size_t J>
+struct AppendToIndexSequence<index_sequence<Is...>, J> {
+  using type = index_sequence<Is..., J>;
+};
+
 template <class ReturnType, class FunctionObject, class EndIndices,
-          class CurrIndices, std::size_t... BoundIndices>
+          class CurrIndices, class BoundIndices>
 struct MakeVisitationMatrixImpl;
 
-template <class ReturnType, class FunctionObject, std::size_t... EndIndices,
-          std::size_t... CurrIndices, std::size_t... BoundIndices>
-struct MakeVisitationMatrixImpl<
-    ReturnType, FunctionObject, index_sequence<EndIndices...>,
-    index_sequence<CurrIndices...>, BoundIndices...> {
+template <class ReturnType, class FunctionObject, class EndIndices,
+          std::size_t... CurrIndices, class BoundIndices>
+struct MakeVisitationMatrixImpl<ReturnType, FunctionObject, EndIndices,
+                                index_sequence<CurrIndices...>, BoundIndices> {
   using ResultType = SimpleArray<
-      typename MakeVisitationMatrix<ReturnType, FunctionObject,
-                                    index_sequence<EndIndices...>>::ResultType,
+      typename MakeVisitationMatrix<ReturnType, FunctionObject, EndIndices,
+                                    index_sequence<>>::ResultType,
       sizeof...(CurrIndices)>;
 
   static constexpr ResultType Run() {
-    return {{MakeVisitationMatrix<ReturnType, FunctionObject,
-                                  index_sequence<EndIndices...>,
-                                  BoundIndices..., CurrIndices>::Run()...}};
+    return {{MakeVisitationMatrix<
+        ReturnType, FunctionObject, EndIndices,
+        AppendToIndexSequenceT<BoundIndices, CurrIndices>>::Run()...}};
   }
 };
 
@@ -251,10 +261,11 @@ template <class ReturnType, class FunctionObject, std::size_t HeadEndIndex,
           std::size_t... TailEndIndices, std::size_t... BoundIndices>
 struct MakeVisitationMatrix<ReturnType, FunctionObject,
                             index_sequence<HeadEndIndex, TailEndIndices...>,
-                            BoundIndices...>
-    : MakeVisitationMatrixImpl<
-          ReturnType, FunctionObject, index_sequence<TailEndIndices...>,
-          absl::make_index_sequence<HeadEndIndex>, BoundIndices...> {};
+                            index_sequence<BoundIndices...>>
+    : MakeVisitationMatrixImpl<ReturnType, FunctionObject,
+                               index_sequence<TailEndIndices...>,
+                               absl::make_index_sequence<HeadEndIndex>,
+                               index_sequence<BoundIndices...>> {};
 
 struct UnreachableSwitchCase {
   template <class Op>
@@ -423,7 +434,8 @@ struct VisitIndicesFallback {
   static VisitIndicesResultT<Op, SizeT...> Run(Op&& op, SizeT... indices) {
     return AccessSimpleArray(
         MakeVisitationMatrix<VisitIndicesResultT<Op, SizeT...>, Op,
-                             index_sequence<(EndIndices + 1)...>>::Run(),
+                             index_sequence<(EndIndices + 1)...>,
+                             index_sequence<>>::Run(),
         (indices + 1)...)(absl::forward<Op>(op));
   }
 };