bug3289.cpp 1.1 KB

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