
Boris Schaeling wrote:
All the key extractors in the documentation of Boost.MultiIndex return one value for an element in a container. Is it somehow possible to use a 1:n relationship between element and value?
The documentation uses this container definition (among others):
typedef multi_index_container< employee, indexed_by< hashed_unique< const_mem_fun<employee, std::string, &employee::name> >
employee_set;
Let's assume an employee can have more than one name (std::string becomes std::vector<std::string>). Now if someone searches for Tom or John the same employee should be returned by the container. Is this possible?
A vector of strings is still an object, and hashed_unique indexes are unique. For indexes that allow duplicate items you want "equal_range" like: typedef pmt_t::index<pid>::type pid_idx_t; pair<pid_idx_t::iterator,pid_idx_t::iterator> pid_match = pid_idx.equal_range(50); while(pid_match.first != pid_match.second ) { } Regards. Pedro.
Boris
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users