问题
We can create a lambda like this:
auto x = [](){};
I can create a copy of this on the heap like this:
auto y = new decltype(x)(x);
The question is, is it possible to do this in one step? Creating a lambda on the heap without extra steps?
回答1:
You can use auto
in a new-expression:
new auto ([](){});
来源:https://stackoverflow.com/questions/51839698/is-it-possible-to-create-a-lambda-on-the-heap-in-one-step