F
Fei Liu
Hi, I have a interesting problem here,
class absOP{
template<class T> T operator(T val) { return val < 0 ? -val : val; }
};
Now the problem is I can't seem to use this overloaded operator,
absOP op(..);
int i = -42;
float f = -2.3;
int ai = op(i); //error
ai = op<int>(i); //error
ai = op(i)<int>; //error
ai = <int>op(i); //error
Alas, I tried a couple sane ways to use function template of overloaded
operator () but none seemed to work...Any idea or help is appreciated.
class absOP{
template<class T> T operator(T val) { return val < 0 ? -val : val; }
};
Now the problem is I can't seem to use this overloaded operator,
absOP op(..);
int i = -42;
float f = -2.3;
int ai = op(i); //error
ai = op<int>(i); //error
ai = op(i)<int>; //error
ai = <int>op(i); //error
Alas, I tried a couple sane ways to use function template of overloaded
operator () but none seemed to work...Any idea or help is appreciated.