Understanding C++17 language features and program output
This is a hard C++ question that tests deep knowledge of C++17 semantics and subtle behaviour in modern standard library features. It is the kind of question used to distinguish candidates who have merely written C++ from those who understand its specification in detail.
To solve it, you need to trace through the program's execution while accounting for C++17-specific changes to initialization rules, temporary lifetime, template deduction, and standard library behaviour. The question rewards careful reading of language semantics over pattern matching or guesswork. Firms ask these questions to verify that a candidate can reason confidently about code correctness and avoid silent bugs in production systems.
- C++17 guaranteed copy elision and temporary lifetime rules
- Structured bindings and their scope and reference semantics
- Deduction guides and template parameter deduction
- Changes to standard library facilities and their overload sets