/Src/Dependencies/Boost/libs/phoenix/test/scope/bug3289.cpp

http://hadesmem.googlecode.com/ · C++ · 37 lines · 21 code · 9 blank · 7 comment · 2 complexity · 51b67f6a728ce4ef1a742cc8bafbc8f1 MD5 · raw file

  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. }