Understanding constexpr containers in C++20
This easy C++ language question tests your familiarity with constexpr semantics and compile-time evaluation in C++20. It asks you to trace the runtime behaviour of a program that uses containers—likely std::vector or std::array—in a constexpr context.
To answer correctly, you need to understand which standard library containers are usable at compile time under C++20 rules, how constexpr functions behave when called at runtime, and what the observable output will be. The question rewards precision about the boundary between compile-time and runtime execution, and careful attention to container semantics.
- Constexpr function evaluation and the constexpr specifier
- Compile-time vs. runtime container construction
- C++20 additions to the standard library's constexpr support
- Type deduction and template instantiation with constexpr