core: assert that Ptr is not null on dereference
This way it is possible to catch errors even if the pointer is not actually dereferenced, for example when it is used to call an object method or stored as a reference.
This commit is contained in:
@@ -780,6 +780,7 @@ template <typename T>
|
||||
T *
|
||||
Ptr<T>::operator -> ()
|
||||
{
|
||||
NS_ASSERT_MSG (m_ptr, "Attempted to dereference zero pointer");
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
@@ -787,6 +788,7 @@ template <typename T>
|
||||
T *
|
||||
Ptr<T>::operator -> () const
|
||||
{
|
||||
NS_ASSERT_MSG (m_ptr, "Attempted to dereference zero pointer");
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
@@ -794,6 +796,7 @@ template <typename T>
|
||||
T &
|
||||
Ptr<T>::operator * () const
|
||||
{
|
||||
NS_ASSERT_MSG (m_ptr, "Attempted to dereference zero pointer");
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
@@ -801,6 +804,7 @@ template <typename T>
|
||||
T &
|
||||
Ptr<T>::operator * ()
|
||||
{
|
||||
NS_ASSERT_MSG (m_ptr, "Attempted to dereference zero pointer");
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user