diff --git a/include/exiv2/types.hpp b/include/exiv2/types.hpp index 410a0cdc..b8130b48 100644 --- a/include/exiv2/types.hpp +++ b/include/exiv2/types.hpp @@ -506,45 +506,6 @@ T stringTo(const std::string& s, bool& ok) { template <> bool stringTo(const std::string& s, bool& ok); -/*! - @brief Return the greatest common denominator of n and m. - (Implementation from Boost rational.hpp) - - @note We use n and m as temporaries in this function, so there is no - value in using const IntType& as we would only need to make a copy - anyway... - */ -template -IntType gcd(IntType n, IntType m) { - // Avoid repeated construction - IntType zero(0); - - // This is abs() - given the existence of broken compilers with Koenig - // lookup issues and other problems, I code this explicitly. (Remember, - // IntType may be a user-defined type). - if (n < zero) { - if (n == std::numeric_limits::min()) { - n = std::numeric_limits::max(); - } else { - n = -n; - } - } - if (m < zero) - m = -m; - - // As n and m are now positive, we can be sure that %= returns a - // positive value (the standard guarantees this for built-in types, - // and we require it of user-defined types). - for (;;) { - if (m == zero) - return n; - n %= m; - if (n == zero) - return m; - m %= n; - } -} - } // namespace Exiv2 #endif // #ifndef TYPES_HPP_ diff --git a/src/tags_int.cpp b/src/tags_int.cpp index aa1d1de3..146f8420 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -22,6 +22,7 @@ #include #include +#include // ***************************************************************************** // local declarations @@ -2807,7 +2808,7 @@ std::ostream& print0x9204(std::ostream& os, const Value& value, const ExifData*) } else if (bias.second <= 0) { os << "(" << bias.first << "/" << bias.second << ")"; } else { - int32_t d = gcd(bias.first, bias.second); + int32_t d = std::gcd(bias.first, bias.second); int32_t num = std::abs(bias.first) / d; int32_t den = bias.second / d; os << (bias.first < 0 ? "-" : "+") << num; diff --git a/src/types.cpp b/src/types.cpp index 34d46613..78b3610c 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -629,7 +630,7 @@ Rational floatToRationalCast(float f) { den = 10000; } const auto nom = static_cast(std::round(d * den)); - const int32_t g = gcd(nom, den); + const int32_t g = std::gcd(nom, den); return {nom / g, den / g}; }