mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 20:55:35 +03:00
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.
This commit is contained in:
parent
8f22af087e
commit
eae14f4ba6
Notes:
sideshowbarker
2024-07-18 17:13:04 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/eae14f4ba64 Pull-request: https://github.com/SerenityOS/serenity/pull/7557 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg
@ -10,7 +10,8 @@
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
|
||||
constexpr unsigned round_up_to_power_of_two(unsigned value, unsigned power_of_two)
|
||||
template<typename T, typename U>
|
||||
constexpr auto round_up_to_power_of_two(T value, U power_of_two) requires(IsIntegral<T>&& IsIntegral<U>)
|
||||
{
|
||||
return ((value - 1) & ~(power_of_two - 1)) + power_of_two;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user