0

i am a newbie to boost multi_index,

and currently trying to create a multi index container for which i will be able to define indices after the container is declared.

In particular i want to load a number of different mysql dbs and thus need a generic structure in which keys are not known a-priori. Can boost::multi_index support such a functionality? I have tried to use the 'ctor_args_list' option but it seems not to work for this case.

Thank you very much!

1 Answers1

1

Strictly speaking, the definition of a boost::multi_index_container is a compile-time business, so you can't say add or remove indices at run time. The closest you can probably get to what you want is to define a predefined number of ordered_non_unique<std::function<int(const element&)>> or similar and then provide the ordering functions at construction time (with ctor_arg_list). This means you're restricted to a maximum number of indices and the ordering functions must take a rigid form (in the example, they are passed the element and return a conventional int expressing whatever ordering applies). Happy to assist back if you take this route.

Joaquín M López Muñoz
  • 5,243
  • 1
  • 15
  • 20