#include <iostream>
#include <array>
#include <iostream>
using namespace std;
void foo(array<int, 3> const& bar) {
for (int i : bar) {
cout << i << endl;
}
}
int main() {
array<int,3> const bar = {1,2,3};
for (int i : bar) {
cout << i << endl;
}
foo(bar);
}
g++ 4.cpp
4.cpp:6:14: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (int i : bar) {
^
4.cpp:13:14: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (int i : bar) {
^
2 warnings generated.
g++ a.cpp -std=c++11
./a.out
1
2
3
1
2
3