ソースを参照

Everywhere: Remove AK_DONT_REPLACE_STD macro

Let's just always include `<utility>`. Placing our own incompatible with
the STL declaration of these functions in AK was always fishy to begin
with.
Andrew Kaster 1 年間 前
コミット
45301e8169

+ 0 - 2
AK/Base64.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/Base64.h>
 #include <AK/Types.h>
 #include <AK/Vector.h>

+ 4 - 38
AK/StdLibExtras.h

@@ -16,6 +16,8 @@
 
 #include <AK/Assertions.h>
 
+#include <utility>
+
 namespace AK {
 
 template<typename T, typename U>
@@ -35,44 +37,8 @@ requires(AK::Detail::IsIntegral<T>)
 template<typename... Args>
 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<typename T>
-constexpr T&& forward(AK::Detail::RemoveReference<T>& param)
-{
-    return static_cast<T&&>(param);
-}
-
-template<typename T>
-constexpr T&& forward(AK::Detail::RemoveReference<T>&& param) noexcept
-{
-    static_assert(!AK::Detail::IsLvalueReference<T>, "Can't forward an rvalue as an lvalue.");
-    return static_cast<T&&>(param);
-}
-
-template<typename T>
-constexpr T&& move(T& arg)
-{
-    return static_cast<T&&>(arg);
-}
-
-}
-
-namespace AK {
-using AK_REPLACED_STD_NAMESPACE::forward;
-using AK_REPLACED_STD_NAMESPACE::move;
+using std::forward;
+using std::move;
 }
 
 namespace AK::Detail {

+ 0 - 2
AK/String.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/Array.h>
 #include <AK/Checked.h>
 #include <AK/Endian.h>

+ 0 - 2
AK/Utf16View.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/CharacterTypes.h>
 #include <AK/Concepts.h>
 #include <AK/StringBuilder.h>

+ 0 - 2
AK/Utf8View.cpp

@@ -5,8 +5,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/Assertions.h>
 #include <AK/Debug.h>
 #include <AK/Format.h>

+ 0 - 1
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)
 

+ 0 - 2
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

+ 0 - 1
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 = [

+ 0 - 1
Userland/Libraries/LibAudio/PlaybackStreamOboe.cpp

@@ -4,7 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
 #include <AK/Atomic.h>
 #include <AK/SourceLocation.h>
 #include <LibAudio/PlaybackStreamOboe.h>

+ 0 - 1
Userland/Libraries/LibGfx/Font/WOFF2/Loader.cpp

@@ -4,7 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
 #include <LibGfx/Font/OpenType/Typeface.h>
 #include <LibGfx/Font/WOFF2/Loader.h>
 #include <woff2/decode.h>

+ 0 - 2
Userland/Libraries/LibUnicode/CharacterTypes.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/Array.h>
 #include <AK/CharacterTypes.h>
 #include <AK/Find.h>

+ 0 - 2
Userland/Libraries/LibUnicode/DateTimeFormat.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/AllOf.h>
 #include <AK/Array.h>
 #include <AK/GenericLexer.h>

+ 0 - 2
Userland/Libraries/LibUnicode/DisplayNames.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/Array.h>
 #include <LibUnicode/DisplayNames.h>
 #include <LibUnicode/ICU.h>

+ 0 - 2
Userland/Libraries/LibUnicode/DurationFormat.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/Array.h>
 #include <AK/CharacterTypes.h>
 #include <AK/GenericLexer.h>

+ 0 - 2
Userland/Libraries/LibUnicode/ICU.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/HashMap.h>
 #include <AK/NonnullOwnPtr.h>
 #include <AK/Utf16View.h>

+ 0 - 2
Userland/Libraries/LibUnicode/ICU.h

@@ -6,8 +6,6 @@
 
 #pragma once
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/Optional.h>
 #include <AK/OwnPtr.h>
 #include <AK/String.h>

+ 0 - 2
Userland/Libraries/LibUnicode/IDNA.cpp

@@ -5,8 +5,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <LibUnicode/ICU.h>
 #include <LibUnicode/IDNA.h>
 

+ 0 - 2
Userland/Libraries/LibUnicode/ListFormat.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/NonnullOwnPtr.h>
 #include <LibUnicode/ICU.h>
 #include <LibUnicode/ListFormat.h>

+ 0 - 2
Userland/Libraries/LibUnicode/Locale.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/AllOf.h>
 #include <AK/GenericLexer.h>
 #include <AK/HashTable.h>

+ 0 - 2
Userland/Libraries/LibUnicode/Normalize.cpp

@@ -5,8 +5,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/StringBuilder.h>
 #include <LibUnicode/ICU.h>
 #include <LibUnicode/Normalize.h>

+ 0 - 2
Userland/Libraries/LibUnicode/NumberFormat.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/CharacterTypes.h>
 #include <AK/QuickSort.h>
 #include <AK/Utf8View.h>

+ 0 - 2
Userland/Libraries/LibUnicode/RelativeTimeFormat.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <LibUnicode/ICU.h>
 #include <LibUnicode/Locale.h>
 #include <LibUnicode/NumberFormat.h>

+ 0 - 2
Userland/Libraries/LibUnicode/Segmenter.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/Utf16View.h>
 #include <AK/Utf32View.h>
 #include <LibUnicode/ICU.h>

+ 0 - 2
Userland/Libraries/LibUnicode/String.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/String.h>
 #include <AK/StringBuilder.h>
 #include <LibUnicode/ICU.h>

+ 0 - 2
Userland/Libraries/LibUnicode/TimeZone.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/Array.h>
 #include <AK/NonnullOwnPtr.h>
 #include <AK/QuickSort.h>

+ 0 - 2
Userland/Libraries/LibUnicode/UnicodeKeywords.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <AK/QuickSort.h>
 #include <AK/ScopeGuard.h>
 #include <LibUnicode/DateTimeFormat.h>

+ 0 - 2
Userland/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp

@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#define AK_DONT_REPLACE_STD
-
 #include <core/SkBitmap.h>
 #include <core/SkBlurTypes.h>
 #include <core/SkCanvas.h>