1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00

AK: Return non-const types from Ptr class operators

Even if the pointer value is const, the value they point to is not
necessarily const, so these functions should not add the qualifier.

This also removes the redundant non-const implementations of these
operators.
This commit is contained in:
MacDue 2022-11-19 01:03:48 +00:00 committed by Linus Groh
parent 24caacfe28
commit 3483407ddc
Notes: sideshowbarker 2024-07-17 04:21:06 +09:00
5 changed files with 23 additions and 85 deletions

View file

@ -93,26 +93,17 @@ public:
return exchange(m_ptr, nullptr);
}
ALWAYS_INLINE RETURNS_NONNULL T* ptr()
ALWAYS_INLINE RETURNS_NONNULL T* ptr() const
{
VERIFY(m_ptr);
return m_ptr;
}
ALWAYS_INLINE RETURNS_NONNULL const T* ptr() const
{
VERIFY(m_ptr);
return m_ptr;
}
ALWAYS_INLINE RETURNS_NONNULL T* operator->() const { return ptr(); }
ALWAYS_INLINE RETURNS_NONNULL T* operator->() { return ptr(); }
ALWAYS_INLINE RETURNS_NONNULL const T* operator->() const { return ptr(); }
ALWAYS_INLINE T& operator*() const { return *ptr(); }
ALWAYS_INLINE T& operator*() { return *ptr(); }
ALWAYS_INLINE const T& operator*() const { return *ptr(); }
ALWAYS_INLINE RETURNS_NONNULL operator const T*() const { return ptr(); }
ALWAYS_INLINE RETURNS_NONNULL operator T*() { return ptr(); }
ALWAYS_INLINE RETURNS_NONNULL operator T*() const { return ptr(); }
operator bool() const = delete;
bool operator!() const = delete;