[llvm] d647578 - [thread] Fix a FIXME with std::apply. NFCI

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 13 09:26:50 PST 2023


Author: Benjamin Kramer
Date: 2023-01-13T18:25:16+01:00
New Revision: d647578726c86f171370af520af1773dce2c4a24

URL: https://github.com/llvm/llvm-project/commit/d647578726c86f171370af520af1773dce2c4a24
DIFF: https://github.com/llvm/llvm-project/commit/d647578726c86f171370af520af1773dce2c4a24.diff

LOG: [thread] Fix a FIXME with std::apply. NFCI

Added: 
    

Modified: 
    llvm/include/llvm/Support/thread.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/thread.h b/llvm/include/llvm/Support/thread.h
index 32599b9f7121..69c06c050aac 100644
--- a/llvm/include/llvm/Support/thread.h
+++ b/llvm/include/llvm/Support/thread.h
@@ -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:


        


More information about the llvm-commits mailing list