Explicit template arguments for operator()

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::eek:perator()\n";
Func()();
}
};

class Bar {
public:
void operator()() {
cout << "Bar::eek:perator()\n";
}
};

int main() {
Foo f;

// Cannot deduce Func
f();

// Illegal expression
f<Bar>();

// Works fine
f.operator()<Bar>();
}
 
B

Barry

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:

14.8.1/5 give some 'note' closely on this, but not exactly,
I wonder adding something about 'overloaded operators' here is
approriate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top