Everywhere: Stop shoving things into ::std and mentioning them as such

Note that this still keeps the old behaviour of putting things in std by
default on serenity so the tools can be happy, but if USING_AK_GLOBALLY
is unset, AK behaves like a good citizen and doesn't try to put things
in the ::std namespace.

std::nothrow_t and its friends get to stay because I'm being told that
compilers assume things about them and I can't yeet them into a
different namespace...for now.
This commit is contained in:
Ali Mohammad Pur 2022-12-13 10:29:30 +03:30 committed by Andreas Kling
parent 72514d6915
commit f96a3c002a
Notes: sideshowbarker 2024-07-17 07:11:12 +09:00
27 changed files with 56 additions and 55 deletions

View file

@ -41,7 +41,7 @@ static inline V* atomic_exchange(T volatile** var, V* desired, MemoryOrder order
}
template<typename T, typename V = RemoveVolatile<T>>
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<V**>(var), nullptr, order);
}
@ -63,7 +63,7 @@ template<typename T, typename V = RemoveVolatile<T>>
}
template<typename T, typename V = RemoveVolatile<T>>
[[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<V**>(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<typename T, typename V = RemoveVolatile<T>>
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<V**>(var), nullptr, order);
}

View file

@ -250,7 +250,7 @@ public:
return *this;
}
DeprecatedString& operator=(std::nullptr_t)
DeprecatedString& operator=(nullptr_t)
{
m_impl = nullptr;
return *this;

View file

@ -544,8 +544,8 @@ struct Formatter<FixedPoint<precision, Underlying>> : StandardFormatter {
};
template<>
struct Formatter<std::nullptr_t> : Formatter<FlatPtr> {
ErrorOr<void> format(FormatBuilder& builder, std::nullptr_t)
struct Formatter<nullptr_t> : Formatter<FlatPtr> {
ErrorOr<void> format(FormatBuilder& builder, nullptr_t)
{
if (m_mode == Mode::Default)
m_mode = Mode::Pointer;

View file

@ -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;

View file

@ -97,7 +97,7 @@ public:
OwnPtr& operator=(T* ptr) = delete;
OwnPtr& operator=(std::nullptr_t)
OwnPtr& operator=(nullptr_t)
{
clear();
return *this;

View file

@ -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(); }

View file

@ -34,10 +34,17 @@ requires(AK::Detail::IsIntegral<T>)
}
#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<typename T>
constexpr T&& forward(AK::Detail::RemoveReference<T>& param)
@ -59,20 +66,11 @@ constexpr T&& move(T& arg)
}
}
#else
# include <utility>
#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<typename T>
@ -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;

View file

@ -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]));
}
}

View file

@ -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;

View file

@ -59,7 +59,7 @@ public:
return *this;
}
WeakPtr& operator=(std::nullptr_t)
WeakPtr& operator=(nullptr_t)
{
clear();
return *this;

View file

@ -113,7 +113,7 @@ struct LockRefPtrTraits {
static constexpr FlatPtr default_null_value = 0;
using NullType = std::nullptr_t;
using NullType = nullptr_t;
};
template<typename T, typename PtrTraits>
@ -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(); }

View file

@ -49,7 +49,7 @@ public:
return *this;
}
LockWeakPtr& operator=(std::nullptr_t)
LockWeakPtr& operator=(nullptr_t)
{
clear();
return *this;

View file

@ -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)

View file

@ -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))
{
}

View file

@ -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);
}
};

View file

@ -14,7 +14,7 @@
Presentation::Presentation(Gfx::IntSize normative_size, HashMap<DeprecatedString, DeprecatedString> metadata)
: m_normative_size(normative_size)
, m_metadata(std::move(metadata))
, m_metadata(move(metadata))
{
}

View file

@ -231,7 +231,7 @@ public:
bool success;
};
Variant<std::nullptr_t, SampleData, MallocData, FreeData, SignpostData, MmapData, MunmapData, ProcessCreateData, ProcessExecData, ThreadCreateData, ReadData> data { nullptr };
Variant<nullptr_t, SampleData, MallocData, FreeData, SignpostData, MmapData, MunmapData, ProcessCreateData, ProcessExecData, ThreadCreateData, ReadData> data { nullptr };
};
Vector<Event> const& events() const { return m_events; }

View file

@ -74,7 +74,7 @@ ALWAYS_INLINE ErrorOr<void> unveil(char const (&path)[NPath], char const (&permi
return unveil(StringView { path, NPath - 1 }, StringView { permissions, NPermissions - 1 });
}
ALWAYS_INLINE ErrorOr<void> unveil(std::nullptr_t, std::nullptr_t)
ALWAYS_INLINE ErrorOr<void> unveil(nullptr_t, nullptr_t)
{
return unveil(StringView {}, StringView {});
}

View file

@ -126,7 +126,7 @@ Result<StringView, DecodeError> Decoder::decode_octet_string(ReadonlyBytes bytes
return StringView { bytes.data(), bytes.size() };
}
Result<std::nullptr_t, DecodeError> Decoder::decode_null(ReadonlyBytes data)
Result<nullptr_t, DecodeError> Decoder::decode_null(ReadonlyBytes data)
{
if (data.size() != 0)
return DecodeError::InvalidInputFormat;

View file

@ -217,7 +217,7 @@ private:
static Result<bool, DecodeError> decode_boolean(ReadonlyBytes);
static Result<UnsignedBigInteger, DecodeError> decode_arbitrary_sized_integer(ReadonlyBytes);
static Result<StringView, DecodeError> decode_octet_string(ReadonlyBytes);
static Result<std::nullptr_t, DecodeError> decode_null(ReadonlyBytes);
static Result<nullptr_t, DecodeError> decode_null(ReadonlyBytes);
static Result<Vector<int>, DecodeError> decode_object_identifier(ReadonlyBytes);
static Result<StringView, DecodeError> decode_printable_string(ReadonlyBytes);
static Result<BitStringView, DecodeError> decode_bit_string(ReadonlyBytes);

View file

@ -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) {

View file

@ -948,7 +948,7 @@ public:
{
}
explicit Yield(std::nullptr_t)
explicit Yield(nullptr_t)
: Instruction(Type::Yield)
{
}

View file

@ -129,7 +129,7 @@ public:
{
}
GCPtr(std::nullptr_t)
GCPtr(nullptr_t)
: m_ptr(nullptr)
{
}

View file

@ -24,7 +24,7 @@ class SafeFunction<Out(In...)> {
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;

View file

@ -16,7 +16,7 @@ DeprecatedString Value::to_deprecated_string(int indent) const
// Return type deduction means that we can't use implicit conversions.
return "<empty>";
},
[&](std::nullptr_t const&) -> DeprecatedString {
[&](nullptr_t const&) -> DeprecatedString {
return "null";
},
[&](bool const& b) -> DeprecatedString {

View file

@ -16,7 +16,7 @@
namespace PDF {
class Value : public Variant<Empty, std::nullptr_t, bool, int, float, Reference, NonnullRefPtr<Object>> {
class Value : public Variant<Empty, nullptr_t, bool, int, float, Reference, NonnullRefPtr<Object>> {
public:
using Variant::Variant;

View file

@ -139,7 +139,7 @@ ErrorOr<NonnullRefPtr<SQLClient>> 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