mirror of
https://github.com/RGBCube/serenity
synced 2025-08-02 03:07:35 +00:00
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:
parent
72514d6915
commit
f96a3c002a
27 changed files with 56 additions and 55 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
DeprecatedString& operator=(std::nullptr_t)
|
||||
DeprecatedString& operator=(nullptr_t)
|
||||
{
|
||||
m_impl = nullptr;
|
||||
return *this;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
|
||||
OwnPtr& operator=(T* ptr) = delete;
|
||||
|
||||
OwnPtr& operator=(std::nullptr_t)
|
||||
OwnPtr& operator=(nullptr_t)
|
||||
{
|
||||
clear();
|
||||
return *this;
|
||||
|
|
|
@ -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(); }
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
WeakPtr& operator=(std::nullptr_t)
|
||||
WeakPtr& operator=(nullptr_t)
|
||||
{
|
||||
clear();
|
||||
return *this;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue