[PATCH] D48349: [ADT] Add llvm::unique_function which is like std::function but supporting move-only closures.

Tim Shen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 21 10:20:13 PDT 2018


timshen added inline comments.


================
Comment at: llvm/include/llvm/ADT/function.h:236
+
+  ReturnT operator()(ParamTs... Params) {
+    void *CallableAddr =
----------------
I think I understand the perfect-forwarding problem better now. Suppose we have the following user code:
    unique_function<void(string)> f(...);
    string a;
    f(a);

Is the string copy-constructed once or twice? I figured that it'd be twice, (1) when calling `operator()`, (2) when calling `CallImpl()`.

Regardless of the solution, can we add a test case for that?


Repository:
  rL LLVM

https://reviews.llvm.org/D48349





More information about the llvm-commits mailing list