From 2350810f4e28820afaad0174c01254e281f27b85 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sat, 20 Jul 2019 16:14:13 +0300 Subject: [PATCH] [Base] Add typename to sat_add/sub --- src/xenia/base/math.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/xenia/base/math.h b/src/xenia/base/math.h index 06b0b5002..091115d6e 100644 --- a/src/xenia/base/math.h +++ b/src/xenia/base/math.h @@ -303,13 +303,14 @@ int64_t m128_i64(const __m128& v) { uint16_t float_to_half(float value); float half_to_float(uint16_t value); -// http://locklessinc.com/articles/sat_arithmetic/ +// https://locklessinc.com/articles/sat_arithmetic/ template inline T sat_add(T a, T b) { - using TU = std::make_unsigned::type; + using TU = typename std::make_unsigned::type; TU result = TU(a) + TU(b); if (std::is_unsigned::value) { - result |= TU(-static_cast::type>(result < TU(a))); + result |= + TU(-static_cast::type>(result < TU(a))); } else { TU overflowed = (TU(a) >> (sizeof(T) * 8 - 1)) + std::numeric_limits::max(); @@ -321,10 +322,11 @@ inline T sat_add(T a, T b) { } template inline T sat_sub(T a, T b) { - using TU = std::make_unsigned::type; + using TU = typename std::make_unsigned::type; TU result = TU(a) - TU(b); if (std::is_unsigned::value) { - result &= TU(-static_cast::type>(result <= TU(a))); + result &= + TU(-static_cast::type>(result <= TU(a))); } else { TU overflowed = (TU(a) >> (sizeof(T) * 8 - 1)) + std::numeric_limits::max();