簡體   English   中英

執行器的 C++ 實現是否已完成? 如何編譯它?

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

我正在嘗試使用 C++ 執行器。 這是我在https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0443r14.html中找到的代碼。 gcc 11應該支持它。

我用命令編譯了這段代碼

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!"; });
}

它給出了很多錯誤。

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

這只是對 C++ 標准的補充建議。 它從未被采用。

請參閱https://github.com/cplusplus/papers/issues/102了解該提案的進展,該提案已關閉, https://github.com/cplusplus/papers/issues/1054了解目前仍在進行中的執行人提案考慮 C++26。

目前在任何 C++ 修訂版(已發布或起草)中都沒有等效的版本。 您不太可能找到支持任何提案的編譯器/標准庫,除非可能作為演示的實驗性實現。 特別是我不確定你基於什么“它應該由 gcc 11 支持。 ”。 (問題上的原始 C++17 標簽也沒有意義,因為鏈接的提案來自 2020 年。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM