Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

I'm trying to use C++ executor. This is the code I found in https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0443r14.html. It should be supported by 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
like image 210
Tianyi Xie Avatar asked Oct 18 '25 02:10

Tianyi Xie


1 Answers

This is just a proposal for addition to the C++ standard. 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.

Currently there is no equivalent in any C++ revision (published or drafting). 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. (The original C++17 tag on the question also doesn't make sense, since the linked proposal is from 2020.)

like image 173
user17732522 Avatar answered Oct 20 '25 15:10

user17732522



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!