diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-12-13 00:06:11 +0330 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-12-13 08:09:56 +0330 |
commit | ad120606fdcaf99ebe03bb83a4b31670696eaa2c (patch) | |
tree | 7cd3014ee2e3540dbc5a228f779cc7d8aa40e9d1 | |
parent | 483c18437b1e9c8bd2903726ba782c732eee440d (diff) | |
download | serenity-ad120606fdcaf99ebe03bb83a4b31670696eaa2c.zip |
AK: Fix build with !USING_AK_GLOBALLY
A couple headers expected names to be in the global namespace, qualify
those names to make sure they're resolved even when the names are not
exported.
One header placed its functions in the global namespace, move those to
the AK namespace to make the concepts resolve.
-rw-r--r-- | AK/BuiltinWrappers.h | 13 | ||||
-rw-r--r-- | AK/NonnullRefPtr.h | 3 | ||||
-rw-r--r-- | AK/StdLibExtras.h | 20 |
3 files changed, 32 insertions, 4 deletions
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<Unsigned IntType> 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<MakeUnsigned<IntType>>(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<T> make_ref_counted(Args&&... args) { return NonnullRefPtr<T>(NonnullRefPtr<T>::Adopt, *new T { forward<Args>(args)... }); } -} template<typename T> struct Traits<NonnullRefPtr<T>> : public GenericTraits<NonnullRefPtr<T>> { @@ -274,6 +273,8 @@ struct Traits<NonnullRefPtr<T>> : public GenericTraits<NonnullRefPtr<T>> { static bool equals(NonnullRefPtr<T> const& a, NonnullRefPtr<T> 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 <AK/Assertions.h> +namespace AK { + template<typename T, typename U> constexpr auto round_up_to_power_of_two(T value, U power_of_two) requires(AK::Detail::IsIntegral<T> && AK::Detail::IsIntegral<U>) @@ -30,21 +32,23 @@ requires(AK::Detail::IsIntegral<T>) 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<typename T> -constexpr T&& forward(RemoveReference<T>& param) +constexpr T&& forward(AK::Detail::RemoveReference<T>& param) { return static_cast<T&&>(param); } template<typename T> -constexpr T&& forward(RemoveReference<T>&& param) noexcept +constexpr T&& forward(AK::Detail::RemoveReference<T>&& param) noexcept { - static_assert(!IsLvalueReference<T>, "Can't forward an rvalue as an lvalue."); + static_assert(!AK::Detail::IsLvalueReference<T>, "Can't forward an rvalue as an lvalue."); return static_cast<T&&>(param); } @@ -59,9 +63,17 @@ constexpr T&& move(T& arg) # include <utility> #endif +#if !USING_AK_GLOBALLY +namespace AK { +#endif + using std::forward; using std::move; +#if !USING_AK_GLOBALLY +} +#endif + namespace AK::Detail { template<typename T> 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 |