← Back to Question List
C++ Code Walkthrough #100
Trace Lvalue and Rvalue Function Overloads
📄 Code
Read carefully — what does this print?1#include <iostream>23template <typename T>4void identify(T& value) {5 std::cout << "Lvalue: " << value << "\n";6}78template <typename T>9void identify(T&& value) {10 std::cout << "Rvalue: " << value << "\n";11}1213int main() {14 int x = 5;15 identify(x);16 identify(10);17 identify(x + 3);18 identify(x += 2);19 identify(++x);20 identify(x++);21 std::cout << "x = " << x << "\n";22 return 0;23}