I am trying to define a recursive construct like a task farming. Here, I am trying for two operands which recursively can work for any number of operands as it can nest itself.
template <typename T1, typename T2>
class Farm
{
private:
T1 *task1;
T2 *task2;
public:
// save them so that I can use them when invoking call operator
Farm(T1 *_t1, T2 *_t2): task1(_t1), task2(_t2) { }
void operator()()
{
// invoke call operator, meaning a farm could be a task (arbitrary nesting)
(*task1)();
(*task2)();
}
};
int main()
{
... create two pointer(A *a, B *b...)
Farm(a,b); // error: missing template arguments before ‘(’ token
Farm<A, B>(a,b); // in this works, it works
}
The problem is with auto-detection of template arguments which is not working in this case. What am I doing wrong and how could I achieve this template parameters implicit detection by gcc compiler.
Thanks!