Range-for statement boost style BOOST_FOREACH iterates over sequences a macro that simulates the std::foreach from C++11 #include <iostream> #include <boost/foreach.hpp> #include <boost/array.hpp> void boost_array() { boost::array<int, 4> a = {1, 2, 3, 4}; BOOST_FOREACH(int i, a) { std::cout << i; } } #include <iostream> #include <array> void cpp_11_foreach() { std::array<int, 4> a = {11, 22, 33, 44}; for (auto i:a) { std::cout << i; } // Another example with Initializer lists: for (const auto x : { 1,2,3,5,8,13,21,34 }) cout << x << '\n'; } Previous C++ Standardization Next 07. C++ Smart Pointers FEATURED TAGS jekyll GitLab Ubuntu C++ Docker FRIENDS 黄玄的博客 乱序 前端外刊评论 天镶的博客 Luke 的自留地 Ebn's Blog SmdCn's Blog David's Game DHong Say 尹峰以为 解旻的博客