C++ compiler support for std::execution (parallel STL algorithms)

Viewed 1154

I wanted to use the parallel version of std::sort where I can specify an execution policy like std::execution::par_unseq.

I'm currently using clang++-10 and g++ 7.5.0 under Ubuntu Linux, but both don't find the required include file execution, so apparently the parallel algorithm is not yet supported in these compiler versions.

Can someone please tell me which version of clang and gcc would support this feature?

1 Answers

C++17 execution policies are supported by GCC 10 and Clang 11.

Here is a demo example https://gcc.godbolt.org/z/xahs5x1Kx

#include <execution>

int main()
{
    int a[] = {2,1};
    std::sort(std::execution::par_unseq, std::begin(a), std::end(a) );
    return a[0];
}
Related