What this C++ reference and auto-deduction question tests
This is an easy C++ language-knowledge question that probes understanding of how the auto keyword deduces types, particularly in the presence of references and qualifiers. It's a foundational skill for writing correct modern C++ code, especially in performance-sensitive environments where type semantics matter.
The question asks you to reason carefully about what type the compiler infers when auto is combined with reference syntax. Getting this right requires understanding the rules for type deduction in template-like contexts and how references interact with const/volatile qualification. Many candidates mispredict the output because they conflate what they write with what the compiler actually sees.
- Auto type deduction rules
- Reference collapsing and forwarding
- Const and volatile propagation