]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Remove some uses of std::bind from thread_management.h 8888/head
authorDaniel Arndt <arndtd@ornl.gov>
Sun, 6 Oct 2019 15:48:09 +0000 (11:48 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Sun, 6 Oct 2019 23:57:16 +0000 (19:57 -0400)
include/deal.II/base/thread_management.h

index 35f06ed17a30f618cd8f99771dcc8e5e83d31be8..b482f7fd9b33f1425712af95455c159ea9f2268e 100644 (file)
@@ -21,6 +21,7 @@
 
 #  include <deal.II/base/exceptions.h>
 #  include <deal.II/base/multithread_info.h>
+#  include <deal.II/base/std_cxx17/tuple.h>
 #  include <deal.II/base/template_constraints.h>
 
 #  include <condition_variable>
@@ -1096,8 +1097,9 @@ namespace Threads
   inline Thread<RT>
   new_thread(RT (*fun_ptr)(Args...), typename identity<Args>::type... args)
   {
-    return new_thread(std::function<RT()>(
-      std::bind(fun_ptr, internal::maybe_make_ref<Args>::act(args)...)));
+    auto dummy = std::make_tuple(internal::maybe_make_ref<Args>::act(args)...);
+    return new_thread(
+      [dummy, fun_ptr]() -> RT { return std_cxx17::apply(fun_ptr, dummy); });
   }
 
 
@@ -1753,8 +1755,9 @@ namespace Threads
   inline Task<RT>
   new_task(RT (*fun_ptr)(Args...), typename identity<Args>::type... args)
   {
-    return new_task(std::function<RT()>(
-      std::bind(fun_ptr, internal::maybe_make_ref<Args>::act(args)...)));
+    auto dummy = std::make_tuple(internal::maybe_make_ref<Args>::act(args)...);
+    return new_task(
+      [dummy, fun_ptr]() -> RT { return std_cxx17::apply(fun_ptr, dummy); });
   }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.