Re: A non-const reference may only be bound to an lvalue?

"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message

That returned instance of B is not an lvalue - it's a temporary

I think lvalue is something we can address and rvalue is something we
can not address. The reurn instance of B is a temporary object, I
think an object is addressable and should be lvalue?

No, it's not "addressable" and it's not an lvalue. Specifically, this
doesn't compile:

B* p = &( source() );

With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Relevant Pages

  • Re: r- r-value vs l-value?
    ... bis an lvalue ... a+5 is an rvalue ... an rvalue-to-lvalue conversion occurs (and this conversion is ... It expects an rvalue operand and yields an lvalue which designates the ...
  • Re: string literal is an lvalue; other literals are rvalues.
    ... >> As I understand the distinction between rvalue and lvalue, ... but not of an rvalue. ... such as the int value 5. ... There is talk of lvalue to rvalue conversion in 4.1. ...
  • Re: Managed C++ Code Generation Bug?
    ... >> binds directly without an initial conversion to an rvalue, ... My mom always told me to stay out of lvalue vs. rvalue ... >I don't see why treating a static const member as an lvalue should cause ...
  • Re: r- r-value vs l-value?
    ... The following are l-values (and also r-values): ... bis an lvalue ... a+5 is an rvalue ... Before this conversion takes place, b is an lvalue; ...
  • Re: value of an assignment expression, revisited
    ... rvalue and lvalue seems bogus anyway. ... The WG21 will perhaps add a "weak" sequence point with assignment ... I know well what's an lvalue (and a rvalue, ... by the authors of the C++ standard, ...