common/alignment: Fix compilation errors (#4303)

This commit is contained in:
Tobias 2020-07-12 16:45:49 +02:00 committed by GitHub
parent 6001538139
commit 80a0f2a118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -11,7 +11,9 @@ namespace Common {
template <typename T> template <typename T>
constexpr T AlignUp(T value, std::size_t size) { constexpr T AlignUp(T value, std::size_t size) {
static_assert(std::is_unsigned_v<T>, "T must be an unsigned value."); static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
return static_cast<T>(value + (size - value % size) % size); auto mod{static_cast<T>(value % size)};
value -= mod;
return static_cast<T>(mod == T{0} ? value : value + size);
} }
template <typename T> template <typename T>