CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List
C++ Code Walkthrough #101

A Named Rvalue Reference Is an Lvalue Expression

hardTemplates

📄 Code

Read carefully — what does this print?
1#include <iostream>
2#include <utility>
3 
4void label(int& value) {
5 std::cout << "label(int&): " << value << "\n";
6}
7 
8void label(int&& value) {
9 std::cout << "label(int&&): " << value << "\n";
10}
11 
12void inspect(int&& value) {
13 std::cout << "inspect got " << value << "\n";
14 label(value);
15 label(std::move(value));
16}
17 
18int main() {
19 inspect(42);
20 int n = 7;
21 label(n);
22 label(n + 1);
23 return 0;
24}

🎯 Your Answer