Boost Users :
Subject: Re: [Boost-users] [multi-index] runtime indices
Date: 2009-03-12 05:05:50
Neil Hunt escribió:
> Hi all,
> I have been using multi-index with great success, but have struck
> a requirement that sort of fits into the remit of multi-index, but isn't
> catered for.
> So basically, add indices at runtime, to take advantage of
> multi_index's great features, such
> as projection, index updating on modification, etc.
> Is this a sensible addition to multi-index, or is it best implement
> using other mechanisms.
> (Having to re-implement many of the great features of multi-index
> doesn't seem desireable.)
This is a non-trivial addition to Boost.MultiIndex. In fact, a run-time
would be a different beast than the classic multi_index_container in
1. multi_index_container memory usage is very efficient as internal
nodes pack all the
(statically known) indices' headers into one big structure. In the
run-time case, this
cannot be done and we would necessitate smarter internal structures,
incurring at least one
extra pointer per node per index. Also, if we allow to add indices to a
container things become much harder --existing nodes would have to be
extra index info.
2. If we wish our run-time multi_index_container to provide an
akin to get<N> in the classical multi_index_container, some sort of type
to be resorted to. This could be given a nice treatment using some
library for dynamic
polymorphism such as Turkanis' candidate Boost.Interfaces
(http://www.coderage.com/interfaces/ ), which unfortunately never made
it into Boost.
FWIW, I investigated this problem in 2006 and sketched some ideas in
conclusion was that the thing is doable but complicated, and I saw no
for it. I don't think I'll resume that task --sorry.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net