1 /*============================================================================== 2 Copyright (c) 2005-2010 Joel de Guzman 3 Copyright (c) 2010 Thomas Heller 4 5 Distributed under the Boost Software License, Version 1.0. (See accompanying 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 ==============================================================================*/ 8 #include <algorithm> 9 #include <vector> 10 11 #include <boost/detail/lightweight_test.hpp> 12 #include <boost/phoenix/core.hpp> 13 #include <boost/phoenix/operator.hpp> 14 #include <boost/phoenix/scope.hpp> 15 #include <boost/phoenix/stl.hpp> 16 17 namespace phx = boost::phoenix; 18 using namespace boost::phoenix; 19 using namespace boost::phoenix::arg_names; 20 using namespace boost::phoenix::local_names; 21 main()22int main() 23 { 24 std::vector<int> u(11,1); 25 std::vector<int> w(11,2); 26 std::vector<int>::const_iterator it=w.begin(); 27 28 boost::phoenix::generate(phx::ref(u), lambda(_a=*phx::ref(it)++)[_a*2])(); 29 30 BOOST_TEST(std::accumulate(u.begin(), u.end(), 0) == 44); 31 32 BOOST_TEST(lambda(_a=*phx::ref(it)++)[_a*2]()() == 4); 33 34 return boost::report_errors(); 35 } 36 37 38