Following some ideas discussed about a year ago, I've added a new
boost::multi_index::key construct allowing for a very terse
specification of predefined
key extractors in C++17 compliant environments. For instance, given
struct phonebook_entry
{
std::string family_name;
std::string given_name;
std::string phone_number()const;
};
int num_calls(const phonebook_entry&);
a classical definition like
typedef multi_index_container<
phonebook_entry,
indexed_by<
ordered_unique<
const_mem_fun
>,
ordered_unique<
global_fun
>,
ordered_non_unique<
composite_key<
phonebook_entry,
member,
member
>
>
>
> phonebook;
can now be written as
typedef multi_index_container<
phonebook_entry,
indexed_by<
ordered_unique<
key<&phonebook_entry::phone_number>
>,
ordered_unique<
key
>,
ordered_non_unique<
key<&phonebook_entry::family_name,&phonebook_entry::given_name>
>
>
> phonebook;
If you have a C++17 compiler, you can play with this new feature by
simply copying
https://github.com/boostorg/multi_index/blob/develop/include/boost/multi_ind...
into your local Boost installation. More info at
https://www.boost.org/doc/libs/develop/libs/multi_index/doc/tutorial/key_ext...
https://www.boost.org/doc/libs/develop/libs/multi_index/doc/reference/key_ex...
Comments and suggestions, specially before Boost 1.69 ships and this becomes
more or less frozen, are most welcome.
Best regards,
Joaquín M López Muñoz