auto buf={1,2,3}
here type of "buf" std::initializer_list, but
int buf[]={1,2,3};
the left side expression declaration of variable "buf",type int[], on right side std::initializer_list
so there implicit type conversion here, std::initializer_list int[]? or new stl defines such conversion?
how can prove if there's or there's not such conversion here?
in case of auto buf = {1, 2, 3};
compiler has deduce type buf
, picks std::initializer_list<int>
.
however in case of int buf[] = {1, 2, 3};
, knows type of buf
, way initialize through aggregate initialization. notice size not specified , deduced number of elements provided. unique arrays.
there no conversion available here. if try force construction std::initializer_list<int>
compilation error:
main.cpp:8:9: error: array initializer must initializer list int buf[] = std::initializer_list<int>({1, 3, 4}); ^