468,249 Members | 1,502 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Explicit template arguments for operator()

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

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

int main() {
Foo f;

// Cannot deduce Func
f();

// Illegal expression
f<Bar>();

// Works fine
f.operator()<Bar>();
}
Sep 17 '08 #1
1 1264
On 9月17日, 下午9时46分, James Daughtry <mordoc...@hotmail.comwrote:
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.

--
Best Regards
Barry
Sep 18 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Tanmoy Bhattacharya | last post: by
4 posts views Thread by Mat DeLong | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.