Advertisement
Guest User

Untitled

a guest
Nov 25th, 2011
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <boost/phoenix/core.hpp>
  2. #include <boost/phoenix/function.hpp>
  3. #include <iostream>
  4. #include <string>
  5. #include <vector>
  6. #include <algorithm>
  7.  
  8. #define USE_PHOENIX
  9.  
  10. #if defined(USE_PHOENIX)
  11. namespace impl
  12. {
  13. void plus4(int i, bool b, long l, std::string const & s)
  14. {
  15. std::cout << (i + l) << std::endl;
  16. }
  17. }
  18.  
  19. BOOST_PHOENIX_ADAPT_FUNCTION(void, plus4, impl::plus4, 4)
  20. #endif
  21.  
  22. int main()
  23. {
  24. using boost::phoenix::arg_names::_1;
  25. bool b = true;
  26. long l = 999;
  27. std::string const s = "Hello";
  28.  
  29. std::vector<int> vec;
  30. vec.push_back(1);
  31. vec.push_back(2);
  32. vec.push_back(3);
  33.  
  34. #if defined(USE_PHOENIX)
  35. std::for_each(vec.begin(), vec.end(), plus4(_1, b, l, s));
  36. #endif
  37. }
  38.  
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement