Yes, this is a mistake, but in GCC. C ++ 11 [stmt.ranged] clearly states that your range-based loop is forequivalent to this:
{
auto && __range = (V);
for ( auto __begin = __range.begin(),
__end = __range.end();
__begin != __end;
++__begin ) {
auto i = *__begin;
{
std::string i = "oups";
}
}
}
Thus, the inside ishould simply hide the loop control iwithout any problems.
And, as this living example shows , the GCC actually agrees with this simply.
source
share