
On Thu, 19 Jan 2006 06:17:02 -0200, Joaquín Mª López Muñoz <joaquin@tid.es> wrote:
Bruno Martínez ha escrito:
On Sat, 31 Dec 2005 18:01:00 -0200, Maxim Yegorushkin <maxim.yegorushkin@gmail.com> wrote:
The most common use cases for intrusive containers are:
* when one would like to store non-copyable elements in a container * when it's beneficial to avoid needless data copy in performance critical applications
For me, it's the ability to get an iterator from a pointer.
Leaving aside the extra benefits intrusive containers can bring in, the ability of getting an iterator from a pointer to the element is implementable for regular multi_index_containers --matter of fact, this feature is internally used in the preview 1.34 version of Boost.MultiIndex I announced yesterday.
Really? Great!
* What is the envisioned application scenario for this feature?
I frequently do something like this: #include <list> struct part; struct whole { std::list<part*> parts; }; struct part { part(whole& w) : my_whole(&w) { me = my_whole->parts.insert(my_whole->parts.end(), this); } ~part() { my_whole->parts.erase(me); } whole* my_whole; std::list<part*>::iterator me; };
* Would you advocate having it in Boost.MultiIndex?
Yes. I would like multi_index to evolve into a solution to representing UML class diagrams in C++, the same way the StateCharts lib does for State Charts. In that case all classes know in which collections they are, so intrusion is natural. I find more natural to just declare in which collections a class is. Bruno