From eae14f4ba64889bc6bcee712e266045e9d351bb9 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sat, 29 May 2021 09:18:22 -0600 Subject: [PATCH] AK: Extend round_to_power_of_two to types other than `unsigned` The previous implementation hardcoded unsigned, when the same logic easily extends to unsigned long, signed types, and other Integral types. --- AK/StdLibExtras.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 57e3f5f295..7a48da2ba1 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -10,7 +10,8 @@ #include -constexpr unsigned round_up_to_power_of_two(unsigned value, unsigned power_of_two) +template +constexpr auto round_up_to_power_of_two(T value, U power_of_two) requires(IsIntegral&& IsIntegral) { return ((value - 1) & ~(power_of_two - 1)) + power_of_two; }