Skip to content

Instantly share code, notes, and snippets.

@LihuaWu
Created March 31, 2016 03:09
Show Gist options
  • Save LihuaWu/de0d555a20e5018657ac10c7962a2062 to your computer and use it in GitHub Desktop.
Save LihuaWu/de0d555a20e5018657ac10c7962a2062 to your computer and use it in GitHub Desktop.
what is exactly a rvalue reference in cpp?
#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