1
votes

Sec. 5.4/1 N3797 says:

The result is an lvalue if T is an lvalue reference type or an rvalue reference to function type and an xvalue if T is an rvalue reference to object type.

What does it mean? I know what means lvalue expression. I've been trying to find an lvalue reference type definition int the Standard, but I can't. Could you possibly provide it?

2
For references in general, see this page. For value-categories (sooner or later you'll get to them), see this page. Between those two I think you'll find what you need.WhozCraig
@T.C. Indeed, I just tried to find 'lvalue reference type'.St.Antario

2 Answers

2
votes

The term lvalue reference means a reference with one & in it, e.g.:

int &x = whatever;
int const &y = whatever;

In C++03, lvalue references were the only type of reference. In C++11, rvalue references were added, so the retronym lvalue reference was coined to mean non-rvalue references.

Lvalue references can bind to both lvalues and rvalues (with the restriction about non-const lvalue reference not being able to bind to a temporary object); rvalue references can only bind to rvalues.

Note: universal references may bind to lvalues or rvalues, and after binding they either behave like an lvalue reference, or like an rvalue reference.

1
votes

There are 2 types of lvalue reference that are described in The C++ Programming Language 4th Edition as follow,

  • A non-const lvalue reference refers to an object, to which the user of the reference can write.
  • A const lvalue reference refers to a constant, which is immutable from the point of view of the user of the reference.

in addition,

  • An rvalue reference refers to a temporary object, which the user of the reference can (and typically will) modify, assuming that the object will never be used again.