// This file is under the public domain. #pragma once #include #include namespace Common { template 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 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