小编Tia*_*Xie的帖子

执行器的 C++ 实现是否已完成?如何编译呢?

我正在尝试使用 C++ 执行器。这是我在https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0443r14.html中找到的代码。gcc 11 应该支持它。

\n

我用命令编译了这段代码

\n
g++-11 main.cpp -ltbb\n
Run Code Online (Sandbox Code Playgroud)\n
#include <iostream>\n#include <execution>\nusing namespace std::execution;\n\nint main() {\n  std::static_thread_pool pool(16);\n  executor auto ex = pool.executor();\n  perform_business_logic(ex);\n  execute(ex, []{ std::cout << "Hello world from the thread pool!"; });\n}\n
Run Code Online (Sandbox Code Playgroud)\n

它给出了很多错误。

\n
error: \xe2\x80\x98thread_pool\xe2\x80\x99 is not a member of \xe2\x80\x98std\xe2\x80\x99\nerror: \xe2\x80\x98executor\xe2\x80\x99 was not declared in this scope\nerror: \xe2\x80\x98ex\xe2\x80\x99 was not declared in this scope\n
Run Code Online (Sandbox Code Playgroud)\n

c++

2
推荐指数
1
解决办法
1139
查看次数

标签 统计

c++ ×1