473,511 Members | 17,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function matching with constructed args

I have the following function call

p->f(G());

where p is a pointer of type P

and a declaration in scope of

void P::f(G& g);

the gcc 3.2 compiler won't match the call to the function.

If I have

G gTmp;
p->f(gTmp);

with the same function declaration in scope
everything works.

Why? 4 other compilers accept it including gcc 2.6.

Is there a gcc 3.2 option to make this work?
Jul 22 '05 #1
1 985

"Mike Cote" <mi******@earthlink.net> wrote in message news:bc*************************@posting.google.co m...
p->f(G());
void P::f(G& g);

the gcc 3.2 compiler won't match the call to the function.\
Of course. G() is an rvalue. You can not bind an rvalue to a (non-const)
reference. It would match
void P::f(const G& g);
G gTmp;
p->f(gTmp);

with the same function declaration in scope
everything works.
gTmp is an lvalue.
Why? 4 other compilers accept it including gcc 2.6.


They are broken if they do.

Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1599
by: Michael | last post by:
In the book 'Text Processing Python,' they present a function that I'm having a real hard time understanding. apply_each = lambda fns, args=: map(apply, fns, *len(fns)) I understand that the...
6
1167
by: Steven Bethard | last post by:
I wrote: > If you really want locals that don't contribute to arguments, I'd be > much happier with something like a decorator, e.g.: > > @with_consts(i=1, deftime=time.ctime()) > def foo(x,...
6
4601
by: Manuel | last post by:
Can I invoke a function before main I could do it by invoking it in a Global object's constructor . Is there any other method other than this. Manuel
16
16202
by: WittyGuy | last post by:
Hi, What is the major difference between function overloading and function templates? Thanks! http://www.gotw.ca/resources/clcm.htm for info about ]
2
1755
by: Drew McCormack | last post by:
I have a self written Tensor class which I need to write a number of elementwise operations for (eg sin, cos, abs, conj). I am trying to implement most of these in terms of standard library...
1
3350
by: UK | last post by:
I want to extract the text within the matching parentheses. Eg Input: (S1 > 1 and S2 in ('a','b','c') and (S5 > '05/27/04' and S5 < '05/27/05') and (S4 = 'hello' or S4 = 'world') and (S_price -...
10
1968
by: Fredrik Tolf | last post by:
If I have a variable which points to a function, can I check if certain argument list matches what the function wants before or when calling it? Currently, I'm trying to catch a TypeError when...
3
3628
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
8
3311
by: Alvin | last post by:
I'm making a very simple game in SDL, and I'm not asking for SDL help I hope - this looks like something C++ related, so I'll ask here. I have a class for a simple block, or tile, in the game,...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
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
7356
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
7427
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...
1
7085
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
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.