mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
AK: Add assertions when dereferencing an OwnPtr.
This will make it immediately obvious what the problem is when you're dereferencing a null OwnPtr.
This commit is contained in:
parent
a9a1a5dfa9
commit
d9cc3e453c
Notes:
sideshowbarker
2024-07-19 12:56:49 +09:00
Author: https://github.com/awesomekling
Commit: d9cc3e453c
1 changed files with 22 additions and 4 deletions
26
AK/OwnPtr.h
26
AK/OwnPtr.h
|
@ -123,11 +123,29 @@ public:
|
|||
T* ptr() { return m_ptr; }
|
||||
const T* ptr() const { return m_ptr; }
|
||||
|
||||
T* operator->() { return m_ptr; }
|
||||
const T* operator->() const { return m_ptr; }
|
||||
T* operator->()
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
T& operator*() { return *m_ptr; }
|
||||
const T& operator*() const { return *m_ptr; }
|
||||
const T* operator->() const
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
T& operator*()
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
const T& operator*() const
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
operator const T*() const { return m_ptr; }
|
||||
operator T*() { return m_ptr; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue