|
Boost Users : |
From: René Haber (rene.haber_at_[hidden])
Date: 2006-10-03 05:43:38
Hello,
I'm looking for an easy way to iterate over a set by a user selected
index. A little example:
[code]
struct Person {
std::string name;
std::string city;
};
struct city{};
struct name{};
typedef multi_index_container<
Person,
indexed_by<
ordered_unique< tag<name>, member<Person, std::string, &Person::name> >,
ordered_non_unique< tag<city>, member<Person, std::string,
&Person::city> >
>
> person_set;
typedef Person::index<name>::type Person_by_name;
typedef Person::index<city>::type Person_by_city;
person_set persons;
for(Person_by_name::iterator it = persons.get<name>().begin(); .....) {...}
[/code]
This for loop is hard-coded to iterate over the set sorted by name. How
can I dynamically change the iterator used in this loop to let the user
decide the sort criteria?
Greetings,
René
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