Questions tagged [xvalue]

"xvalue" is a C++11 term for an expiring value that can be moved from

From the proposed C++11 standard:

An xvalue (an “eXpiring” value) also refers to an object, usually near the end of its lifetime (so that its resources may be moved, for example). An xvalue is the result of certain kinds of expressions involving rvalue references (8.3.2). [Example: The result of calling a function whose return type is an rvalue reference is an xvalue. — end example ]

60 questions
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
2
votes
2 answers

`xvalue` behavior in C++11/14

class Myclass { public: Myclass() = default; ~Myclass() = default; Myclass(Myclass&&) = default; Myclass& operator=(Myclass&&) = default; Myclass(const Myclass&) = delete; Myclass& operator=(const Myclass&) = delete; …
gaurav bharadwaj
  • 1,669
  • 1
  • 12
  • 29
2
votes
1 answer

Is a rvalue reference parameter that is returned by value an xvalue?

My understanding is that, in the following function, the expression foo in the statement return foo; is an xvalue, because the object it denotes is expiring (even though foo is an lvalue in previous statements): Foo bar() { Foo foo; …
ricab
  • 2,697
  • 4
  • 23
  • 28
1
vote
2 answers

Temporary materialization and xvalue expression

cppreference is said that: any expression that designates a temporary object after temporary materialization is xvalue expression (since C++17). Temporary materialization is: A prvalue of any complete type T can be converted to an xvalue of…
user15676138
1
vote
0 answers

Why does `T&&` not stick?

Say I have the following functions: void f2(int&& i) { puts("f2(int&& i)"); } void f(int&& i) { puts("f(int&& i)"); f2(i); } The compiler error emitted is: error C2664: 'void f2(int &&)': cannot convert argument 1 from 'int' to 'int…
bobobobo
  • 64,917
  • 62
  • 258
  • 363
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
1 answer

Why C++ allows returning ifstream object?

In C++98, the following code does not compile because the ifstream has no copy constructor: #include #include using namespace std; ifstream f() { return ifstream("main.cpp"); } int main() { ifstream st= f(); } However…
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

xcode CGPoint arc4random not working

I have 22 images... 11 are (rightwall1, rightwall2, rightwall3, etc) the other 11 are (leftwall1, leftwall2, leftwall3, etc) I am placing each one ontop of the other by setting their y value to the previous walls y value plus the height of the wall…
Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195
1
vote
2 answers

C# Chart control : X value of a horizontal bar chart is 0 for all points in the serie

I have a horizontally stacked bar chart in my app, and I'm trying to figure out how to get the X axis value when the user clicks on a bar. The problem is when I look at the values at runtime, the Y values are fine but the X values are all 0. Screen…
Klev330
  • 11
  • 4
1
vote
0 answers

A temporary array is assigned but not a temporary primary value

I am amazed that this C++ code is compiled: int main() { (int[10]){}[0]=15; return 0; } The equivalent assembly is main: push rbp mov rbp, rsp mov QWORD PTR [rbp-48], 0 mov QWORD PTR [rbp-40],…
ar2015
  • 5,558
  • 8
  • 53
  • 110
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

HighChart how to use object array

json file: [{ "key_as_string": "2017-05-09", "doc_count": 1874 }, { "key_as_string": "2017-05-10", "doc_count": 2680 }, { "key_as_string": "2017-05-11", "doc_count": 2717 }, { "key_as_string": "2017-05-12", …
Dali
  • 31
  • 4
1
vote
3 answers

Is value category of function returning by value is always xvalue?

As per my understanding below code should call move constructor of Test class since this function is returning by value which means expression GetTestObj() should be rvalue and xvalues are implicitly moved but why this code is calling copy…
PapaDiHatti
  • 1,841
  • 19
  • 26
1
vote
0 answers

C# chart XValue is empty

I have a problem with getting value of AxisX. I add new points form dataTable: chart1.Series.Add(dataTable.Columns[x].Caption); chart1.Series[dataTable.Columns[x].Caption].ChartType =…