Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ gcd不在g+中编译+;5.4.0--';gcd&x27;不是';std&x27;_C++_G++_Std_C++17_Greatest Common Divisor - Fatal编程技术网

C++ gcd不在g+中编译+;5.4.0--';gcd&x27;不是';std&x27;

C++ gcd不在g+中编译+;5.4.0--';gcd&x27;不是';std&x27;,c++,g++,std,c++17,greatest-common-divisor,C++,G++,Std,C++17,Greatest Common Divisor,环境: Ubuntu 16.04 64位 g++版本5.4.0 代码如下: #include <numeric> ... auto g = std::gcd(10, 4); ... 然后我得到了一个错误: 错误:“gcd”不是“std”的成员 从,std::gcd是从C++17开始引入的 从中,我的g++版本支持C++17 但为什么仍然存在错误?同样的代码在Visual Studio 2017中编译时没有任何错误。std::gcd仅从GCC 7.1开始提供 从 请参阅conf

环境:

  • Ubuntu 16.04 64位
  • g++版本5.4.0
代码如下:

#include <numeric>
...
auto g = std::gcd(10, 4);
...
然后我得到了一个错误:

错误:“gcd”不是“std”的成员

从,
std::gcd
是从C++17开始引入的

从中,我的g++版本支持C++17


但为什么仍然存在错误?同样的代码在Visual Studio 2017中编译时没有任何错误。

std::gcd
仅从GCC 7.1开始提供


请参阅conformance viewer以了解更多信息。

您正在查看语言功能页面。你需要看看
g++ -m64 -std=c++17   -c -g -w -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp