From 9dc238187f0c0e45276b2104e4b4ec125c542e0b Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 19 Feb 2021 16:18:09 +0300 Subject: [PATCH] Simplify utils::align() a bit std::is_unsigned implies std::is_integral I believe. --- rpcs3/util/asm.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rpcs3/util/asm.hpp b/rpcs3/util/asm.hpp index d4e15468e2..a31b5c6102 100644 --- a/rpcs3/util/asm.hpp +++ b/rpcs3/util/asm.hpp @@ -366,24 +366,24 @@ namespace utils } // Align to power of 2 - template ::value && std::is_unsigned::value>> - constexpr T align(T value, ullong align) + template >> + constexpr T align(T value, std::type_identity_t align) { - return static_cast((value + (align - 1)) & (0 - align)); + return static_cast((value + (align - 1)) & (T{0} - align)); } // General purpose aligned division, the result is rounded up not truncated - template ::value && std::is_unsigned::value>> + template >> constexpr T aligned_div(T value, std::type_identity_t align) { return static_cast(value / align + T{!!(value % align)}); } // General purpose aligned division, the result is rounded to nearest - template ::value>> + template >> constexpr T rounded_div(T value, std::type_identity_t align) { - if constexpr (std::is_unsigned::value) + if constexpr (std::is_unsigned_v) { return static_cast(value / align + T{(value % align) > (align / 2)}); }