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

@ -131,35 +131,21 @@ public:
return NonnullOwnPtr<U>(NonnullOwnPtr<U>::Adopt, static_cast<U&>(*leak_ptr()));
}
T* ptr() { return m_ptr; }
const T* ptr() const { return m_ptr; }
T* ptr() const { return m_ptr; }
T* operator->()
T* operator->() const
{
VERIFY(m_ptr);
return m_ptr;
}
const T* operator->() const
{
VERIFY(m_ptr);
return m_ptr;
}
T& operator*()
T& operator*() const
{
VERIFY(m_ptr);
return *m_ptr;
}
const T& operator*() const
{
VERIFY(m_ptr);
return *m_ptr;
}
operator const T*() const { return m_ptr; }
operator T*() { return m_ptr; }
operator T*() const { return m_ptr; }
operator bool() { return !!m_ptr; }