Boost logo

Boost :

Subject: [boost] [fusion] flat fusion sequence of all the node of a type
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-05-24 18:42:38


I want to create a fusion sequence that give access to all the nodes of a struct/class/array that inherit from a given class TO.
If we remove this constraint, the fusion sequence can be seen as flattening the tree of nodes in a given order. Once I will have this I can use filter_if<is_base_of<TO,_> >

class TO;
struct W {
    TO t;
struct X : TO { // direct
    TO* to_ptr;
    char c;
struct Y : TO { // direct with embeddeds
    X x;
    int i;
struct Z { // with embeddeds
    Y y[2];
    TO t;
    W w;

Z z;

the flat view corrsponds to

z.w.t, z.w, z.t, z.y[0].x.to_ptr, z.y[0].x.c, z.y[0].x, z.y[0], z.y[1].x.to_ptr, z.y[1].x.c, z.y[1].x, z.y[1], z.y, z

The filtered view corrsponds to

Y z.y[0]
X z.y[0].x
Y z.y[1]
X z.y[1].x
TO z.t
TO z.w.t

If I have fusion sequence struct adaptors for W, X, Y, Z. Is there a simple and run-time efficient way to get this fusion sequence adaptor or I need to do something similar to the struct adaptor? Have others had a similar need already?


P.S. For my personal usage I need only a forward sequence.

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