Ovanes Markarian ha escrito:
Hello,
unfortunately I can't figure out how to specify member access for a hash function to a hash indexed mult-index container containing boost::tuple. I would like to hash by the first tuple member only. Can someone help?
Here is an example:
typedef boost::tuples::tuple<std::string, int, some_other_type> my_tuple;
struct hash {};
multi_index_container< my_tuple , indexed_by< hashed_unique<tag<hash>, ???? , other_index_type... >
hashed_container;
I would like this tuple to be hashed by the first member. boost::tuple has no access member function to the first member. The only way to access it is:
my_tuple t("aaa", 10, xyz);
std::string s(get<0>(t));
but as I can see the doc for multi_index it supports only access through a member function or by using the hash function which is applied to the whole object. The second scenario does not suit well, since I must pass an object instance to the hasher, where I would like to pass a name only. Should I write my own key_extractor class? Any help is appreciated.
Hello Ovanes, the issue of using a boost::tuple member as a key for a Boost.MultiIndex index has arisen in the past. Please read the following posts: http://lists.boost.org/boost-users/2005/12/16087.php http://lists.boost.org/boost-users/2005/12/16088.php Do they address your problem? Best regards, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo