Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > The temporary vs non-const reference love story

Reply
Thread Tools

The temporary vs non-const reference love story

 
 
Ron Natalie
Guest
Posts: n/a
 
      11-05-2003

>
> Actually, I don't understand what his issue is. There's nothing wrong
> with the code he posted (he's not passing temporaries).
>

Yes, he is. Since the types don't match, but are convertable, a temporary
converted value is generated.


 
Reply With Quote
 
 
 
 
Larry Smith
Guest
Posts: n/a
 
      11-05-2003
> > Actually, I don't understand what his issue is. There's nothing wrong
> > with the code he posted (he's not passing temporaries).
> >

> Yes, he is. Since the types don't match, but are convertable, a temporary
> converted value is generated.


There's no type mismatch in his original post.


 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?=
Guest
Posts: n/a
 
      11-06-2003
Ron Natalie wrote:

> Yes, he is. Since the types don't match, but are convertable, a temporary
> converted value is generated.


There seems to be something wrong anyway: BCC managed to make the type
conversion from long to unsigned long, but then complained about
temporaries being passed, while saying nothing about the automatic
conversion itself. GCC, on the other hand, refused to do the type
conversion and failed to compile.

I am not sure about what the proper behavior should be, but I would hope
that, in a situation like that, the compilers would *warn* both about
the type conversion (since there is a good chance of it being unwanted)
and the creation of temporaries. That way, a user could have a better
idea of where he went wrong.

Regards,

--
Ney André de Mello Zunino
 
Reply With Quote
 
Ron Natalie
Guest
Posts: n/a
 
      11-06-2003

"Ney André de Mello Zunino" <(E-Mail Removed)> wrote in message news:boc76s$1coms3$(E-Mail Removed)-berlin.de...

> There seems to be something wrong anyway: BCC managed to make the type
> conversion from long to unsigned long, but then complained about
> temporaries being passed, while saying nothing about the automatic
> conversion itself. GCC, on the other hand, refused to do the type
> conversion and failed to compile.
>

Either way is fine. The standard doesn't say anything about the message
issued for ill-formed programs, just that one should be issued. Actually
both errors are fine. It's not clear to the compiler (or even me) which is
the real error here. It could either be that you didn't intend a conversion
here (mismatched args) or you are trying to bind the converted temporary
to an non-const reference.


 
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
Love love love imuaplease@gmail.com C++ 0 06-03-2009 02:53 AM
Tell Your Story - Wondershare Released Photo Story Platinum kena Digital Photography 0 06-12-2007 08:42 AM
NSLU2 and python - a love story ? Thomas W Python 3 06-02-2005 12:36 AM
Newsweek Story just that a Story Mark Test Digital Photography 21 05-22-2005 02:39 PM
Pix 506e, VPN, and overlapping pools... a love story Nate Smith Cisco 2 10-21-2003 03:38 PM



Advertisments