Boost MultiIndex container - using multiple composite keys
Hi All, I'm new to this mailing list. I have been using the boost multi index container for a while. I now have requirement where I need to create multiple composite keys. The example 7 (composite keys example) in the multi index container documentation shows that it is possible to define multiple composite keys. But how do we use a specific composite key when searching the data. Does the container differentiate the composite keys using the key data types? Thanks, Charitha --------------------------------- How low will we go? Check out Yahoo! Messengers low PC-to-Phone call rates.
Charitha Herath ha escrito:
Hi All,
I'm new to this mailing list. I have been using the boost multi index container for a while. I now have requirement where I need to create multiple composite keys.
The example 7 (composite keys example) in the multi index container documentation shows that it is possible to define multiple composite keys. But how do we use a specific composite key when searching the data. Does the container differentiate the composite keys using the key data types?
Thanks,
Charitha
Hello Charitha, I'm not getting whether your problem is related with composite keys or with *multiple* composite keys, i.e. having several indices each with its own composite key. Allow me to assume your problem is related with the usage of one composite key, please correct me otherwise. The usage of composite keys is explained in http://boost.org/libs/multi_index/doc/advanced_topics.html#composite_keys Basically, when looking up an index that uses a composite key, you must pass the different key arguments inside a boost::tuple, like shown in the phonebook example in the docs: // search for Dorothea White's number phonebook::iterator it=pb.find( boost::make_tuple(std::string("White"),std::string("Dorothea"))); Additionally, with ordered indices you can also specifiy just the first N arguments and leave the rest undefined: // look for all Whites std::pairphonebook::iterator,phonebook::iterator p= pb.equal_range(boost::make_tuple(std::string("White"))); Is there anything about this that is not sufficiently clear to you? I've got the hunch I haven't addressed your question, so it'd be great if you can elaborate a little more. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (2)
-
Charitha Herath
-
Joaquín Mª López Muñoz