Lvalue reference (T&) — binds to named objects. Rvalue reference (T&&) — binds to temporary objects.
1int x = 10;2int& lref = x; // OK — lvalue reference3int& lref2 = 10; // Error — cannot bind lvalue ref to rvalue45int&& rref = 10; // OK — rvalue reference to temporary6int&& rref2 = x; // Error — cannot bind rvalue ref to lvalue7int&& rref3 = std::move(x); // OK — cast to rvalue89void process(int& val) { std::cout << "lvalue\n"; }10void process(int&& val) { std::cout << "rvalue\n"; }1112process(x); // lvalue13process(10); // rvalue14process(std::move(x)); // rvalue
Use cases: