如何将async与不返回任何内容的lambdas一起使用
How to use async with lambdas which does not return anything?
我在async内部调用了一个简单的lambda。但它给出了一个系统错误。
#include<future>
#include<iostream>
int main()
{
auto a = std::async([]()
{
std::cout << 42 << std::endl;
});
a.get();
return 0;
}
http://ideone.com/GIyGI
编译器:C++0x(gcc-4.5.1)
有什么想法吗?
很可能,您需要使用-pthread
选项进行编译。
相关文章:
- 如何将enable-if与模板参数和参数包一起使用
- 如何将PERF_AMPLE_READ与mmap一起使用
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 如何将C++中的库和头与MinGW一起使用
- 将--whole archive链接器选项与CMake和具有其他库依赖项的库一起使用
- 为什么我不能将 rand() 与数组的大小一起使用?
- 要与"if constexpr"一起使用的编译时消息(在预处理器之后)
- 不能将复制初始化与隐式转换的多个步骤一起使用
- 将fold表达式与std::一起用于两个元组
- spdlog标头仅与外部fmt一起使用.spdlog错误:'内部':不是'fmt'
- 将 std::allocate_shared 与多态资源分配器一起使用
- 为什么在C++20中对lambdas使用"std::bind_front"
- 为什么常量词在重载运算符中不与 ostream 对象一起使用<<?
- 将 OpenCV 与 CMAKE 中的项目一起构建为第三方库的正确方法
- 将 exprtk 与自定义类的对象一起使用
- 将 std::set 与基于键的比较器一起使用
- 使QTConcurrent ::映射与Lambdas一起工作
- 如何将async与不返回任何内容的lambdas一起使用
- 将函子/lambdas与C回调一起使用
- 将SFINAE与通用lambdas一起使用