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:
parent
24caacfe28
commit
3483407ddc
Notes:
sideshowbarker
2024-07-17 04:21:06 +09:00
Author: https://github.com/MacDue
Commit: 3483407ddc
Pull-request: https://github.com/SerenityOS/serenity/pull/16114
5 changed files with 23 additions and 85 deletions
22
AK/OwnPtr.h
22
AK/OwnPtr.h
|
@ -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; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue