Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Function matching with constructed args

Reply
Thread Tools

Function matching with constructed args

 
 
Mike Cote
Guest
Posts: n/a
 
      01-22-2004
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?
 
Reply With Quote
 
 
 
 
Ron Natalie
Guest
Posts: n/a
 
      01-22-2004

"Mike Cote" <> wrote in message news: 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
forwarding Args&&... vs forwarding Args... Andrew Tomazos C++ 5 01-05-2012 11:15 PM
C++0x -- fun(Args&...) and fun(Args const&...) er C++ 2 12-20-2010 07:52 PM
Is there a class or method to construct url args or extract url args? Ken Varn ASP .Net 2 06-22-2005 12:26 PM
args v. *args passed to: os.path.join() Pierre Fortin Python 2 09-18-2004 06:59 PM
When passing functions as args,how to pass extra args for passed function? python@sarcastic-horse.com Python 3 09-17-2003 12:25 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57