On 02/04/2014 04:35 PM, syvyi wrote:
What if the composite key should be parameterized from a file?
In the case of <raw> struct phonebook_entry { std::string family_name; std::string given_name; std::string phone_number;
phonebook_entry( std::string family_name, std::string given_name, std::string phone_number): family_name(family_name),given_name(given_name),phone_number(phone_number) {} };
// define a multi_index_container with a composite key on // (family_name,given_name) typedef multi_index_container< phonebook_entry, indexed_by< //non-unique as some subscribers might have more than one number ordered_non_unique< composite_key< phonebook_entry, member
, member > >, ordered_unique< // unique as numbers belong to only one subscriber member > phonebook;
</raw>
the lines member
, member should be auto-generated by reading a composite key from a file.
That use case sounds incompatible with composite keys, which must be defined at compile time. In that case, I would recommend creating individual indices on the container for each field that you might want to use at runtime, but you would lose the composite key functionality. Jason