I would have thought that one could do this? Yet, it doesn't seem to be the case. Why? Or am I doing something wrong?
#include<vector>
#include<initializer_list>
#include<iostream>
using namespace std;
void fn(std::initializer_list<int> i)
{
for(int ivalue:i)
{
cout << ivalue << endl;
}
}
int main()
{
fn({1,2,3});
fn(vector<int>{4,5,6})
return 0;
}
Aucun commentaire:
Enregistrer un commentaire