Home

Rvalue

Rvalue is a programming term used to describe an expression that yields a value and is typically not associated with a persistent storage location. In many languages, rvalues can appear on the right-hand side of an assignment but cannot generally be assigned to themselves. This contrasts with lvalue, or locator value, which denotes an expression that refers to an identifiable storage location and can appear on the left-hand side of an assignment.

In languages such as C and C++, an rvalue includes literals (for example, the number 5), the

In C++11 and later, the concept evolved into value categories, clarifying how values can be used and

Across other languages, the formal terminology may vary, but the core idea remains: rvalues denote values or

result
of
most
arithmetic
expressions
(such
as
x
+
y),
and
temporary
objects
returned
by
functions.
An
lvalue,
by
contrast,
refers
to
a
named
object
or
a
location
in
memory,
such
as
a
variable
or
a
dereferenced
pointer.
For
example,
in
the
statement
int
a
=
3;
the
variable
a
is
an
lvalue,
while
the
literal
3
is
an
rvalue.
moved.
The
categories
include
glvalue
(generalized
lvalue),
prvalue
(pure
rvalue),
and
xvalue
(expiring
value).
These
distinctions
underpin
move
semantics
and
resource
management,
allowing
efficient
transfer
of
resources
via
rvalue
references
(type&&).
For
instance,
objects
can
be
moved
from
when
passed
as
rvalues,
enabling
constructors
and
functions
to
take
ownership
of
resources
without
unnecessary
copying.
temporaries,
typically
not
tied
to
a
modifiable
storage
location,
in
contrast
to
lvalues
which
designate
concrete
storage
locations.