Boost logo

Boost :

Subject: Re: [boost] [fusion] is there an adapter for C-arrays?
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-02-06 19:48:18

----- Original Message -----
From: "Joel de Guzman" <joel_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, February 07, 2010 1:20 AM
Subject: Re: [boost] [fusion] is there an adapter for C-arrays?

> On 2/7/2010 3:34 AM, vicente.botet wrote:
>> Hi,
>> I need to visit the members of a C++ type using Fusion sequences. For structures I plan
>> to use BOOST_FUSION_ADAPT_STRUCT. I need also to visit also c-arrays (with static
>> size). I see that there is already an adapter for boost::array. Is there an adapter for
>> C-arrays?
> Sorry, no. Would you want to contribute one? It's easy if you
> take a look at the boost::array adapter.


Well if doesn't exists I will need to see how to do it :) I will inform you when I reach to get something.

I don't know if I'm taking the good way. I need to apply a function to all the elements of a compound C++ type satisfying a given type constraint. For example, if I have

struct Type {
    void f();
struct D1 : Type {};
struct D2 : Type {};
struct S1 {
    D1 d1;
    int i;
struct S2 : Type {
    char c;
    S1 s1;
    D2 d2;

S2 a[3];

I would like to apply f() to all the instances inheritig from Type, that is { a[0], a[1], a[2], a[0].s1.d1, a[1].s1.d1, a[2].s1.d1,a[0].d2, a[1].d2, a[2].d2}

I think that I will need to see every type as a sequence, then make a flat view of the tree, restrict with a filter_view and last apply the function on the resulting sequence.

Is there a simple way to implement this flat view? Or even better, is it already available?


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