52 ms·
The post is interesting, but is there anything stopping you using the following... template<typename T> struct Link { T obj; Link *
by alexchamberlain 13y ago
The post is interesting, but is there anything stopping you using the following...
template<typename T>
struct Link
{
T obj;
Link *link;
}
That looks pretty much like the intrusive version in memory, right?
- mihai_ionic 13y agoThe point of intrusive lists is to allow access to the link when you provide only the contained object. The way you're thinking of would theoretically work, but you'd have to make sure the compiler isn't adding fancy padding that would break your pointer manipulation and type casting. boost::intrusive::list on the other hand, works in a type-safe manner by having your class either inherit a list hook, or provide it as member and then pass the list implementation a member pointer as template parameter so that it can be accessed.