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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top