Boost logo

Boost :

Subject: [boost] [multi_index] Taking advantage of C++17 auto template params to simplify key specification
From: Joaquin M López Muñoz (joaquinlopezmunoz_at_[hidden])
Date: 2017-09-27 10:53:51

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<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 ).

Is there interest in adding this to Boost.MultiIndex? Comments on this or
alternative syntaxes?

Thank you,

Joaquín M López Muñoz

Boost list run by bdawes at, gregod at, cpdaniel at, john at