Created
March 31, 2016 03:09
-
-
Save LihuaWu/de0d555a20e5018657ac10c7962a2062 to your computer and use it in GitHub Desktop.
what is exactly a rvalue reference in cpp?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
#include <iostream> | |
int main() { | |
int a = 5; | |
int&& b = std::move(a); //我觉得5-6行本就不应该编译过,b的类型是右值引用,但是b出现在表达式的左边,因此是个左值。这是为啥呢? | |
b++; | |
std::cout << "a is : " << a << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment