So i can do this:
#include <iostream>
#include <vector>
main(){
auto init = {1,2,3};
std::vector<int> v(init);
}
and i can do this:
#include <iostream>
#include <vector>
main(){
int i[3] = {1,2,3};
}
Why can i not do this:
#include <iostream>
#include <vector>
main(){
auto init = {1,2,3};
int i[3] = init;
}
?
the compiler tells me this:
main.cpp: In function 'int main()':
main.cpp:10:16: error: array must be initialized with a brace-enclosed
initializer
int i[3] = init;
^~~~
exit status 1
it does not make a difference if i create init
with std::initializer_list<int>
instead of auto
.
You can mess around with it here.