
On 4/22/13 11:08 AM, Antony Polukhin wrote:
2013/4/22 Michael Marcin
: <...> You can take a non-intrusive container and make it intrusive?
Black magic?
And how are you going to make intrusive container manage memory and objects lifetime?
Stefan Strasser said it well not long ago, I'll just quote him. On 4/6/13 10:08 AM, Stefan Strasser wrote:
Zitat von Vadim Stadnik
: If Boost.Intrusive containers (and containers based on Boost.Intrusive containers) outperform all other containers, they are the best possible choice. They are winners by both of these important parameters. Otherwise their advantage is not so obvious.
a non-intrusive container that is implemented in terms of an intrusive container is as efficient as any other non-intrusive container. it is a little more work to implement, to provide the Intrusive public interface. However, you can not implement an Intrusive container in terms of a non-intrusive container but have to reimplement the entire data structure. That's why Boost.Intrusive is not based on namespace std containers but are a reimplementation of the algorithms.
The implementation of a non-intrusive container in terms of an intrusive one is as simple as:
struct value_holder : intrusive::hook{ T value; };
and forwarding all calls of the STL container interface.