From f05fea441cd255971dd15f97a9e918e04a0da638 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 3 Mar 2024 14:52:23 +0100 Subject: [PATCH] libluna: Add LinkedList tags --- libluna/include/luna/LinkedList.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/libluna/include/luna/LinkedList.h b/libluna/include/luna/LinkedList.h index a9e65276..52d66dc8 100644 --- a/libluna/include/luna/LinkedList.h +++ b/libluna/include/luna/LinkedList.h @@ -8,7 +8,7 @@ template class LinkedListNode { using SelfType = LinkedListNode; - private: + protected: SelfType* m_next_node; SelfType* m_last_node; @@ -284,3 +284,29 @@ template class LinkedList usize m_count = 0; }; + +struct Tag : public LinkedListNode +{ + public: + Tag(void* ptr) : m_ptr(ptr) + { + } + + ~Tag() + { + detach_from_list(); + } + + void* ptr() + { + return m_ptr; + } + + template T& as() + { + return *static_cast(m_ptr); + } + + private: + void* m_ptr; +};