What this C++ type-deduction interview question tests
This is a medium-difficulty C++ question that probes your working knowledge of decltype and how the compiler resolves types in non-obvious contexts. It rewards precision: small syntactic differences—parentheses, references, value categories—produce different answers, and interviewers expect you to predict the exact output without guessing.
Questions like this are common in C++ technical interviews because they expose whether you understand the rules the standard actually enforces, not just the intuitive mental model you might carry. The skill tested is the ability to trace through type deduction rules methodically and reason about what a snippet will do at runtime.
- Decltype with expressions vs. names
- Lvalue and rvalue references in type deduction
- The difference between decltype(x) and decltype((x))
- How parentheses change the result of type analysis