Benedetto Proietti | 9 Feb 04:54
Picon

Re: [fusion] problems with accumulate metafunction

Greetings.
 
I am kind of newbie to Boost.Fusion.
 
I have a sequence of "Field"s:
 
typedef fusion::vector<
    Field<int, 3, Check1, ..>,
    Field<float, 8, Check2, ..>,
    Field<MyString, 2, Check3, ..>,
    ...
>  MySequence;
 
Each "Field" knows how to (de)serialize, has some checking policy and a few more little stuff.
"Field" also has a "int" property "TypeSize":
 
static const int TypeSize = somevalue_known_at_compile_time;
 
 
I'd like to traverse the type "MySequence" and get the sum of all the sizes at compile time.
Like:  
Field<int,3,Check1>::TypeSize + Field<float, 8, Check2>::TypeSize + Field<MyString,2,Check3>::TypeSize + ... ;
 
I tried playing with fusion::accumulate and mpl<int_> but couldn't do it.
There's no much documentation/examples about fusion (correct me if I am wrong please).
How can I get the accumulated sum of Field<...>::TypeSize of all the members in "MySequence"? 

Thanks in advance,
  Benedetto
 

PS: It's not really a priority (the cost of doing that at runtime once for object is minimal), but I'd really like to fully understand Fusion, which I have found very useful so far.
 
_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Gmane