&&

1
2
3
4
5
6
7
8
#include <iostream>

int main()
{
	int x = 1;
	int&& x1 = static_cast<int&&>(x);
	int&& x2 = x1;
}


//why a compilation errror?
x, x1 and x2 are all l-values since they have a name and are addressable in memory
The more usual way to write that would be (with the error corrected):

1
2
3
4
5
6
7
8
#include <utility>

int main()
{
	int x = 1;
	int&& x1 = std::move(x);
	int&& x2 = std::move(x1);
}


Btw, when posting about compilation errors, provide the text of the error.

@gedanial, Thanks!
@cire, it is equal to:
1
2
3
4
5
6
7
8
#include <utility>

int main()
{
	int x = 1;
	int&& x1 = static_cast<int&&>(x);
	int&& x2 = static_cast<int&&>(x1);
}
Topic archived. No new replies allowed.