Boost logo

Boost Users :

Subject: Re: [Boost-users] [Fusion] Building parameter list for fusion::invoke
From: TONGARI (tongari95_at_[hidden])
Date: 2011-01-23 02:40:31


2011/1/23 Vivek <vivek_at_[hidden]>

> 2011/1/22 Vivek <vivek_at_[hidden]>
>
> > Or alternatively, is there a direct way to initialize a fusion vector?
>
> IIUC, its ctor just do the job, not?
>
> The problem is I don't know the arity or parameter types of the function
> being called. I just have a source of data (which can be simplified to TYPE
> data = data_source<TYPE>().pop();) and arbitrary functions being passed in.
>
Sorry if I missed your point...here comes an idea:
Use Fusion's MPL sequences adapters, so you can have:

typedef typename
        mpl::transform
        <
            parameter_types
          , from_data_source<mpl::_1>
          , mpl::back_inserter<mpl::vector<> >
>::type
data_source_provider; // a MPL sequence

And invoke as:

fs::invoke(f, data_source_provider());

where from_data_source<T> is defined as:

template<class T>
struct from_data_source
{
    operator T() const
    {
        return data_source<T>().pop();
    }
};

Maybe your data_source<T>() is some singleton for the data source?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net