Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > lvalue rvalue

Thread Tools

lvalue rvalue

Ioannis Vranos
Posts: n/a
Ali Cehreli wrote:

> They are destroyed at the end of the complete statement where they are
> created. The complete statement may have many other function
> calls. The destruction of the temporary must wait untill all of those
> calls are completed.
> This is incorrect. The temporary lives longer than the function call
> as I described above. The destruction must wait until the statement
> completes.

Yes you are right.


Ioannis Vranos
Reply With Quote
Posts: n/a
Andrey Tarasevich posted:

> but that's just the way it is in C++.

The only valid explanantion.

Reply With Quote
Posts: n/a

I've just had a quick read over this thread.

We can summarize temporaries with the following:

non-const (they're *not* const)
r-value (they're *not* an l-value)

(strange how it is!)

With has the following repercussions (for want of a better word):

A temporary cannot be bound to a non-const reference ( not because it's
const, because it *isn't*, but because it's an r-value, ie. you can only
bind a non-const reference to an l-value ).

So, where you have:

AnyType& blah = Anything...

then "Anything" must be:


And where you have:

AnyType const & blah = Anything...

Then "Anything" can quite literally be anything!

Reply With Quote

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
Giving an rvalue ref to a function taking an rvalue ref Juha Nieminen C++ 13 08-29-2012 09:25 PM
operators requiring lvalue/rvalue operands and resulting in rvalue/lvalue Kavya C Programming 9 10-28-2006 01:45 AM
const and non-const operator[] Vs. lvalue and rvalue use Mark Stijnman C++ 2 04-22-2005 02:32 PM
rvalue / lvalue operator[] Gonzalo Aguirre C++ 4 01-02-2004 06:02 PM
++x returns lvalue but x++ return rvalue Chris Mantoulidis C++ 4 12-29-2003 07:00 AM