diff --git a/AK/Atomic.h b/AK/Atomic.h index ce0a34351d6..2bfe1aaa6ed 100644 --- a/AK/Atomic.h +++ b/AK/Atomic.h @@ -41,7 +41,7 @@ static inline V* atomic_exchange(T volatile** var, V* desired, MemoryOrder order } template> -static inline V* atomic_exchange(T volatile** var, std::nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept +static inline V* atomic_exchange(T volatile** var, nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept { return __atomic_exchange_n(const_cast(var), nullptr, order); } @@ -63,7 +63,7 @@ template> } template> -[[nodiscard]] static inline bool atomic_compare_exchange_strong(T volatile** var, V*& expected, std::nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept +[[nodiscard]] static inline bool atomic_compare_exchange_strong(T volatile** var, V*& expected, nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept { if (order == memory_order_acq_rel || order == memory_order_release) return __atomic_compare_exchange_n(const_cast(var), &expected, nullptr, false, memory_order_release, memory_order_acquire); @@ -125,7 +125,7 @@ static inline void atomic_store(T volatile** var, V* desired, MemoryOrder order } template> -static inline void atomic_store(T volatile** var, std::nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept +static inline void atomic_store(T volatile** var, nullptr_t, MemoryOrder order = memory_order_seq_cst) noexcept { __atomic_store_n(const_cast(var), nullptr, order); } diff --git a/AK/DeprecatedString.h b/AK/DeprecatedString.h index 75cc762e0fc..e5a4ed853dd 100644 --- a/AK/DeprecatedString.h +++ b/AK/DeprecatedString.h @@ -250,7 +250,7 @@ public: return *this; } - DeprecatedString& operator=(std::nullptr_t) + DeprecatedString& operator=(nullptr_t) { m_impl = nullptr; return *this; diff --git a/AK/Format.h b/AK/Format.h index c52932e974c..9b460818149 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -544,8 +544,8 @@ struct Formatter> : StandardFormatter { }; template<> -struct Formatter : Formatter { - ErrorOr format(FormatBuilder& builder, std::nullptr_t) +struct Formatter : Formatter { + ErrorOr format(FormatBuilder& builder, nullptr_t) { if (m_mode == Mode::Default) m_mode = Mode::Pointer; diff --git a/AK/Function.h b/AK/Function.h index 16ad355e935..f202429fa6a 100644 --- a/AK/Function.h +++ b/AK/Function.h @@ -54,7 +54,7 @@ public: using ReturnType = Out; Function() = default; - Function(std::nullptr_t) + Function(nullptr_t) { } @@ -116,7 +116,7 @@ public: return *this; } - Function& operator=(std::nullptr_t) + Function& operator=(nullptr_t) { clear(); return *this; diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h index 8de5eeb37dc..ece4c34391d 100644 --- a/AK/OwnPtr.h +++ b/AK/OwnPtr.h @@ -97,7 +97,7 @@ public: OwnPtr& operator=(T* ptr) = delete; - OwnPtr& operator=(std::nullptr_t) + OwnPtr& operator=(nullptr_t) { clear(); return *this; diff --git a/AK/RefPtr.h b/AK/RefPtr.h index f60af914afd..7619017347d 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -197,7 +197,7 @@ public: return *this; } - RefPtr& operator=(std::nullptr_t) + RefPtr& operator=(nullptr_t) { clear(); return *this; @@ -256,7 +256,7 @@ public: ALWAYS_INLINE operator bool() { return !is_null(); } - bool operator==(std::nullptr_t) const { return is_null(); } + bool operator==(nullptr_t) const { return is_null(); } bool operator==(RefPtr const& other) const { return as_ptr() == other.as_ptr(); } diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 02b98cd2c27..8e1e87be205 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -34,10 +34,17 @@ requires(AK::Detail::IsIntegral) } -#ifndef AK_DONT_REPLACE_STD -namespace std { // NOLINT(cert-dcl58-cpp) Names in std to aid tools +#if !USING_AK_GLOBALLY +# define AK_REPLACED_STD_NAMESPACE AK::replaced_std +#else +# define AK_REPLACED_STD_NAMESPACE std +#endif + +namespace AK_REPLACED_STD_NAMESPACE { // 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. +// If USING_AK_GLOBALLY is false, we can't put them in ::std, so we put them in AK::replaced_std instead +// The user code should not notice anything unless it explicitly asks for std::stuff, so...don't. template constexpr T&& forward(AK::Detail::RemoveReference& param) @@ -59,20 +66,11 @@ constexpr T&& move(T& arg) } } -#else -# include -#endif -#if !USING_AK_GLOBALLY namespace AK { -#endif - -using std::forward; -using std::move; - -#if !USING_AK_GLOBALLY +using AK_REPLACED_STD_NAMESPACE::forward; +using AK_REPLACED_STD_NAMESPACE::move; } -#endif namespace AK::Detail { template @@ -193,11 +191,13 @@ using AK::array_size; using AK::ceil_div; using AK::clamp; using AK::exchange; +using AK::forward; using AK::is_constant_evaluated; using AK::is_power_of_two; using AK::max; using AK::min; using AK::mix; +using AK::move; using AK::RawPtr; using AK::round_up_to_power_of_two; using AK::swap; diff --git a/AK/TypedTransfer.h b/AK/TypedTransfer.h index 80625b0f3c4..cc18fb97175 100644 --- a/AK/TypedTransfer.h +++ b/AK/TypedTransfer.h @@ -25,9 +25,9 @@ public: for (size_t i = 0; i < count; ++i) { if (destination <= source) - new (&destination[i]) T(std::move(source[i])); + new (&destination[i]) T(AK::move(source[i])); else - new (&destination[count - i - 1]) T(std::move(source[count - i - 1])); + new (&destination[count - i - 1]) T(AK::move(source[count - i - 1])); } } diff --git a/AK/Types.h b/AK/Types.h index 32a8607d1c9..db6146b81ab 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -81,13 +81,13 @@ constexpr u64 TiB = KiB * KiB * KiB * KiB; constexpr u64 PiB = KiB * KiB * KiB * KiB * KiB; constexpr u64 EiB = KiB * KiB * KiB * KiB * KiB * KiB; -namespace std { // NOLINT(cert-dcl58-cpp) nullptr_t must be in ::std:: for some analysis tools +namespace AK_REPLACED_STD_NAMESPACE { // NOLINT(cert-dcl58-cpp) nullptr_t must be in ::std:: for some analysis tools using nullptr_t = decltype(nullptr); } namespace AK { -using nullptr_t = std::nullptr_t; +using nullptr_t = AK_REPLACED_STD_NAMESPACE::nullptr_t; static constexpr FlatPtr explode_byte(u8 b) { @@ -133,6 +133,7 @@ enum MemoryOrder { #if USING_AK_GLOBALLY using AK::align_down_to; using AK::align_up_to; +using AK::explode_byte; using AK::MemoryOrder; using AK::nullptr_t; using AK::TriState; diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index 730a85558d3..bf4eabc8635 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -59,7 +59,7 @@ public: return *this; } - WeakPtr& operator=(std::nullptr_t) + WeakPtr& operator=(nullptr_t) { clear(); return *this; diff --git a/Kernel/Library/LockRefPtr.h b/Kernel/Library/LockRefPtr.h index 4222e17e4fb..4c7aeb70f38 100644 --- a/Kernel/Library/LockRefPtr.h +++ b/Kernel/Library/LockRefPtr.h @@ -113,7 +113,7 @@ struct LockRefPtrTraits { static constexpr FlatPtr default_null_value = 0; - using NullType = std::nullptr_t; + using NullType = nullptr_t; }; template @@ -284,7 +284,7 @@ public: return *this; } - LockRefPtr& operator=(std::nullptr_t) + LockRefPtr& operator=(nullptr_t) { clear(); return *this; @@ -353,8 +353,8 @@ public: ALWAYS_INLINE operator bool() { return !is_null(); } - bool operator==(std::nullptr_t) const { return is_null(); } - bool operator!=(std::nullptr_t) const { return !is_null(); } + bool operator==(nullptr_t) const { return is_null(); } + bool operator!=(nullptr_t) const { return !is_null(); } bool operator==(LockRefPtr const& other) const { return as_ptr() == other.as_ptr(); } bool operator!=(LockRefPtr const& other) const { return as_ptr() != other.as_ptr(); } diff --git a/Kernel/Library/LockWeakPtr.h b/Kernel/Library/LockWeakPtr.h index 184be112f36..f6bacbe6b7d 100644 --- a/Kernel/Library/LockWeakPtr.h +++ b/Kernel/Library/LockWeakPtr.h @@ -49,7 +49,7 @@ public: return *this; } - LockWeakPtr& operator=(std::nullptr_t) + LockWeakPtr& operator=(nullptr_t) { clear(); return *this; diff --git a/Tests/AK/TestTypeTraits.cpp b/Tests/AK/TestTypeTraits.cpp index ad7753e7de2..787452f5ffe 100644 --- a/Tests/AK/TestTypeTraits.cpp +++ b/Tests/AK/TestTypeTraits.cpp @@ -46,22 +46,22 @@ enum class Enummer : u8 { TEST_CASE(FundamentalTypeClassification) { EXPECT_TRAIT_TRUE(IsVoid, void); - EXPECT_TRAIT_FALSE(IsVoid, int, Empty, std::nullptr_t); + EXPECT_TRAIT_FALSE(IsVoid, int, Empty, nullptr_t); - EXPECT_TRAIT_TRUE(IsNullPointer, std::nullptr_t); + EXPECT_TRAIT_TRUE(IsNullPointer, nullptr_t); EXPECT_TRAIT_FALSE(IsNullPointer, void, int, Empty, decltype(0)); EXPECT_TRAIT_TRUE(IsFloatingPoint, float, double, long double); - EXPECT_TRAIT_FALSE(IsFloatingPoint, int, Empty, std::nullptr_t, void); + EXPECT_TRAIT_FALSE(IsFloatingPoint, int, Empty, nullptr_t, void); EXPECT_TRAIT_TRUE(IsArithmetic, float, double, long double, bool, size_t); EXPECT_TRAIT_TRUE(IsArithmetic, char, signed char, unsigned char, char8_t, char16_t, char32_t); EXPECT_TRAIT_TRUE(IsArithmetic, short, int, long, long long); EXPECT_TRAIT_TRUE(IsArithmetic, unsigned short, unsigned int, unsigned long, unsigned long long); - EXPECT_TRAIT_FALSE(IsArithmetic, void, std::nullptr_t, Empty); + EXPECT_TRAIT_FALSE(IsArithmetic, void, nullptr_t, Empty); - EXPECT_TRAIT_TRUE(IsFundamental, void, std::nullptr_t); + EXPECT_TRAIT_TRUE(IsFundamental, void, nullptr_t); EXPECT_TRAIT_TRUE(IsFundamental, float, double, long double, bool, size_t); EXPECT_TRAIT_TRUE(IsFundamental, char, signed char, unsigned char, char8_t, char16_t, char32_t); EXPECT_TRAIT_TRUE(IsFundamental, short, int, long, long long); @@ -89,7 +89,7 @@ TEST_CASE(FundamentalTypeClassification) EXPECT_TRAIT_FALSE(IsEnum, Empty); EXPECT_TRAIT_FALSE(IsEnum, int); EXPECT_TRAIT_FALSE(IsEnum, void); - EXPECT_TRAIT_FALSE(IsEnum, std::nullptr_t); + EXPECT_TRAIT_FALSE(IsEnum, nullptr_t); } TEST_CASE(AddConst) diff --git a/Tests/LibAudio/TestFLACSpec.cpp b/Tests/LibAudio/TestFLACSpec.cpp index 3782641cc13..64518b8ac34 100644 --- a/Tests/LibAudio/TestFLACSpec.cpp +++ b/Tests/LibAudio/TestFLACSpec.cpp @@ -15,7 +15,7 @@ struct FlacTest : Test::TestCase { FlacTest(LexicalPath path) : Test::TestCase( DeprecatedString::formatted("flac_spec_test_{}", path.basename()), [this]() { run(); }, false) - , m_path(std::move(path)) + , m_path(move(path)) { } diff --git a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp index 50e99dfd732..66091823db1 100644 --- a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp @@ -121,7 +121,7 @@ ContentFilterSettingsWidget::ContentFilterSettingsWidget() if (GUI::InputBox::show(window(), text, "Enter domain name"sv, "Add domain to Content Filter"sv) == GUI::Dialog::ExecResult::OK && !text.is_empty()) { - m_domain_list_model->add_domain(std::move(text)); + m_domain_list_model->add_domain(move(text)); set_modified(true); } }; diff --git a/Userland/Applications/Presenter/Presentation.cpp b/Userland/Applications/Presenter/Presentation.cpp index b1d809f9088..27fc6a529a1 100644 --- a/Userland/Applications/Presenter/Presentation.cpp +++ b/Userland/Applications/Presenter/Presentation.cpp @@ -14,7 +14,7 @@ Presentation::Presentation(Gfx::IntSize normative_size, HashMap metadata) : m_normative_size(normative_size) - , m_metadata(std::move(metadata)) + , m_metadata(move(metadata)) { } diff --git a/Userland/DevTools/Profiler/Profile.h b/Userland/DevTools/Profiler/Profile.h index eb374002a07..ad66fb15c73 100644 --- a/Userland/DevTools/Profiler/Profile.h +++ b/Userland/DevTools/Profiler/Profile.h @@ -231,7 +231,7 @@ public: bool success; }; - Variant data { nullptr }; + Variant data { nullptr }; }; Vector const& events() const { return m_events; } diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index 986d2d57c89..e7c673a3442 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -74,7 +74,7 @@ ALWAYS_INLINE ErrorOr unveil(char const (&path)[NPath], char const (&permi return unveil(StringView { path, NPath - 1 }, StringView { permissions, NPermissions - 1 }); } -ALWAYS_INLINE ErrorOr unveil(std::nullptr_t, std::nullptr_t) +ALWAYS_INLINE ErrorOr unveil(nullptr_t, nullptr_t) { return unveil(StringView {}, StringView {}); } diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.cpp b/Userland/Libraries/LibCrypto/ASN1/DER.cpp index 4d398a6b205..8570387be70 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.cpp +++ b/Userland/Libraries/LibCrypto/ASN1/DER.cpp @@ -126,7 +126,7 @@ Result Decoder::decode_octet_string(ReadonlyBytes bytes return StringView { bytes.data(), bytes.size() }; } -Result Decoder::decode_null(ReadonlyBytes data) +Result Decoder::decode_null(ReadonlyBytes data) { if (data.size() != 0) return DecodeError::InvalidInputFormat; diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.h b/Userland/Libraries/LibCrypto/ASN1/DER.h index 6081c40473d..e3c3f467783 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.h +++ b/Userland/Libraries/LibCrypto/ASN1/DER.h @@ -217,7 +217,7 @@ private: static Result decode_boolean(ReadonlyBytes); static Result decode_arbitrary_sized_integer(ReadonlyBytes); static Result decode_octet_string(ReadonlyBytes); - static Result decode_null(ReadonlyBytes); + static Result decode_null(ReadonlyBytes); static Result, DecodeError> decode_object_identifier(ReadonlyBytes); static Result decode_printable_string(ReadonlyBytes); static Result decode_bit_string(ReadonlyBytes); diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp index 94558454bab..87df5d03454 100644 --- a/Userland/Libraries/LibGUI/FileIconProvider.cpp +++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp @@ -222,7 +222,7 @@ Icon FileIconProvider::icon_for_executable(DeprecatedString const& path) continue; } - icon.set_bitmap_for_size(icon_section.image_size, std::move(bitmap)); + icon.set_bitmap_for_size(icon_section.image_size, move(bitmap)); } if (had_error) { diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 053406b51ed..6bf3f05dac4 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -948,7 +948,7 @@ public: { } - explicit Yield(std::nullptr_t) + explicit Yield(nullptr_t) : Instruction(Type::Yield) { } diff --git a/Userland/Libraries/LibJS/Heap/GCPtr.h b/Userland/Libraries/LibJS/Heap/GCPtr.h index f0c0623afab..c42519173e2 100644 --- a/Userland/Libraries/LibJS/Heap/GCPtr.h +++ b/Userland/Libraries/LibJS/Heap/GCPtr.h @@ -129,7 +129,7 @@ public: { } - GCPtr(std::nullptr_t) + GCPtr(nullptr_t) : m_ptr(nullptr) { } diff --git a/Userland/Libraries/LibJS/SafeFunction.h b/Userland/Libraries/LibJS/SafeFunction.h index 879fd69b14b..7a86dc95c9d 100644 --- a/Userland/Libraries/LibJS/SafeFunction.h +++ b/Userland/Libraries/LibJS/SafeFunction.h @@ -24,7 +24,7 @@ class SafeFunction { public: SafeFunction() = default; - SafeFunction(std::nullptr_t) + SafeFunction(nullptr_t) { } @@ -102,7 +102,7 @@ public: return *this; } - SafeFunction& operator=(std::nullptr_t) + SafeFunction& operator=(nullptr_t) { clear(); return *this; diff --git a/Userland/Libraries/LibPDF/Value.cpp b/Userland/Libraries/LibPDF/Value.cpp index b95d619f0cb..1f652fdfee0 100644 --- a/Userland/Libraries/LibPDF/Value.cpp +++ b/Userland/Libraries/LibPDF/Value.cpp @@ -16,7 +16,7 @@ DeprecatedString Value::to_deprecated_string(int indent) const // Return type deduction means that we can't use implicit conversions. return ""; }, - [&](std::nullptr_t const&) -> DeprecatedString { + [&](nullptr_t const&) -> DeprecatedString { return "null"; }, [&](bool const& b) -> DeprecatedString { diff --git a/Userland/Libraries/LibPDF/Value.h b/Userland/Libraries/LibPDF/Value.h index 4144b09a15a..68080329690 100644 --- a/Userland/Libraries/LibPDF/Value.h +++ b/Userland/Libraries/LibPDF/Value.h @@ -16,7 +16,7 @@ namespace PDF { -class Value : public Variant> { +class Value : public Variant> { public: using Variant::Variant; diff --git a/Userland/Libraries/LibSQL/SQLClient.cpp b/Userland/Libraries/LibSQL/SQLClient.cpp index df72ca1eb9e..ae37d474983 100644 --- a/Userland/Libraries/LibSQL/SQLClient.cpp +++ b/Userland/Libraries/LibSQL/SQLClient.cpp @@ -139,7 +139,7 @@ ErrorOr> SQLClient::launch_server_and_create_client(Str auto socket = TRY(Core::Stream::LocalSocket::connect(move(socket_path))); TRY(socket->set_blocking(true)); - return adopt_nonnull_ref_or_enomem(new (nothrow) SQLClient(std::move(socket))); + return adopt_nonnull_ref_or_enomem(new (nothrow) SQLClient(move(socket))); } #endif