I was trying to make a range based lopp like this in C++11:
std::vector<Satellite> Satellites; // Class member
//...
int number = 1;
for(auto sat : this->Satellites) {
sat.setNumber(number++);
}
And I'm getting this warning:
'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
Of course I could stick to for(Satellite sat : this->Satellites)
, but I was trying to test the auto keyword.
I had read that usage of auto was possible with C++11, but recently I found that it changed since C++0x (or it looks like it did!):
The keyword auto isn’t new; it actually dates back the pre-ANSI C era. However, C++11 has changed its meaning; auto no longer designates an object with automatic storage type. Rather, it declares an object whose type is deducible from its initializer. The old meaning of auto was removed from C++11 to avoid confusion.
So: Am I able to use it like this with C++11 and my problem is at the IDE (Eclipse CDT Juno), or should I use it in a different way (or remove the auto keyword at all)?