diff options
Diffstat (limited to 'AK/RefPtr.h')
-rw-r--r-- | AK/RefPtr.h | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/AK/RefPtr.h b/AK/RefPtr.h index 11e27a2c1c..9e06c900b9 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -8,18 +8,14 @@ #define REFPTR_SCRUB_BYTE 0xe0 -#ifdef KERNEL -# include <Kernel/Library/ThreadSafeRefPtr.h> -#else - -# include <AK/Assertions.h> -# include <AK/Atomic.h> -# include <AK/Error.h> -# include <AK/Format.h> -# include <AK/NonnullRefPtr.h> -# include <AK/StdLibExtras.h> -# include <AK/Traits.h> -# include <AK/Types.h> +#include <AK/Assertions.h> +#include <AK/Atomic.h> +#include <AK/Error.h> +#include <AK/Format.h> +#include <AK/NonnullRefPtr.h> +#include <AK/StdLibExtras.h> +#include <AK/Traits.h> +#include <AK/Types.h> namespace AK { @@ -104,9 +100,9 @@ public: ALWAYS_INLINE ~RefPtr() { clear(); -# ifdef SANITIZE_PTRS +#ifdef SANITIZE_PTRS m_ptr = reinterpret_cast<T*>(explode_byte(REFPTR_SCRUB_BYTE)); -# endif +#endif } template<typename U> @@ -236,14 +232,14 @@ public: } ALWAYS_INLINE T* ptr() { return as_ptr(); } - ALWAYS_INLINE const T* ptr() const { return as_ptr(); } + ALWAYS_INLINE T const* ptr() const { return as_ptr(); } ALWAYS_INLINE T* operator->() { return as_nonnull_ptr(); } - ALWAYS_INLINE const T* operator->() const + ALWAYS_INLINE T const* operator->() const { return as_nonnull_ptr(); } @@ -253,12 +249,12 @@ public: return *as_nonnull_ptr(); } - ALWAYS_INLINE const T& operator*() const + ALWAYS_INLINE T const& operator*() const { return *as_nonnull_ptr(); } - ALWAYS_INLINE operator const T*() const { return as_ptr(); } + ALWAYS_INLINE operator T const*() const { return as_ptr(); } ALWAYS_INLINE operator T*() { return as_ptr(); } ALWAYS_INLINE operator bool() { return !is_null(); } @@ -282,8 +278,8 @@ public: template<typename U> bool operator!=(NonnullRefPtr<U>& other) { return as_ptr() != other.m_ptr; } - bool operator==(const T* other) const { return as_ptr() == other; } - bool operator!=(const T* other) const { return as_ptr() != other; } + bool operator==(T const* other) const { return as_ptr() == other; } + bool operator!=(T const* other) const { return as_ptr() != other; } bool operator==(T* other) { return as_ptr() == other; } bool operator!=(T* other) { return as_ptr() != other; } @@ -306,17 +302,17 @@ private: }; template<typename T> -struct Formatter<RefPtr<T>> : Formatter<const T*> { +struct Formatter<RefPtr<T>> : Formatter<T const*> { ErrorOr<void> format(FormatBuilder& builder, RefPtr<T> const& value) { - return Formatter<const T*>::format(builder, value.ptr()); + return Formatter<T const*>::format(builder, value.ptr()); } }; template<typename T> struct Traits<RefPtr<T>> : public GenericTraits<RefPtr<T>> { using PeekType = T*; - using ConstPeekType = const T*; + using ConstPeekType = T const*; static unsigned hash(RefPtr<T> const& p) { return ptr_hash(p.ptr()); } static bool equals(RefPtr<T> const& a, RefPtr<T> const& b) { return a.ptr() == b.ptr(); } }; @@ -324,13 +320,13 @@ struct Traits<RefPtr<T>> : public GenericTraits<RefPtr<T>> { template<typename T, typename U> inline NonnullRefPtr<T> static_ptr_cast(NonnullRefPtr<U> const& ptr) { - return NonnullRefPtr<T>(static_cast<const T&>(*ptr)); + return NonnullRefPtr<T>(static_cast<T const&>(*ptr)); } template<typename T, typename U> inline RefPtr<T> static_ptr_cast(RefPtr<U> const& ptr) { - return RefPtr<T>(static_cast<const T*>(ptr.ptr())); + return RefPtr<T>(static_cast<T const*>(ptr.ptr())); } template<typename T, typename U> @@ -375,5 +371,3 @@ using AK::adopt_ref_if_nonnull; using AK::RefPtr; using AK::static_ptr_cast; using AK::try_make_ref_counted; - -#endif |