diff --git a/AK/BuiltinWrappers.h b/AK/BuiltinWrappers.h index 81c27d5846..1bfdaa5c97 100644 --- a/AK/BuiltinWrappers.h +++ b/AK/BuiltinWrappers.h @@ -8,6 +8,8 @@ #include "Concepts.h" +namespace AK { + template inline constexpr int popcount(IntType value) { @@ -147,3 +149,14 @@ inline constexpr int bit_scan_forward(IntType value) return 1 + count_trailing_zeroes(static_cast>(value)); #endif } + +} + +#if USING_AK_GLOBALLY +using AK::bit_scan_forward; +using AK::count_leading_zeroes; +using AK::count_leading_zeroes_safe; +using AK::count_trailing_zeroes; +using AK::count_trailing_zeroes_safe; +using AK::popcount; +#endif diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index a862878867..2a1a0d5e06 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -264,7 +264,6 @@ inline NonnullRefPtr make_ref_counted(Args&&... args) { return NonnullRefPtr(NonnullRefPtr::Adopt, *new T { forward(args)... }); } -} template struct Traits> : public GenericTraits> { @@ -274,6 +273,8 @@ struct Traits> : public GenericTraits> { static bool equals(NonnullRefPtr const& a, NonnullRefPtr const& b) { return a.ptr() == b.ptr(); } }; +} + #if USING_AK_GLOBALLY using AK::adopt_ref; using AK::make_ref_counted; diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 9f8a265ed4..02b98cd2c2 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -16,6 +16,8 @@ #include +namespace AK { + template constexpr auto round_up_to_power_of_two(T value, U power_of_two) requires(AK::Detail::IsIntegral && AK::Detail::IsIntegral) @@ -30,21 +32,23 @@ requires(AK::Detail::IsIntegral) return value && !((value) & (value - 1)); } +} + #ifndef AK_DONT_REPLACE_STD namespace std { // NOLINT(cert-dcl58-cpp) Names in std to aid tools // NOTE: These are in the "std" namespace since some compilers and static analyzers rely on it. template -constexpr T&& forward(RemoveReference& param) +constexpr T&& forward(AK::Detail::RemoveReference& param) { return static_cast(param); } template -constexpr T&& forward(RemoveReference&& param) noexcept +constexpr T&& forward(AK::Detail::RemoveReference&& param) noexcept { - static_assert(!IsLvalueReference, "Can't forward an rvalue as an lvalue."); + static_assert(!AK::Detail::IsLvalueReference, "Can't forward an rvalue as an lvalue."); return static_cast(param); } @@ -59,9 +63,17 @@ constexpr T&& move(T& arg) # include #endif +#if !USING_AK_GLOBALLY +namespace AK { +#endif + using std::forward; using std::move; +#if !USING_AK_GLOBALLY +} +#endif + namespace AK::Detail { template struct _RawPtr { @@ -182,10 +194,12 @@ using AK::ceil_div; using AK::clamp; using AK::exchange; using AK::is_constant_evaluated; +using AK::is_power_of_two; using AK::max; using AK::min; using AK::mix; using AK::RawPtr; +using AK::round_up_to_power_of_two; using AK::swap; using AK::to_underlying; #endif