Let's say I have following class template:
template<typename T>
class Foo
{
int value;
public:
int& operator() (int some_arg) { return value; }
int operator() (T t) { return value; }
};
I use it like that:
int main()
{
Foo<double> f;
double x = 3;
f(x);
//...
}
I get compilation error 2 overloads have similar conversions
which refers to calling: f(x)
.
-
Shouldn't I get such error only if I would pass
int
as template argument? -
Is there a way to solve this issue but without replacing one of the operators with function or
[]
operator?
Aucun commentaire:
Enregistrer un commentaire