[Parallel_libs-commits] [PATCH] D24473: [SE] Host platform implementation

Justin Lebar via Parallel_libs-commits parallel_libs-commits at lists.llvm.org
Tue Sep 13 10:18:47 PDT 2016


jlebar accepted this revision.
This revision is now accepted and ready to land.

================
Comment at: streamexecutor/include/streamexecutor/KernelSpec.h:273
@@ +272,3 @@
+                                         HostFunctionTy &&Function) {
+    HostFunction = llvm::make_unique<HostFunctionTy>(std::move(Function));
+    return *this;
----------------
The usual convention I've seen is to take the heavyweight, copyable arg (be it an std::function, std::string, std::vector, whatever) that you're taking ownership of by value, rather than by rvalue ref.

You're right that making the function arg an rvalue ref prevents accidental copies.  The problem is that it also makes *intentional* copies a pain.  I think you have to spell out the whole type again:

  std::function<const void*> fn = ...;
  addHostFunction("kernel_name", std::function<const void*>(fn));


https://reviews.llvm.org/D24473





More information about the Parallel_libs-commits mailing list