c++ - 关于 std::reduce vs2017 中的未知数?

标签 c++ std c++17

我用的是vs2017,在使用reduce函数时:

     auto norm = 1.f / std::reduce(t_, t_ + channels);

标题是:

     #include "numeric"

我得到以下错误:

error   c2039   “reduce”: is not member of std.

但据我所知,在c++17中已经添加了reduce函数。我该怎么办?

最佳答案

你应该使用 #include <numeric>而不是 #include "numeric" <> 用于系统包含,""用于本地 header 。

第二件事是 VS2017 不完全支持 c++17,这就是我猜的问题。 还要确保您已启用 c++17 开关 How to enable C++17 compiling in Visual Studio?

关于c++ - 关于 std::reduce vs2017 中的未知数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52362801/

相关文章:

c++ - 在一个函数中使用类的每个成员来计算平均值

c++ - 通过编写包装器将 RogueWave 替换为标准库

c++ - 编译器与简单元函数的差异

具有函数参数评估的 C++17 参数包扩展

使用 SDL2 和 SDL_image 加载 C++ 图像

c++ - 相同的 C++ 代码,不同的链接选项会导致不同的行为?

c++ - C++终止称为 'std::length_error'?

C++ auto on int16_t 强制转换为整数

c++ - 当我尝试使用读取和写入时,为什么 fstream 无法正常工作?

c++ - 聚合类型是否意味着它也是标准布局?