|
Boost Users : |
Subject: Re: [Boost-users] [multi-index] runtime indices
From: joaquin_at_[hidden]
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.)
Hello Neil,
This is a non-trivial addition to Boost.MultiIndex. In fact, a run-time
multi_index_container
would be a different beast than the classic multi_index_container in
important aspects:
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
non-empty
container things become much harder --existing nodes would have to be
added the
extra index info.
2. If we wish our run-time multi_index_container to provide an
index-retrieving facility
akin to get<N> in the classical multi_index_container, some sort of type
erasure needs
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
code. My
conclusion was that the thing is doable but complicated, and I saw no
real demand
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