
Hi all,
this is a follow-up of my question of yesterday (Fold a vector of pairs).
The example here is a lot more elaborate and more like the final code
I'd like to achieve.
I still get errors when compiling the code below related the use of
mpl::secondmpl::_2.
I'm trying to generate a multi-index container type that will store
objects generated using inherit_linearly.
The objects contain a number of attributes (all int in this example)
based on a typelist of attribute tags.
I want to generate this container by providing the object type and a
index_list as shown here:
http://www.boost.org/doc/libs/1_49_0/libs/multi_index/doc/tutorial/technique...
I'm trying to compose the index_list using some kind of MPL tag dispatch
based on the unique & non_unique tags to generate unique & non_unique
ordered indices for the container.
It's clear to me that the errors have to do with the MPL placeholder
expressions used in the 3 types passed to the multi_index::member
template class. This is confirmed because if I replace these 3 template
parameters by the ones which are comment out just below the program
compiles fine.
From my previous question I get that the placeholder expressions need
to be evaluated lazily (so no ::type or ::value - obviously the code
below is thus incorrect).
I've been reading section 3.3 of the MPL book on 'Handling Placeholders'
a couple of times and from this it seems I need 3 metafunctions that
call apply<> on the passed placeholder expressions and which would
return each of the types to be passed to multi_index::member<>?
I've been trying different approaches but none have been successful...
I'm still not grasping how to handle these placeholder expressions...
I hope the great minds on this list can bring some light in my clouded
mind...
Thanks & kind regards,
Peter
//-------------------------------------------------
#include
::type {};
struct unique {};
struct non_unique {};
template <typename T>
struct is_unique : boost::false_type {};
template <>
struct is_unique<unique> : boost::true_type {};
template
,
mpl::push_back<
mpl::_1,
bmi::ordered_non_unique<
bmi::member<
Attribute
::type IndexList;
typedef boost::multi_index_container
AttributeList_1;
typedef Object
Object_1_Indicex;
ObjectContainer