What type does auto deduce in the C++17 declaration auto x = {1, 2, 3};?
Correct answer D. std::initializer_list<int>
Explanation
With copy-list-initialisation (auto x = {...}), auto deduces std::initializer_list, here std::initializer_list, which needs . It never deduces a std::vector or a built-in array. C++17 also changed direct-list-initialisation, so auto y{5}; deduces int, and auto z{1, 2}; is an error, which surprises many programmers.
Answer checked How we write and check questions
Discussion