LinkedList: Make sure the contained type inherits from DoublyLinkedListNode<T>

This commit is contained in:
apio 2022-12-17 13:49:47 +01:00
parent 2cbc9fa385
commit ace674e518
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <luna/Option.h> #include <luna/Option.h>
#include <luna/TypeTraits.h>
template <typename T> inline Option<T*> nonnull_or_error(T* ptr) template <typename T> inline Option<T*> nonnull_or_error(T* ptr)
{ {
@ -57,6 +58,8 @@ template <typename T> class DoublyLinkedList
{ {
using Node = DoublyLinkedListNode<T>; using Node = DoublyLinkedListNode<T>;
static_assert(IsBaseOf<DoublyLinkedListNode<T>, T>);
public: public:
void append(T* ptr) void append(T* ptr)
{ {