找不到标头`execution`和`std :: reduce` [英] Header `execution` and `std::reduce` not found

查看:160
本文介绍了找不到标头`execution`和`std :: reduce`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将此代码段进行编译

I am trying to get this snippet to compile

#include <vector>
#include <numeric>
#include <execution>

double result = std::reduce(std::execution::par, v.begin(), v.end());

我尝试了这些编译器:

Apple LLVM version 8.1.0 (clang-802.0.42)

clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)

g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

三个都给我'execution'文件未找到

分别为错误:名称空间"std"中没有名为"reduce"的成员自动结果= std :: reduce(v.begin(),v.end());

此代码段

#include<numeric>
#include<vector>

int main(int argc, char *argv[])
{
    std::vector<double> v(10, 1);

    auto result = std::reduce(v.begin(), v.end());
    return 0;
}

我猜我的编译器太旧了?但是关于cppreference 并没有说最低要求哪个编译器版本,我也这样做在存储库中看不到clang或gcc的任何新版本.

I guess my compilers are too old? But on cppreference it does not say which compiler version is requiered minimum and also I do not see any newer versions for clang or gcc in the repo.

推荐答案

std :: reduce std :: execution :: par 自C ++ 17开始可用

std::reduce and std::execution::par are available since C++17.

对于大多数编译器,C ++ 17尚未完全实现.您可以尝试使用带有 -std = c ++ 1z 标志的clang.

For most of the compilers C++17 isn't fully implemented yet. You can try using clang with flag -std=c++1z.

这篇关于找不到标头`execution`和`std :: reduce`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆