CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
C++ Quiz #127

A Named Rvalue Reference Is Still an Lvalue

hardTemplates

inspect receives the literal 7 through an rvalue reference named value. Inside it, value is passed to label twice. What is printed?

📄 Code

1#include <iostream>
2#include <utility>
3 
4void label(int&) {
5 std::cout << "Lvalue\n";
6}
7 
8void label(int&&) {
9 std::cout << "Rvalue\n";
10}
11 
12void inspect(int&& value) {
13 label(value);
14 label(std::move(value));
15}
16 
17int main() {
18 inspect(7);
19 return 0;
20}