I done some research about this. The __gcd function seems to be a private auxiliary function created in the libstdc++ implementation of the algorithm> header's libstdc++ implementation (line 1503). Only the std::rotate function uses it internally (line 1610). It was (likely) never meant to be used outside of the library's implementation. Attempting to use this method with a compiler other than g++ isn't guaranteed to work because it's special to libstdc++. In this respect, the std:: gcd function can be thought of as a (poorly described) internal aid that is only available with certain C++ compilers.

A now-deleted query here originally alerted me to the existence of __gcd, which asked why it handled negative inputs inconsistently. Because the libstdc++ implementation only utilises it when the inputs are nonnegative, it turns out it wasn't actually built to handle negative values. It's one of the drawbacks of utilising an internal helper method that isn't documented!)

std::gcd, on the other hand, is a standard C++ library function added in C++17. This implies that any C++17-compliant compiler will support std::gcd, therefore if you have a C++17-compliant compiler, you should use this option.

You may easily implement your own version GCD function in C++14 or lower. Euclid's algorithm is simple to implement and runs exceedingly rapidly.