Boost logo

Boost :

Subject: Re: [boost] [multi_index] Taking advantage of C++17 auto template params to simplify key specification
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2017-09-27 11:23:14


On 09/27/17 13:53, Joaquin M López Muñoz via Boost wrote:
> Consider the following:
>
>   struct element
>   {
>     int x;
>     int f()const{return x;}
>   };
>
>   int gf(const element& e){return e.x;}
>
>   using container=multi_index_container<
>     element,
>     indexed_by<
> ordered_unique<member<element,int,&element::x>>,
> ordered_unique<const_mem_fun<element,int,&element::f>>,
>       ordered_unique<global_fun<const element&,int,&gf>>
>     >
>   >;
>
> With the advent in C++17 of auto non-type template parameters, it is
> very easy to
> provide a boost::multi_index::key class template so that we can write:
>
>   using container=multi_index_container<
>     element,
>     indexed_by<
>       ordered_unique<key<&element::x>>,
>       ordered_unique<key<&element::f>>,
>       ordered_unique<key<&gf>>
>     >
>   >;
>
> (Example at http://coliru.stacked-crooked.com/a/5742c768cc093c03 ).
>
> Is there interest in adding this to Boost.MultiIndex? Comments on this or
> alternative syntaxes?

Looks interesting. The C++03 version always seemed verbose to me. Will
it also support function objects for key extraction?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk