K
Klaus Schneider
Dear newsgroup,
I want to call a template function with a standard operator (+, /, -, * for
double) as parameter. Here is a minimal example:
template <typename T>
T opIf(T val1, T val2, T (*op)(T,T) )
{
if (val2 != 0)
return op(val1, val2);
else
return (T)0;
}
How can I call this function with e.g. the standard / operator?
double res = opIf(10., 5., operator/);
or similar does not work.
Thanks a lot,
Klaus
I want to call a template function with a standard operator (+, /, -, * for
double) as parameter. Here is a minimal example:
template <typename T>
T opIf(T val1, T val2, T (*op)(T,T) )
{
if (val2 != 0)
return op(val1, val2);
else
return (T)0;
}
How can I call this function with e.g. the standard / operator?
double res = opIf(10., 5., operator/);
or similar does not work.
Thanks a lot,
Klaus