
On Wed, Sep 27, 2017 at 12:53 PM, Joaquin M López Muñoz via Boost < boost@lists.boost.org> wrote:
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>> >
;
classical def#1
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>> >
;
C++17 def#2
(Example at http://coliru.stacked-crooked.com/a/5742c768cc093c03 ).
template<auto Member> struct key{}; template<typename Class,typename Type,Type Class::*PtrToMember> struct key<PtrToMember>: boost::multi_index::member<Class,Type,PtrToMember>{}; template<typename Class,typename Type,Type (Class::*PtrToMemberFunction)()const> struct key<PtrToMemberFunction>: boost::multi_index::const_mem_fun<Class,Type,PtrToMemberFunction>{}; template<typename Class,typename Type,Type (Class::*PtrToMemberFunction)()> struct key<PtrToMemberFunction>: boost::multi_index::mem_fun<Class,Type,PtrToMemberFunction>{}; template<class Value,typename Type,Type (*PtrToFunction)(Value)> struct key<PtrToFunction>: boost::multi_index::global_fun<Value,Type,PtrToFunction>{}; Is there interest in adding this to Boost.MultiIndex? Comments on this
[...] syntaxes?
I'm out of my depth here, but the fact you use inheritance means the two types are not the same as a consequence, right? I.e. std::is_name<def#1, def#2> is false? And I suppose such partial specialization is not possible with template type aliases to have is_same<> being true? Not sure it matters, just thinking out loud. --DD