|
|
|
|
|
by SamReidHughes
4189 days ago
|
|
You can also make these using this structure: template <class T>
struct node { node<T> *next, *prev; };
template <class T>
struct intrusive_list : private node<T> { };
Your type foo then subclasses the node<foo> type, and in some places intrusive_list<foo> has to statically cast them back down.This means you don't need that messy "T *owner;" pointer anywhere. The downside is that if you want your type to be a member of multiple intrusive lists, you have to make spurious parent classes and inherit from those. |
|