Boost.Phoenix で range-based for
phx::for_each より楽に使えるものをと.
https://gist.github.com/1540409
void revival_example() { using boost::phoenix::arg_names::_1; using boost::phoenix::arg_names::_2; using boost::phoenix::local_names::_x; int array[5] = { 1, 2, 3, 4, 5 }; /* for (int &x : array) x *= 2; */ ranged(_x, _1) [ _x *= _2 ] (array, 2); int const result[5] = { 2, 4, 6, 8, 10 }; BOOST_CHECK(boost::equal(array, result)); }
内部では iterator を回しながら phx::let にぶん投げているだけです.