简体   繁体   English

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

[英]Is C++ implementation of executor finalized? How to compile it?

I'm trying to use C++ executor.我正在尝试使用 C++ 执行器。 This is the code I found in https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0443r14.html .这是我在https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0443r14.html中找到的代码。 It should be supported by gcc 11. gcc 11应该支持它。

I compiled this code with command我用命令编译了这段代码

g++-11 main.cpp -ltbb
#include <iostream>
#include <execution>
using namespace std::execution;

int main() {
  std::static_thread_pool pool(16);
  executor auto ex = pool.executor();
  perform_business_logic(ex);
  execute(ex, []{ std::cout << "Hello world from the thread pool!"; });
}

It gives a lot of errors.它给出了很多错误。

error: ‘thread_pool’ is not a member of ‘std’
error: ‘executor’ was not declared in this scope
error: ‘ex’ was not declared in this scope

This is just a proposal for addition to the C++ standard.这只是对 C++ 标准的补充建议。 It was never adopted.它从未被采用。

See https://github.com/cplusplus/papers/issues/102 regarding the progress of this proposal which was closed and https://github.com/cplusplus/papers/issues/1054 for the executor proposal which is currently still under consideration for C++26.请参阅https://github.com/cplusplus/papers/issues/102了解该提案的进展,该提案已关闭, https://github.com/cplusplus/papers/issues/1054了解目前仍在进行中的执行人提案考虑 C++26。

Currently there is no equivalent in any C++ revision (published or drafting).目前在任何 C++ 修订版(已发布或起草)中都没有等效的版本。 It is unlikely that you will find a compiler/standard library supporting any of the proposals except maybe as experimental implementations for demonstration.您不太可能找到支持任何提案的编译器/标准库,除非可能作为演示的实验性实现。 In particular I am not sure what you base " It should be supported by gcc 11. " on.特别是我不确定你基于什么“它应该由 gcc 11 支持。 ”。 (The original C++17 tag on the question also doesn't make sense, since the linked proposal is from 2020.) (问题上的原始 C++17 标签也没有意义,因为链接的提案来自 2020 年。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM