78、基于范围的for循环

Boost 中定义了很多"范围",很多标准库函数都使⽤了范围风格的实现。这⼀概念被C++11提了出来:

int arr[5];
std::vector<int> v;
for(int x: arr);
for(const int& x: arr);
for(int x: v);
for(auto &x: v);

Last updated