if.cpp 926 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  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 <iostream>
  7. #include <vector>
  8. #include <algorithm>
  9. #include <boost/phoenix/statement.hpp>
  10. #include <boost/phoenix/operator.hpp>
  11. #include <boost/phoenix/core.hpp>
  12. int
  13. main()
  14. {
  15. using boost::phoenix::if_;
  16. using boost::phoenix::arg_names::arg1;
  17. int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  18. std::vector<int> v(init, init+10);
  19. std::cout << std::dec;
  20. int x = 0;
  21. std::for_each(v.begin(), v.end(),
  22. if_(arg1 > 5)
  23. [
  24. std::cout << arg1 << ", "
  25. ]
  26. );
  27. std::cout << std::endl;
  28. return 0;
  29. }