Boris ha escrito:
struct employee { std::string name; };
typedef multi_index_container< employee, indexed_by< hashed_unique
> mi;
If I want to change the index to make it case-insensitive I have to write my own key extractor, right? Would the following code then be correct (it is based on boost::multi_index::member)?
[...] Yep, it is correct, though possibly a little overkill; you could use a simpler key extractor for the task at hand, like this: struct employee_case_insensitive_name_extractor { typedef std::string result_type; std::string operator()(const employee& x) const { return boost::algorithm::to_lower_copy(x.name); } };
With the following typedef I get a container which does not change the name of an employee (I want to retain the name without making it lower- or uppercase) but refuses items with the same case-insensitive name?
typedef multi_index_container< employee, indexed_by< hashed_unique
> mi2;
Well, you just have to try in order to find out :) Looks pretty much like it'll do what you want. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo