
Bruno Martínez ha escrito:
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; };
OK, but seems to me the kind of idioms you propose are best served by an intrusive version of multi_index_container. The "pointer to iterator" feature does not help in isolation, if I'm understanding you right. Joaquín M López Muñoz Telefónica, Investigación y Desarollo