Date
2008-08-27.00:00:00
Message id
1796

Content

One effect of the initializer-list proposal is that now we allow

    auto x = { 1, 2, 3 };  // decltype(x) is std::initializer_list<int>

but not

    auto ar[3] = { 1, 2, 3 };  // ill-formed

This seems unfortunate, as the code for the first could also support the second. Incidentally, I also failed to update the text in 9.2.9.7 [dcl.spec.auto] paragraph 3 which forbids the use of auto with braced-init-lists, so technically the first form above is currently ill-formed but has defined semantics.

Bjarne Stroustrup:

Is this the thin edge of a wedge? How about

    vector<auto> v = { 1, 2, 3 };

and

    template<class T> void f(vector<T>& v);
    f({1, 2, 3 });

(See also issue 625.)