是否可以一步一步在堆上创建lambda? [英] Is it possible to create a lambda on the heap in one step?
本文介绍了是否可以一步一步在堆上创建lambda?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以这样创建一个lambda:
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?
推荐答案
您可以使用 auto
在new表达式中:
You can use auto
in a new-expression:
new auto ([](){});
这篇关于是否可以一步一步在堆上创建lambda?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文