sample5.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. using namespace std;
  14. using namespace phoenix;
  15. //////////////////////////////////
  16. template <int N>
  17. struct static_int {
  18. template <typename TupleT>
  19. struct result { typedef int type; };
  20. template <typename TupleT>
  21. int eval(TupleT const&) const { return N; }
  22. };
  23. //////////////////////////////////
  24. template <int N>
  25. phoenix::actor<static_int<N> >
  26. int_const()
  27. {
  28. return static_int<N>();
  29. }
  30. //////////////////////////////////
  31. int
  32. main()
  33. {
  34. cout << (int_const<5>() + int_const<6>())() << endl;
  35. return 0;
  36. }