[thread] Fix a FIXME with std::apply. NFCI
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 13 Jan 2023 17:13:31 +0000 (18:13 +0100)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 13 Jan 2023 17:25:16 +0000 (18:25 +0100)
llvm/include/llvm/Support/thread.h

index 32599b9..69c06c0 100644 (file)
@@ -36,18 +36,13 @@ namespace llvm {
 /// LLVM thread following std::thread interface with added constructor to
 /// specify stack size.
 class thread {
-  template <typename FPtr, typename... Args, size_t... Indices>
-  static void Apply(std::tuple<FPtr, Args...> &Callee,
-                    std::index_sequence<Indices...>) {
-    std::move(std::get<0>(Callee))(std::move(std::get<Indices + 1>(Callee))...);
-  }
-
   template <typename CalleeTuple> static void GenericThreadProxy(void *Ptr) {
     std::unique_ptr<CalleeTuple> Callee(static_cast<CalleeTuple *>(Ptr));
-
-    // FIXME: use std::apply when C++17 is allowed.
-    std::make_index_sequence<std::tuple_size<CalleeTuple>() - 1> Indices{};
-    Apply(*Callee.get(), Indices);
+    std::apply(
+        [](auto &&F, auto &&...Args) {
+          std::forward<decltype(F)>(F)(std::forward<decltype(Args)>(Args)...);
+        },
+        *Callee);
   }
 
 public: