mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-22 02:26:11 +00: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
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…
Reference in a new issue