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:
Andreas Kling 2019-08-02 10:34:40 +02:00
parent a9a1a5dfa9
commit d9cc3e453c

View file

@ -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; }