Header `execution` and `std::reduce` not found(找不到标头`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' file not found
分别错误:命名空间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 它并没有说明最低要求哪个编译器版本,我也这样做了在 repo 中看不到任何更新的 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`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:找不到标头`execution`和`std::reduce`
基础教程推荐
- CString 到 char* 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
