generator.cpp 988 B

12345678910111213141516171819202122232425262728293031323334
  1. /*=============================================================================
  2. Copyright (c) 2011 Thomas Heller
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #include <vector>
  7. #include <algorithm>
  8. #include <iostream>
  9. #include <boost/phoenix.hpp>
  10. template <typename> struct wrap {};
  11. int main()
  12. {
  13. using boost::phoenix::val;
  14. using boost::phoenix::lambda;
  15. using boost::phoenix::let;
  16. using boost::phoenix::construct;
  17. using boost::phoenix::placeholders::_1;
  18. using boost::phoenix::local_names::_a;
  19. int const n = 10;
  20. std::vector<int> v1(n);
  21. let(_a = construct<int>(0))
  22. [
  23. generate(_1, lambda(_a = ref(_a))[_a++])
  24. , std::cout << val("result:\n")
  25. , for_each(_1, lambda[std::cout << _1 << ' '])
  26. , std::cout << val('\n')
  27. ](v1);
  28. }