Subject: [boost] task_array<n> and variadic templates
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-11-18 20:18:08


Hi,

I want to create an static task_array<n> which must be initiaized with n functors.

In pseudo code:

template <std::size N>
struct task_array {
    template <typename F_1, ..., typename F_N>
    task_array(F_1 f1, ..., F_N fN);
};

My current implementation with N=1..3 is like that

template <std::size N>
struct task_array;

template <>
struct task_array<1>;
 {
    template <typename F_1,>
    task_array(F_1 f1);
};
template <>
struct task_array<2>;
 {
    template <typename F_1, typename F_2>
    task_array(F_1 f1, F_2 f2);
};

template <>
struct task_array<3>;
 {
    template <typename F_1, typename F_2, typename F_3>
    task_array(F_1 f1, F_2 f2, F_3 f3);
};

I can use the Boost.Preprocessor library to generate this up to a maximum know at compile time, but can I define this class with the help of variadic templates? If yes how?

Thanks in advance,

Vicente