LinkedList: Fix nonnull_or_error
This commit is contained in:
parent
2734353a5d
commit
07e6ebd3cc
@ -3,7 +3,9 @@
|
||||
|
||||
template <typename T> inline Result<T*> nonnull_or_error(T* ptr)
|
||||
{
|
||||
return ptr == nullptr ? err(ENONE) : ptr;
|
||||
if (ptr == nullptr) return err(ENONE);
|
||||
else
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template <typename T> class DoublyLinkedList;
|
||||
@ -69,12 +71,12 @@ template <typename T> class DoublyLinkedList
|
||||
|
||||
Result<T*> next(T* item)
|
||||
{
|
||||
return nonnull_or_error(((DoublyLinkedListNode<T>*)item)->m_next_node);
|
||||
return nonnull_or_error((T*)((DoublyLinkedListNode<T>*)item)->m_next_node);
|
||||
}
|
||||
|
||||
Result<T*> previous(T* item)
|
||||
{
|
||||
return nonnull_or_error(((DoublyLinkedListNode<T>*)item)->m_last_node);
|
||||
return nonnull_or_error((T*)((DoublyLinkedListNode<T>*)item)->m_last_node);
|
||||
}
|
||||
|
||||
template <typename Callback> void for_each(Callback callback)
|
||||
|
Loading…
Reference in New Issue
Block a user