Fix applyTuple to work under MSVC again
authorChristopher Dykes <cdykes@fb.com>
Mon, 15 Aug 2016 22:56:35 +0000 (15:56 -0700)
committerFacebook Github Bot 3 <facebook-github-bot-3-bot@fb.com>
Mon, 15 Aug 2016 23:08:27 +0000 (16:08 -0700)
Summary:
Because MSVC didn't like the new version used to add support for multiple tuples.
This also switches to std::index_sequence rather than our own home-grown version.

Reviewed By: yfeldblum

Differential Revision: D3706506

fbshipit-source-id: 724c995fe2671d21f78cd7ffa4b19ea1b278c308

folly/ApplyTuple.h

index 0288f567c2c02ab642ead3c842fddc2b5f6c226b..b22987766702fa4f023ae780abf30e0c55c7d4e9 100644 (file)
@@ -55,9 +55,14 @@ inline constexpr std::size_t sum(std::size_t v1, Args... vs) {
   return v1 + sum(vs...);
 }
 
-template <class... Tuple>
-using MakeIndexSequenceFromTuple = MakeIndexSequence<sum(
-    std::tuple_size<typename std::decay<Tuple>::type>::value...)>;
+template <typename... Tuples>
+struct TupleSizeSum {
+  static constexpr auto value = sum(std::tuple_size<Tuples>::value...);
+};
+
+template <typename... Tuples>
+using MakeIndexSequenceFromTuple = MakeIndexSequence<
+    TupleSizeSum<typename std::decay<Tuples>::type...>::value>;
 
 // This is to allow using this with pointers to member functions,
 // where the first argument in the tuple will be the this pointer.