9
3

sample4.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*=============================================================================
  2. Phoenix V1.2.1
  3. Copyright (c) 2001-2003 Joel de Guzman
  4. Use, modification and distribution is subject to the Boost Software
  5. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. ==============================================================================*/
  8. #include <vector>
  9. #include <algorithm>
  10. #include <iostream>
  11. #include <boost/spirit/include/phoenix1_operators.hpp>
  12. #include <boost/spirit/include/phoenix1_primitives.hpp>
  13. #include <boost/spirit/include/phoenix1_statements.hpp>
  14. #include <boost/spirit/include/phoenix1_special_ops.hpp>
  15. using namespace std;
  16. using namespace phoenix;
  17. int
  18. main()
  19. {
  20. int init[] = { 2, 10, 4, 5, 1, 6, 8, 3, 9, 7 };
  21. vector<int> c(init, init + 10);
  22. typedef vector<int>::iterator iterator;
  23. // Print all odd contents of an stl container c
  24. for_each(c.begin(), c.end(),
  25. if_(arg1 % 2 == 1)
  26. [
  27. cout << arg1 << ' '
  28. ]
  29. );
  30. return 0;
  31. }