473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 1441
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: C. Carbonera | last post by:
/* Hi, I have a problem with explicit instantiation of templates in Visual C++ 6.0. I have provided the source below. I have an example of a function template that produces incorrect output in...
5
by: BCC | last post by:
In looking through some code I have inherited, I notice a lot of places where the programmer used operator() as a function call: void operator() (int x, int y); Rather than an explicit...
9
by: Tanmoy Bhattacharya | last post by:
Hi, This is a question about whether I am right that a particular syntactic sugar is missing in C++. Let me explain with an example. Let us say I have a class for complex numbers, and I want...
4
by: Mat DeLong | last post by:
I have never been stuck on programming something before to the point I give up... this is a first. I am programming what should be something very easy in C++... using Templates. Here is the code,...
3
by: IR | last post by:
Hi, I've been trying to do the following (which doesn't compile) : template<class T, class F = Example<T struct Example { F foo(); };
1
by: petschy | last post by:
hello, i've run into an error when qualifying a copy ctor 'explicit'. the strange thing is that i get a compiler error only if the class is a template and declare the variable as X<Zx = y....
42
by: coder_lol | last post by:
Thanks everyone again for contributing to helping me clear C++ confusions. I did some serious reading on copy constructors and assignments and I think I've got a good handle on the memory stuff. ...
7
by: Protoman | last post by:
Is this an efficient way to integrate an explicit function of x from a to b: #include <iostream> using namespace std; class Integrate { public: Integrate(long double (*f)(long double&...
2
by: Barry | last post by:
The following code compiles with VC8 but fails to compiles with Comeau online, I locate the standard here: An explicit specialization of any of the following:
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.