Boost logo

Boost Users :

Subject: [Boost-users] [multi-index] runtime indices
From: Neil Hunt (boost_at_[hidden])
Date: 2009-03-11 18:44:34


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.

Here's what I want to do (pseudocode)

typedef multi_index<MyClass> MyIndex;

MyIndex mi;

int index_id = 0;
mi.add_sorted_index( index_id++, MyIndex::sorted_index_predicate_type(
&some_predicate ) );
mi.add_sorted_index( index_id++, MyIndex::sorted_index_predicate_type(
&some_other_predicate ) );

So basically, add indices at runtime, to take advantage of multi_index's
great features, such
as projection, index updating on modification, etc.

My use case, if it's relevant, is to expose multi_index behaviour on objects
from a dll.
Where obviously the calling module can't specify at compile time the
required indices.

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.)

Neil



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