The Boost.Intrusive library doesn't litterally ask you to define prev
and next
pointers -- in that part of the documentation, the presence of prev
and next
pointers is merely a conceptual illustration of how intrusive containers work.
The actual of defining intrusive containers is to include a hook through inheritance or as a member that contains the prev
and next
pointers. By including several hooks (tagged with different static types), you can include the same object in several differnet intrusive containers (each tagged with different static types).
See http://www.boost.org/doc/libs/1_38_0/doc/html/intrusive/usage.html to see how the hooks work. See this StackOverflow answer for an example of how to do this with multiple intrusive contianers.
This has some limitations -- you can't include your objects in an arbitrary set of multiple intrusive containers defined at runtime -- you have to know what containers you want to use when you're coding them initially, and build knowledge of each one into your objects.