Amit Prakash Ambasta
Hi, The structure I'm building is to hold a graph. However, since I need to only perform lookups on the nodes via multiple indices, I'm using a struct with a pointer to parent as a member and Boost.MultiIndex to instances.
Elements are not necessarily inserted in sequential order. However, there is some strict ordering in insertion (child elements can not be inserted before parent elements)
I think I understand. If there can be more than one children to the same parent (i.e. if parent->child arrows don't form a linear sequence) then no index can substitute for the kind of design you have.
[...] Hence I am trying to convert the iterator to container of LinkList via index_ll.find(0) to a pointer to LinkList instance..
i.e. LinkList const& parent = *index_ll.find(0); ill.insert(LinkList{1, (LinkList*)(&(*parent))})
The cast is ugly an potentially dangerous, as you can modify a key of an element via a non-const LinkList*, thus breaking the container invariants (this is why Boost.MultiIndex iterators are constant). If your design can handle const pointers to parent: struct LinkList { size_t index; const LinkList* parent; //... }; then no cast is needed. Other than this, your technique works as long as you play nicely with keys. Joaquín M López Muñoz Telefónica