|
Boost Users : |
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-04-23 12:11:05
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.
With Kind Regards,
Ovanes
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