Skip to content

Latest commit

 

History

History
55 lines (30 loc) · 1.47 KB

CppBOOST_FOREACH.md

File metadata and controls

55 lines (30 loc) · 1.47 KB

 

 

 

 

 

 

BOOST_FOREACH is a Boost macro to replace for-loops or to simplify their corresponding algorithm.

 

Examples

 

 

 

 

 

 


#include <boost/foreach.hpp> //From http://www.richelbilderbeek.nl/CppTriple.htm template <class Container> void Triple(Container& c) {   BOOST_FOREACH(typename Container::value_type& i, c)   {     i*=3;   } } #include <vector> #include <cassert> int main() {   std::vector<int> v;   v.push_back(1);   Triple(v);   assert(v[0]==3); }