// This file is under the public domain. #pragma once #include #include namespace Common { template [[nodiscard]] constexpr T AlignUp(T value, std::size_t size) { static_assert(std::is_unsigned_v, "T must be an unsigned value."); auto mod{value % size}; value -= mod; return static_cast(mod == T{0} ? value : value + size); } template [[nodiscard]] constexpr T AlignDown(T value, std::size_t size) { static_assert(std::is_unsigned_v, "T must be an unsigned value."); return static_cast(value - value % size); } } // namespace Common