summaryrefslogtreecommitdiffstats
path: root/src/common/alignment.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/alignment.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h
index 0057052af..fc5c26898 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -12,7 +12,9 @@ namespace Common {
template <typename T>
requires std::is_integral_v<T>
-[[nodiscard]] constexpr T AlignUp(T value, size_t size) {
+[[nodiscard]] constexpr T AlignUp(T value_, size_t size) {
+ using U = typename std::make_unsigned_t<T>;
+ auto value{static_cast<U>(value_)};
auto mod{static_cast<T>(value % size)};
value -= mod;
return static_cast<T>(mod == T{0} ? value : value + size);
@@ -26,7 +28,9 @@ template <typename T>
template <typename T>
requires std::is_integral_v<T>
-[[nodiscard]] constexpr T AlignDown(T value, size_t size) {
+[[nodiscard]] constexpr T AlignDown(T value_, size_t size) {
+ using U = typename std::make_unsigned_t<T>;
+ const auto value{static_cast<U>(value_)};
return static_cast<T>(value - value % size);
}