在 C++ 中使用 header of <execution> 的问题

Problem with using header of <execution> in c++

我在 windows 10 上安装了 gcc 10.2.0。所以,在这个最新版本的 gcc 中实现了。
问题是当我从以下 link 复制示例代码时:https://docs.w3cub.com/cpp/algorithm/reduce,它说:std::execution 尚未声明。有什么想法吗?

#include <iostream>
#include <chrono>
#include <vector>
#include <numeric>
#include <execution>
 
int main()
{
    std::vector<double> v(10'000'007, 0.5);
 
    {
        auto t1 = std::chrono::high_resolution_clock::now();
        double result = std::accumulate(v.begin(), v.end(), 0.0);
        auto t2 = std::chrono::high_resolution_clock::now();
        std::chrono::duration<double, std::milli> ms = t2 - t1;
        std::cout << std::fixed << "std::accumulate result " << result
                  << " took " << ms.count() << " ms\n";
    }
 
    {
        auto t1 = std::chrono::high_resolution_clock::now();
        double result = std::reduce(std::execution::par, v.begin(), v.end());
        auto t2 = std::chrono::high_resolution_clock::now();
        std::chrono::duration<double, std::milli> ms = t2 - t1;
        std::cout << "std::reduce result "
                  << result << " took " << ms.count() << " ms\n";
    }
}

许多编译器默认使用较旧的 C++ 模式以实现向后兼容性。在设置中启用 C++17 以使用更新的功能。