From 45301e816942201134db7db1df2c11f889762671 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Wed, 24 Jul 2024 18:27:18 -0600 Subject: [PATCH] Everywhere: Remove AK_DONT_REPLACE_STD macro Let's just always include ``. Placing our own incompatible with the STL declaration of these functions in AK was always fishy to begin with. --- AK/Base64.cpp | 2 - AK/StdLibExtras.h | 42 ++----------------- AK/String.cpp | 2 - AK/Utf16View.cpp | 2 - AK/Utf8View.cpp | 2 - CMakeLists.txt | 1 - Meta/Lagom/ReadMe.md | 2 - Meta/gn/secondary/Ladybird/BUILD.gn | 1 - .../Libraries/LibAudio/PlaybackStreamOboe.cpp | 1 - .../Libraries/LibGfx/Font/WOFF2/Loader.cpp | 1 - .../Libraries/LibUnicode/CharacterTypes.cpp | 2 - .../Libraries/LibUnicode/DateTimeFormat.cpp | 2 - .../Libraries/LibUnicode/DisplayNames.cpp | 2 - .../Libraries/LibUnicode/DurationFormat.cpp | 2 - Userland/Libraries/LibUnicode/ICU.cpp | 2 - Userland/Libraries/LibUnicode/ICU.h | 2 - Userland/Libraries/LibUnicode/IDNA.cpp | 2 - Userland/Libraries/LibUnicode/ListFormat.cpp | 2 - Userland/Libraries/LibUnicode/Locale.cpp | 2 - Userland/Libraries/LibUnicode/Normalize.cpp | 2 - .../Libraries/LibUnicode/NumberFormat.cpp | 2 - .../LibUnicode/RelativeTimeFormat.cpp | 2 - Userland/Libraries/LibUnicode/Segmenter.cpp | 2 - Userland/Libraries/LibUnicode/String.cpp | 2 - Userland/Libraries/LibUnicode/TimeZone.cpp | 2 - .../Libraries/LibUnicode/UnicodeKeywords.cpp | 2 - .../LibWeb/Painting/DisplayListPlayerSkia.cpp | 2 - 27 files changed, 4 insertions(+), 86 deletions(-) diff --git a/AK/Base64.cpp b/AK/Base64.cpp index 7a579440649..05691270f2c 100644 --- a/AK/Base64.cpp +++ b/AK/Base64.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index bb337e326f0..2944137a728 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -16,6 +16,8 @@ #include +#include + namespace AK { template @@ -35,44 +37,8 @@ requires(AK::Detail::IsIntegral) template void compiletime_fail(Args...); -} - -#if !USING_AK_GLOBALLY || defined(AK_DONT_REPLACE_STD) -# 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) -{ - return static_cast(param); -} - -template -constexpr T&& forward(AK::Detail::RemoveReference&& param) noexcept -{ - static_assert(!AK::Detail::IsLvalueReference, "Can't forward an rvalue as an lvalue."); - return static_cast(param); -} - -template -constexpr T&& move(T& arg) -{ - return static_cast(arg); -} - -} - -namespace AK { -using AK_REPLACED_STD_NAMESPACE::forward; -using AK_REPLACED_STD_NAMESPACE::move; +using std::forward; +using std::move; } namespace AK::Detail { diff --git a/AK/String.cpp b/AK/String.cpp index 130afd74144..dd6502740f6 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/AK/Utf16View.cpp b/AK/Utf16View.cpp index bd971adc9a8..f09e85cab11 100644 --- a/AK/Utf16View.cpp +++ b/AK/Utf16View.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/AK/Utf8View.cpp b/AK/Utf8View.cpp index 05d67cfa204..71f71618be2 100644 --- a/AK/Utf8View.cpp +++ b/AK/Utf8View.cpp @@ -5,8 +5,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a5e9e43b63..20c507af1a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,6 @@ if (HAIKU) add_compile_definitions(__USE_GNU) endif() -add_compile_definitions(AK_DONT_REPLACE_STD) add_cxx_compile_options(-Wno-expansion-to-defined) add_cxx_compile_options(-Wno-user-defined-literals) diff --git a/Meta/Lagom/ReadMe.md b/Meta/Lagom/ReadMe.md index 877eb1abbe7..c4fa0e918be 100644 --- a/Meta/Lagom/ReadMe.md +++ b/Meta/Lagom/ReadMe.md @@ -40,8 +40,6 @@ Now, you can link against Lagom libraries. Things to keep in mind: - You should prefer to use a library's `Lagom::` alias when linking - Example: `Lagom::Core` vs `LibCore` -- If you still _need_ to use the C++ standard library, you may have to compile with the `AK_DONT_REPLACE_STD` macro. - - Serenity defines its own `move` and `forward` functions inside of `AK/StdLibExtras.h` that will clash with the standard library's definitions. This macro will make Serenity use the standard library's `move` and `forward` instead. - If your application has name clashes with any names in AK, you may have to define `USING_AK_GLOBALLY=0` for the files that have visibility to both sets of headers. ## Fuzzing diff --git a/Meta/gn/secondary/Ladybird/BUILD.gn b/Meta/gn/secondary/Ladybird/BUILD.gn index 15cfb5c0d72..fe0002ecb6f 100644 --- a/Meta/gn/secondary/Ladybird/BUILD.gn +++ b/Meta/gn/secondary/Ladybird/BUILD.gn @@ -48,7 +48,6 @@ config("ladybird_config") { "//Userland/Applications", "//Userland/Services", ] - defines = [ "AK_DONT_REPLACE_STD" ] } ladybird_helper_processes = [ diff --git a/Userland/Libraries/LibAudio/PlaybackStreamOboe.cpp b/Userland/Libraries/LibAudio/PlaybackStreamOboe.cpp index d619fd68399..a9cd02b9805 100644 --- a/Userland/Libraries/LibAudio/PlaybackStreamOboe.cpp +++ b/Userland/Libraries/LibAudio/PlaybackStreamOboe.cpp @@ -4,7 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD #include #include #include diff --git a/Userland/Libraries/LibGfx/Font/WOFF2/Loader.cpp b/Userland/Libraries/LibGfx/Font/WOFF2/Loader.cpp index f92976b4abd..e6938bde731 100644 --- a/Userland/Libraries/LibGfx/Font/WOFF2/Loader.cpp +++ b/Userland/Libraries/LibGfx/Font/WOFF2/Loader.cpp @@ -4,7 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD #include #include #include diff --git a/Userland/Libraries/LibUnicode/CharacterTypes.cpp b/Userland/Libraries/LibUnicode/CharacterTypes.cpp index a0f5a8048de..f8cf4bc6087 100644 --- a/Userland/Libraries/LibUnicode/CharacterTypes.cpp +++ b/Userland/Libraries/LibUnicode/CharacterTypes.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/DateTimeFormat.cpp b/Userland/Libraries/LibUnicode/DateTimeFormat.cpp index b4801121451..4b5707e9bb4 100644 --- a/Userland/Libraries/LibUnicode/DateTimeFormat.cpp +++ b/Userland/Libraries/LibUnicode/DateTimeFormat.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/DisplayNames.cpp b/Userland/Libraries/LibUnicode/DisplayNames.cpp index e8111f246c5..f2ad8442351 100644 --- a/Userland/Libraries/LibUnicode/DisplayNames.cpp +++ b/Userland/Libraries/LibUnicode/DisplayNames.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/DurationFormat.cpp b/Userland/Libraries/LibUnicode/DurationFormat.cpp index a3ccb02c5e1..cadca63d307 100644 --- a/Userland/Libraries/LibUnicode/DurationFormat.cpp +++ b/Userland/Libraries/LibUnicode/DurationFormat.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/ICU.cpp b/Userland/Libraries/LibUnicode/ICU.cpp index 853a4dd0d54..fc63292ed6f 100644 --- a/Userland/Libraries/LibUnicode/ICU.cpp +++ b/Userland/Libraries/LibUnicode/ICU.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/ICU.h b/Userland/Libraries/LibUnicode/ICU.h index 5cbaea76d3e..c6af66b2ae2 100644 --- a/Userland/Libraries/LibUnicode/ICU.h +++ b/Userland/Libraries/LibUnicode/ICU.h @@ -6,8 +6,6 @@ #pragma once -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/IDNA.cpp b/Userland/Libraries/LibUnicode/IDNA.cpp index c890751e858..47dc9f75d23 100644 --- a/Userland/Libraries/LibUnicode/IDNA.cpp +++ b/Userland/Libraries/LibUnicode/IDNA.cpp @@ -5,8 +5,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include diff --git a/Userland/Libraries/LibUnicode/ListFormat.cpp b/Userland/Libraries/LibUnicode/ListFormat.cpp index 2205a5e03b5..6db8045ccbf 100644 --- a/Userland/Libraries/LibUnicode/ListFormat.cpp +++ b/Userland/Libraries/LibUnicode/ListFormat.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/Locale.cpp b/Userland/Libraries/LibUnicode/Locale.cpp index df8680b7684..f4bdf2cc0f6 100644 --- a/Userland/Libraries/LibUnicode/Locale.cpp +++ b/Userland/Libraries/LibUnicode/Locale.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/Normalize.cpp b/Userland/Libraries/LibUnicode/Normalize.cpp index ce01566c295..c5b5b1cb97e 100644 --- a/Userland/Libraries/LibUnicode/Normalize.cpp +++ b/Userland/Libraries/LibUnicode/Normalize.cpp @@ -5,8 +5,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/NumberFormat.cpp b/Userland/Libraries/LibUnicode/NumberFormat.cpp index 372c63c8745..a45bd39061f 100644 --- a/Userland/Libraries/LibUnicode/NumberFormat.cpp +++ b/Userland/Libraries/LibUnicode/NumberFormat.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/RelativeTimeFormat.cpp b/Userland/Libraries/LibUnicode/RelativeTimeFormat.cpp index 25ebe6619bf..a9604bb24a0 100644 --- a/Userland/Libraries/LibUnicode/RelativeTimeFormat.cpp +++ b/Userland/Libraries/LibUnicode/RelativeTimeFormat.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/Segmenter.cpp b/Userland/Libraries/LibUnicode/Segmenter.cpp index 450b53eb031..953f36a73d3 100644 --- a/Userland/Libraries/LibUnicode/Segmenter.cpp +++ b/Userland/Libraries/LibUnicode/Segmenter.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/String.cpp b/Userland/Libraries/LibUnicode/String.cpp index 30b4ff6449f..2e37675ca28 100644 --- a/Userland/Libraries/LibUnicode/String.cpp +++ b/Userland/Libraries/LibUnicode/String.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/TimeZone.cpp b/Userland/Libraries/LibUnicode/TimeZone.cpp index 5269c4fa899..e6fdcb5c882 100644 --- a/Userland/Libraries/LibUnicode/TimeZone.cpp +++ b/Userland/Libraries/LibUnicode/TimeZone.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibUnicode/UnicodeKeywords.cpp b/Userland/Libraries/LibUnicode/UnicodeKeywords.cpp index 1713607f767..048a6092d2c 100644 --- a/Userland/Libraries/LibUnicode/UnicodeKeywords.cpp +++ b/Userland/Libraries/LibUnicode/UnicodeKeywords.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include diff --git a/Userland/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp b/Userland/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp index c40c2e4823e..069b022ed81 100644 --- a/Userland/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp +++ b/Userland/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#define AK_DONT_REPLACE_STD - #include #include #include