Questions tagged [prvalue]
30 questions
2
votes
0 answers
Can a Second Const Reference Extend the Lifetime of a Temporary
Background:
I noticed that the signature of std::max is:
template
const T& max(const T&, const T&);
and I wondered about the implications of returning a reference to a const
T...
If we pass in two L-values, it makes sense we could…

user137364
- 305
- 1
- 7
2
votes
2 answers
C++11: does "decltype(1+2)" declare an xvalue or a prvalue?
Does decltype(1+2) declare an xvalue or or a prvalue?
cppreference says, decltype(expression) will declare:
1. T&& if expression is an xvalue
2. T if expression is an prvalue
3. T& if expression is lvalue
But my question is: how to generate an…

Hind Forsum
- 9,717
- 13
- 63
- 119
1
vote
1 answer
Cv-qualification of prvalues during reference binding
Consider this example:
const int& r2 = 5;
The rules governing reference-initialization are found in [dcl.init.ref]/5:
A reference to type “cv1 T1” is initialized by an expression of
type “cv2 T2” as follows:
(5.1) [..]
(5.2) [..]
(5.3) Otherwise,…

mada
- 1,646
- 1
- 15
1
vote
0 answers
How does prvalue works?
I have read a few posts on SO about prvalue and guaranteed copy elision (especially this one). But I am still confused about how prvalue works.
Consider the following code (C++17):
class Y
{
public:
Y() { cout << "Y dctor\n"; }
};
class…

CPPL
- 726
- 1
- 10
1
vote
1 answer
The C++17 compiler (gcc or Microsoft Visual C++), does it have an option that prohibit the feature "not produce a temporary"
How can I told to С++17 compiler to create temporary in the following case
(i.e. The C++17 compiler must considered copy/move operation, like C++11 and C++14 compilers do)
class A{
public:
A(){}
A(const A&)=delete;
…

al-
- 25
- 5
1
vote
2 answers
Some differences between xvalue and prvalue
I've been carefully studying C++ catogories recently. The difference between lvalue and rvalue seems to be clear, but I got confused when it comes to prvalue and xvalue.
Given the example below:
#include
using std::cout;
using…

0x269
- 688
- 8
- 20
1
vote
1 answer
Behavioral differences in 5 vs std::move(5)
I've read all the major questions on SO about different value categories but still don't clearly understand the difference between, in this case, xvalues vs prvalues.
I know that, like all glvalues, xvalues can have their dynamic type different from…

ledonter
- 1,269
- 9
- 27
1
vote
1 answer
Constructor call is a prvalue expression
In the C++ standard one can find examples of prvalue expressions:
"prvalue
The following expressions are prvalue expressions:
a literal (except for string literal), such as 42, true or nullptr;
a function call or an overloaded operator expression…

user42768
- 1,951
- 11
- 22
0
votes
1 answer
prvalue vs xvalue for class types
I've got more confused when I see this question: Is a class instantiation--class_name() a xvalue or a prvalue? I'm trying to understand what does it mean by a class prvalue and a class xvalue. Someone tell me that they're called value category. But…

iopiux
- 11
- 3
0
votes
1 answer
How conversions that creates prvalue are create temporary objects?
From cppreference
Temporary objects are created .. in the
following situations:
conversion that creates a prvalue (including T(a,b,c) and T{})
When this can happen? (examples will be appreciated)
What does they mean by "including T(a,b,c) and…
user15676138
0
votes
0 answers
Examples of rvalue, lvalues, xvalues, glvalues, and prvalues?
This post What are rvalues, lvalues, xvalues, glvalues, and prvalues? provides the definitions of rvalue, lvalues, xvalues, glvalues, and prvalues, but I don't see examples.
I think I have a solid understanding of lvalues and rvalues, but not so…

24n8
- 1,898
- 1
- 12
- 25
0
votes
1 answer
What steps should I take to determine the value category of an expression?
I'm rather confused about determiming the value category of an expression. Could you please provide the basic steps that should be taken (what should be analysed) to determing the value category of an expression?

beginpluses
- 497
- 2
- 9
0
votes
1 answer
Why a function call is an xvalue (if return type is an rvalue)?
Let's say we have a function:
struct A {
int m;
};
A&& f();
As far as I know the expressions:
f();
f().m;
are both xvalue. But why? Why aren't they prvalue? I'm a little bit confused.

embedc
- 1,485
- 1
- 6
- 20
0
votes
1 answer
Move a prvalue into function template uref argument or not?
my question is if it would make sense to std::move (or not) a prvalue into a catch-all function template which accordingly takes a universal reference T&& in its signature. Also I would like to know if copy-move elision/RVO is playing a role in this…

Navie
- 164
- 1
- 8
0
votes
1 answer
Q: why _rvalues_ were renamed to _prvalues_? (pure rvalues)
This document appears to be the source of these changes from C++11: n3055.
II. Overview of Changes
Rvalues, as currently known in the core language clauses, are renamed
to “prvalues” (“pure” rvalues).
lvalues meaning was not changed, but…

mteodor
- 175
- 6