I was under the impression that I don't need a template in order to use variadics in C++. So in the following class, I have a method that accepts a variadic as its second variable. Now my question is: how do I iterate over the variadic?
class CoolClass{
/** Other stuff go here */
// my question is about this
void variadic(X d, X others...){
cout<<"Main is "<<d.value()<<endl;
cout<<"Others are: "<<endl;
for(const auto& o: { others... }){ // doesn't have to be const
cout<<o.value()<<endl;
}
}
};
I tried running the code above and it doesn't work. I changed from { others...} to simply
others`, but that doesn't work either.
Aucun commentaire:
Enregistrer un commentaire