Environment:
This is the code:
#include <numeric>
...
auto g = std::gcd(10, 4);
...
I have turned on the -std=c++17
option in the compiling command:
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
Then I got the error:
error: 'gcd' is not a member of 'std'
From this webpage, std::gcd
is introduced since C++17.
From this webpage, my version of g++ supports C++17.
But why is there still an error? The same code compiles without any error in Visual Studio 2017.
std::gcd
is available from GCC 7.1 onwards only.
From Table 1.5. C++ 2017 Implementation Status
See conformance viewer for multiple GCC versions.