DoublyLinkedList: Make DoublyLinkedListCLink more useful.

Before, it just used a hardcoded Element::link member. Now,
it uses whatever one is specified based on the template
arguments.

No source compatibility breakage intended.

Change-Id: I62128921766df0b705488eb64402f902334f2ed0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10589
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
This commit is contained in:
Augustin Cavalier
2026-03-30 22:11:53 +00:00
committed by waddlesplash
parent 397b2e8189
commit 15594f62fe
+14 -13
View File
@@ -83,22 +83,23 @@ public:
}
};
// DoublyLinkedListCLink - interface to struct list
template<typename Element>
// DoublyLinkedListCLink - interface to struct list (or equivalent)
template<typename Element, typename CLink = struct list_link,
CLink Element::* LinkMember = &Element::link>
class DoublyLinkedListCLink {
private:
typedef DoublyLinkedListLink<Element> Link;
private:
typedef DoublyLinkedListLink<Element> Link;
public:
inline Link* operator()(Element* element) const
{
return (Link*)&element->link;
}
public:
inline Link* operator()(Element* element) const
{
return (Link*)&(element->*LinkMember);
}
inline const Link* operator()(const Element* element) const
{
return (const Link*)&element->link;
}
inline const Link* operator()(const Element* element) const
{
return (Link*)&(element->*LinkMember);
}
};
// for convenience