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

依然范特西╮ 提交于 2019-12-04 09:58:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!