To get access to N-th index you could use function get
as follows:
std::pair< hmap::nth_index<3>::type::const_iterator,
hmap::nth_index<3>::type::const_iterator > pit =
hmap.get<3>().equal_range(boost::make_tuple( partnerAge, false ) );
equal_range
returns pair of iterators of N-th index. You will get range of elements that are satisfy the specified condition since your composite key is not unique. To iterate through that range you could use loop from the first iterator to the second iterator.
Consider using named indexes to use them as get<index_name>()
, because specifying actual number is not very readable.
count
has syntax similar to equal_range
:
size_t cnt = hmap.get<3>().count(boost::make_tuple( partnerAge, false ) );
Kirill V. Lyadvinsky
2010-04-19 18:40:45