LinkedList: Fix nonnull_or_error

This commit is contained in:
apio 2022-12-06 18:22:45 +01:00
parent 2734353a5d
commit 07e6ebd3cc
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -3,7 +3,9 @@
template <typename T> inline Result<T*> nonnull_or_error(T* ptr) 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; template <typename T> class DoublyLinkedList;
@ -69,12 +71,12 @@ template <typename T> class DoublyLinkedList
Result<T*> next(T* item) 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) 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) template <typename Callback> void for_each(Callback callback)