/Src/Dependencies/Boost/boost/spirit/home/phoenix/core/composite.hpp

http://hadesmem.googlecode.com/ · C++ Header · 96 lines · 74 code · 14 blank · 8 comment · 0 complexity · f0e14754096e8f7fb09b1a404e228f30 MD5 · raw file

  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. #ifndef PHOENIX_CORE_COMPOSITE_HPP
  7. #define PHOENIX_CORE_COMPOSITE_HPP
  8. #include <boost/spirit/home/phoenix/core/actor.hpp>
  9. #include <boost/spirit/home/phoenix/core/is_actor.hpp>
  10. #include <boost/fusion/include/vector.hpp>
  11. #include <boost/fusion/include/at.hpp>
  12. #include <boost/fusion/include/size.hpp>
  13. #include <boost/fusion/include/mpl.hpp>
  14. #include <boost/mpl/fold.hpp>
  15. #include <boost/mpl/bool.hpp>
  16. #include <boost/mpl/or.hpp>
  17. namespace boost { namespace phoenix
  18. {
  19. namespace detail
  20. {
  21. template <int N>
  22. struct composite_eval;
  23. struct compute_no_nullary
  24. {
  25. template <typename State, typename T>
  26. struct apply
  27. {
  28. typedef typename
  29. mpl::or_<typename T::no_nullary, State>::type
  30. type;
  31. };
  32. };
  33. }
  34. template <typename EvalPolicy, typename EvalTuple>
  35. struct composite : EvalTuple
  36. {
  37. typedef EvalTuple base_type;
  38. typedef composite<EvalPolicy, EvalTuple> self_type;
  39. typedef EvalPolicy eval_policy_type;
  40. typedef typename
  41. mpl::fold<
  42. EvalTuple
  43. , mpl::false_
  44. , detail::compute_no_nullary
  45. >::type
  46. no_nullary;
  47. template <typename Env>
  48. struct result
  49. {
  50. typedef
  51. typename detail::composite_eval<
  52. fusion::result_of::size<base_type>::value>::
  53. template result<self_type, Env>::type
  54. type;
  55. };
  56. composite()
  57. : base_type() {}
  58. composite(base_type const& base)
  59. : base_type(base) {}
  60. template <typename U0>
  61. composite(U0& _0)
  62. : base_type(_0) {}
  63. template <typename U0, typename U1>
  64. composite(U0& _0, U1& _1)
  65. : base_type(_0, _1) {}
  66. template <typename Env>
  67. typename result<Env>::type
  68. eval(Env const& env) const
  69. {
  70. typedef typename result<Env>::type return_type;
  71. return detail::
  72. composite_eval<fusion::result_of::size<base_type>::value>::template
  73. call<return_type>(*this, env);
  74. }
  75. // Bring in the rest of the constructors
  76. #include <boost/spirit/home/phoenix/core/detail/composite.hpp>
  77. };
  78. // Bring in the detail::composite_eval<0..N> definitions
  79. #include <boost/spirit/home/phoenix/core/detail/composite_eval.hpp>
  80. }}
  81. #endif