diff options
| author | Tobias <thm.frey@gmail.com> | 2020-07-12 16:45:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-12 16:45:49 +0200 |
| commit | dec48c55cbc543fa2e817025d486d806a7017026 (patch) | |
| tree | d41257ef294df43612dcec9de2b05f1a2987d689 /src/common | |
| parent | 60eb93ceabfa1b30cac2091921d52b00fa8697f4 (diff) | |
common/alignment: Fix compilation errors (#4303)
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/alignment.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h index f8c49e0797..b37044bb60 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h @@ -11,7 +11,9 @@ namespace Common { template <typename T> constexpr T AlignUp(T value, std::size_t size) { 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> |
