On Sun, Jan 23, 2011 at 2:40 AM, TONGARI <tongari95@gmail.com> wrote:


2011/1/23 Vivek <vivek@xmain.com>

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?

That's perfect. I didn't make the connection that a function invocation only requires types that are *convertible* to the argument types, not necessarily exactly the argument types. And the conversion operator can handle fetching the data. And yes, the data source is a singleton.

Thanks

Vivek