From b5b92fd1e5f44634ccccc8e0526cd725dfd81f34 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 8 Feb 2021 18:01:19 -0800 Subject: common: alignment: Add DivideUp utility method. --- src/common/alignment.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/alignment.h b/src/common/alignment.h index fb81f10d8..32d796ffa 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h @@ -42,6 +42,11 @@ requires std::is_integral_v[[nodiscard]] constexpr bool IsAligned(T value, si return (value & mask) == 0; } +template +requires std::is_integral_v[[nodiscard]] constexpr T DivideUp(T x, U y) { + return (x + (y - 1)) / y; +} + template class AlignmentAllocator { public: -- cgit v1.2.3