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?
The context of a lambda is the set of objects that are in scope when the lambda is called. The context objects may be captured then used as part of the lambda's processing. Capturing an object by name makes a lambda-local copy of the object. Capturing an object by reference allows the lambda to manipulate its context.
Copying a lambda will copy its state.
You can use auto
in a new-expression:
new auto ([](){});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With