Value Categories and References
Rvalue Bindings
An rvalue reference can bind to a temporary expression so the program can name that temporary result.
Rvalue Bindings
rvalue_bindings.cpp
#include <iostream>
int main() {
int base = ;
int&& temporary = base * 2;
int total = temporary + 1;
std::cout << "temporary=" << temporary << std::endl;
std::cout << "total=" << total << std::endl;
return 0;
}
#include <iostream>
int main() {
int base = ;
int&& temporary = base * 2;
int total = temporary + 1;
std::cout << "temporary=" << temporary << std::endl;
std::cout << "total=" << total << std::endl;
return 0;
}
#include <iostream>
int main() {
int base = ;
int&& temporary = base * 2;
int total = temporary + 1;
std::cout << "temporary=" << temporary << std::endl;
std::cout << "total=" << total << std::endl;
return 0;
}
rvalue reference
An rvalue reference uses `&&` and can bind to a temporary value.
temporary expression
Expressions such as arithmetic results do not have stable names until they are bound or stored.