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



"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7790CF47-E70E-4079-A7C9-6F2C2FF528D8@xxxxxxxxxxxxx
Why,

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

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 ...
    (comp.lang.c)
  • 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. ...
    (comp.lang.cpp)
  • 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 ...
    (microsoft.public.dotnet.languages.vc)
  • 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; ...
    (comp.lang.c)
  • 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, ...
    (comp.std.c)