I'm creating some classes which represent the functions in the mathematical meaning and their interface is to be 'math-friendly'. To accomplish this I want to create a variadic template operator() methods, which allow user to write defining functions in this way f(x, y) = 2*x + y;
and then getting its value by calling f(4, 5);
. I cannot predict the number of parameters (the number of variables in mathematical function) so I decided to use variadic templates. However overloading operator() twice as a variadic template and calling it causes the "ambigous call" error. Is there some way to overcome it, or do I have to create two seprate methods?
//expressions like f(x, y, z) = x*x+y-z
template <typename... Args>
RichFunction<T> &operator()(Args&&... args)
{
mMainLinears.clear();
setMainLinears(args...);
return *this;
}
//expressions like f(5, 4, 3)
template <typename... Args>
T operator()(Args&&... args)
{
Function<T>::assign(mMainLinears, 0, args...);
return Function<T>::value();
}
Aucun commentaire:
Enregistrer un commentaire