我正在尝试使用 C++ 执行器。这是我在https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0443r14.html中找到的代码。gcc 11 应该支持它。
\n我用命令编译了这段代码
\ng++-11 main.cpp -ltbb\nRun 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}\nRun Code Online (Sandbox Code Playgroud)\n它给出了很多错误。
\nerror: \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\nRun Code Online (Sandbox Code Playgroud)\n c++ ×1