J
James Daughtry
It seems impossible to explicitly specify template arguments for an
overloaded operator() without giving the full name. I'd like to know
where in the C++ standard this behavior is defined. I can't seem to
find it. Here's some code the shows what I'm talking about:
#include <iostream>
using namespace std;
class Foo {
public:
template <typename Func>
void operator()() {
cout << "Foo:perator()\n";
Func()();
}
};
class Bar {
public:
void operator()() {
cout << "Bar:perator()\n";
}
};
int main() {
Foo f;
// Cannot deduce Func
f();
// Illegal expression
f<Bar>();
// Works fine
f.operator()<Bar>();
}
overloaded operator() without giving the full name. I'd like to know
where in the C++ standard this behavior is defined. I can't seem to
find it. Here's some code the shows what I'm talking about:
#include <iostream>
using namespace std;
class Foo {
public:
template <typename Func>
void operator()() {
cout << "Foo:perator()\n";
Func()();
}
};
class Bar {
public:
void operator()() {
cout << "Bar:perator()\n";
}
};
int main() {
Foo f;
// Cannot deduce Func
f();
// Illegal expression
f<Bar>();
// Works fine
f.operator()<Bar>();
}