Boost logo

Boost Users :

Subject: Re: [Boost-users] variadic template function using fusion vector
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2010-01-12 22:50:49


noman javed wrote:
> Hi
>
> I want to write a function like that
>
> template<class A, class T0, class T1, ..., class Tn>
> execute(const A& a, T0& arg0, T1& arg&, .. , Tn& argn)
> {
> boost::fusion::vector<T0,...,Tn> vec(arg0, arg1, .., argn);
> /* rest of the code */
> }
>
> Can anybody guide me how can I write this function without overloading
> it with different number of args?
>

Write a function that takes one single argument - the vector. Then
use appropriate adapters to transform it.

See the documentation of the Functional module of Fusion for details.

Note that this way does not require your compiler to support variadic
template functions - using those is another option.

Regards,
Tobias


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