IS STD ::功能与使用自动一样有效
Is std::function as efficient as using auto?
说我有一个我想定义的lambda。我可以这样做,
auto foo = [] (int x)
{
return x == 42;
};
或这个,
std::function<bool(int)> foo = [] (int x)
{
return x == 42;
};
对第二次进行罚款吗?std::function
是否应该谨慎?我不经常使用它;仅在进行递归时。
使用std :: function确实会遇到成本,以便对此成本进行良好的讨论。
相关文章:
- 欧拉项目#8答案是大以获得有效答案
- 调整大小后指向元素值的指针unordered_map有效?
- 为什么是0;C++中的有效语句
- 最高有效数字侧的第N位
- GCC对可能有效的代码抛出init list生存期警告
- 有效地使用std::unordered_map来插入或增加键的值
- c++中O(n^(1/3))中一个数的除数的有效计数
- 使用无符号字符数组有效存储内存
- 自定义先决条件对移动分配运算符有效吗
- 为什么将值返回函数传递给重载=运算符对运算符函数有效,而对其他运算符无效
- 如何将不同的可执行文件合并到一个窗口框架中进行编码?像浏览器一样
- 有哪些有效的方法可以消除一组 100 万个字符串>重复数据?
- 为什么这种直接初始化有效?(C++17)
- 递归函数有效,但无法记忆
- 为什么在C++中对链表这样做?(像堆叠一样处理它们)
- 在C++中初始化向量映射的最有效方法
- 使用类型推断声明变量是否与"classical way"变量名称后用括号初始化变量一样有效?
- IS STD ::功能与使用自动一样有效
- 为什么CIN像Cin.getline一样有效?
- 使用 getchar() 输入字符的最有效方法,就像 cin 中没有换行符和空格字符一样C++