#include <boost/core/lightweight_test.hpp>
#include <boost/phoenix/core.hpp>
#include <boost/phoenix/operator.hpp>
#include <boost/phoenix/bind.hpp>
#include <boost/phoenix/scope.hpp>
#include <boost/phoenix/stl/algorithm/iteration.hpp>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <iostream>
namespace phoenix = boost::phoenix;
void test_foreach() {
using phoenix::placeholders::_1;
using phoenix::ref;
using phoenix::lambda;
int a[10][20];
int sum = 0;
std::for_each(a, a + 10,
phoenix::for_each(_1, lambda[_1 = ref(sum), ++ref(sum)]));
sum = 0;
std::for_each(a, a + 10,
phoenix::for_each( _1,
lambda[(ref(sum) += _1)]));
BOOST_TEST_EQ(sum, (199 + 1)/ 2 * 199);
}
int main()
{
test_foreach();
return boost::report_errors();
}