initializer_list c++
If you set a list to an abject (or on auto keyword). CPP compiler assumes that the type of variable is initializer_list
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include <iostream> #include <initializer_list> using namespace std; int main() { auto a = {2,1,3,1}; // a is an initializer_list<int> for(auto el: a){ cout<< el << endl; } return 0; } |