← Back to Question List
C++ Code Walkthrough #101
A Named Rvalue Reference Is an Lvalue Expression
📄 Code
Read carefully — what does this print?1#include <iostream>2#include <utility>34void label(int& value) {5 std::cout << "label(int&): " << value << "\n";6}78void label(int&& value) {9 std::cout << "label(int&&): " << value << "\n";10}1112void inspect(int&& value) {13 std::cout << "inspect got " << value << "\n";14 label(value);15 label(std::move(value));16}1718int main() {19 inspect(42);20 int n = 7;21 label(n);22 label(n + 1);23 return 0;24}