diff --git a/include/support.h b/include/support.h index 6c4bc62a..364a8385 100644 --- a/include/support.h +++ b/include/support.h @@ -39,17 +39,19 @@ std::string get_basename(const std::string& filename); // Unsigned-only integer division with ceiling -template::value>::type, - typename T2, class = typename std::enable_if::value>::type> -inline const T1 ceil_udivide(const T1 x, const T2 y) noexcept { +template +inline constexpr T1 ceil_udivide(const T1 x, const T2 y) noexcept { + static_assert(std::is_unsigned::value, "First parameter should be unsigned"); + static_assert(std::is_unsigned::value, "Second parameter should be unsigned"); return (x != 0) ? 1 + ((x - 1) / y) : 0; // https://stackoverflow.com/a/2745086 } // Signed-only integer division with ceiling -template::value>::type, - typename T2, class = typename std::enable_if::value>::type> -inline const T1 ceil_sdivide(const T1 x, const T2 y) noexcept { +template +inline constexpr T1 ceil_sdivide(const T1 x, const T2 y) noexcept { + static_assert(std::is_signed::value, "First parameter should be signed"); + static_assert(std::is_signed::value, "Second parameter should be signed."); return x / y + (((x < 0) ^ (y > 0)) && (x % y)); // https://stackoverflow.com/a/33790603 }