|
Boost : |
Subject: [boost] [multi_index] feature proposal: member keys and typeless specification of keys
From: JOAQUIN M. LOPEZ MUÑOZ (joaquin_at_[hidden])
Date: 2011-05-08 07:31:32
Hi all,
This is a proposal for inclusion of two new features into Boost.MultiIndex,
mem_key and BOOST_MULTI_INDEX_AUTO_KEY.
Consider the following:
struct foo
{
int x;
int bar();
int baz()const;
};
typedef multi_index_container<
foo,
indexed_by<
ordered_unique<member<foo,int,&foo::x> >,
ordered_unique<mem_fun<foo,int,&foo::bar> >,
ordered_unique<const_mem_fun<foo,int,&foo::baz> >
>
> multi_t;
Note that we have to use member, mem_fun or const_mem_fun
depending on the kind of key used. mem_key allows for a uniform
specification syntax:
typedef multi_index_container<
foo,
indexed_by<
ordered_unique<mem_key<int foo::*,&foo::x> >,
ordered_unique<mem_key<int (foo::*)(),&foo::bar> >,
ordered_unique<mem_key<int (foo::*)()const,&foo::baz> >
>
> multi_t;
This in itself gains us relatively little; but if we have a C++11 compiler
with decltype, BOOST_MULTI_INDEX_AUTO_KEY can use mem_key
in a way that dispenses with the need for specifying the type of
the key!
typedef multi_index_container<
foo,
indexed_by<
ordered_unique<BOOST_MULTI_INDEX_AUTO_KEY(&foo::x)>,
ordered_unique<BOOST_MULTI_INDEX_AUTO_KEY(&foo::bar)>,
ordered_unique<BOOST_MULTI_INDEX_AUTO_KEY(&foo::baz)>
>
> multi_t;
Some requests and questions:
1. If you're interested in these features, please download the attached
mem_key.hpp file, play with it and report on successful/problematic
usage.
2. Do you think this is worth including in Boost.MultiIndex?
3. Proposals on the naming scheme?
Thank you,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
________________________________
Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo.
This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at.
http://www.tid.es/ES/PAGINAS/disclaimer.aspx
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk