diff --git a/include/exiv2/value.hpp b/include/exiv2/value.hpp index 9090d324..2b2c53b4 100644 --- a/include/exiv2/value.hpp +++ b/include/exiv2/value.hpp @@ -1270,16 +1270,28 @@ class ValueType : public Value { } // Check for integer overflow. +#if __cplusplus >= 201703L + if (std::is_signed_v == std::is_signed_v) { +#else if (std::is_signed::value == std::is_signed::value) { +#endif // conversion does not change sign const auto imin = std::numeric_limits::min(); const auto imax = std::numeric_limits::max(); if (imax < b || a < imin || imax < a) { return 0; } +#if __cplusplus >= 201703L + } else if (std::is_signed_v) { +#else } else if (std::is_signed::value) { +#endif // conversion is from unsigned to signed +#if __cplusplus >= 201402L + const auto imax = std::make_unsigned_t(std::numeric_limits::max()); +#else const auto imax = typename std::make_unsigned::type(std::numeric_limits::max()); +#endif if (imax < b || imax < a) { return 0; } @@ -1290,8 +1302,13 @@ class ValueType : public Value { return 0; } // Inputs are not negative so convert them to unsigned. +#if __cplusplus >= 201402L + const auto a_u = std::make_unsigned_t(a); + const auto b_u = std::make_unsigned_t(b); +#else const auto a_u = typename std::make_unsigned::type(a); const auto b_u = typename std::make_unsigned::type(b); +#endif if (imax < b_u || imax < a_u) { return 0; }