Consider this snippet:
#include <iostream>
int main() {
int s[6] {0, 1, 2, 3, 4, 5};
for ( auto && i: s ) {
std::cout << " " << i << std::endl;
}
}
This compiles and runs happily under both g ++ and clang ++.
This is taken for granted in many posts ( here and here , for example), but it is not clear to me how the compiler can correctly determine the size of an array in for rangefor a type without an iterator.
Can someone answer or add link to link?
source
share