Is it possible to create a lambda on the heap in one step?

  • A+

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?


You can use auto in a new-expression:

new auto ([](){}); 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: