/Src/Dependencies/Boost/boost/proto/transform/detail/make.hpp

http://hadesmem.googlecode.com/ · C++ Header · 174 lines · 121 code · 30 blank · 23 comment · 4 complexity · 49772f3f485f99436c114562beca1230 MD5 · raw file

  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/proto/transform/detail/preprocessed/make.hpp>
  3. #elif !defined(BOOST_PP_IS_ITERATING)
  4. #define BOOST_PROTO_MAKE_IF(Z, M, DATA) \
  5. make_if_<BOOST_PP_CAT(A, M), Expr, State, Data> \
  6. /**/
  7. #define BOOST_PROTO_MAKE_IF_TYPE(Z, M, DATA) \
  8. typename BOOST_PROTO_MAKE_IF(Z, M, DATA) ::type \
  9. /**/
  10. #define BOOST_PROTO_MAKE_IF_APPLIED(Z, M, DATA) \
  11. BOOST_PROTO_MAKE_IF(Z, M, DATA) ::applied || \
  12. /**/
  13. #define BOOST_PROTO_CONSTRUCT_ARG(Z, M, DATA) \
  14. detail::as_lvalue( \
  15. typename when<_, BOOST_PP_CAT(A, M)>::template impl<Expr, State, Data>()(e, s, d) \
  16. ) \
  17. /**/
  18. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  19. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/make.hpp")
  20. #endif
  21. ///////////////////////////////////////////////////////////////////////////////
  22. /// \file make.hpp
  23. /// Contains definition of the make<> transform.
  24. //
  25. // Copyright 2008 Eric Niebler. Distributed under the Boost
  26. // Software License, Version 1.0. (See accompanying file
  27. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  28. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  29. #pragma wave option(preserve: 1)
  30. #endif
  31. #define BOOST_PP_ITERATION_PARAMS_1 \
  32. (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/detail/make.hpp>))
  33. #include BOOST_PP_ITERATE()
  34. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  35. #pragma wave option(output: null)
  36. #endif
  37. #undef BOOST_PROTO_CONSTRUCT_ARG
  38. #undef BOOST_PROTO_MAKE_IF_APPLIED
  39. #undef BOOST_PROTO_MAKE_IF_TYPE
  40. #undef BOOST_PROTO_MAKE_IF
  41. #else
  42. #define N BOOST_PP_ITERATION()
  43. namespace detail
  44. {
  45. #if N > 0
  46. template<
  47. template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class R
  48. BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)
  49. , typename Expr, typename State, typename Data
  50. >
  51. struct make_<
  52. R<BOOST_PP_ENUM_PARAMS(N, A)>
  53. , Expr, State, Data
  54. BOOST_PROTO_TEMPLATE_ARITY_PARAM(N)
  55. >
  56. : nested_type_if<
  57. R<BOOST_PP_ENUM(N, BOOST_PROTO_MAKE_IF_TYPE, ~)>
  58. , (BOOST_PP_REPEAT(N, BOOST_PROTO_MAKE_IF_APPLIED, ~) false)
  59. >
  60. {};
  61. template<
  62. template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class R
  63. BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)
  64. , typename Expr, typename State, typename Data
  65. >
  66. struct make_<
  67. noinvoke<R<BOOST_PP_ENUM_PARAMS(N, A)> >
  68. , Expr, State, Data
  69. BOOST_PROTO_TEMPLATE_ARITY_PARAM(1)
  70. >
  71. {
  72. typedef R<BOOST_PP_ENUM(N, BOOST_PROTO_MAKE_IF_TYPE, ~)> type;
  73. static bool const applied = true;
  74. };
  75. #endif
  76. template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  77. struct is_applyable<R(BOOST_PP_ENUM_PARAMS(N, A))>
  78. : mpl::true_
  79. {};
  80. template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  81. struct is_applyable<R(*)(BOOST_PP_ENUM_PARAMS(N, A))>
  82. : mpl::true_
  83. {};
  84. template<typename T, typename A>
  85. struct construct_<proto::expr<T, A, N>, true>
  86. {
  87. typedef proto::expr<T, A, N> result_type;
  88. template<BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), typename A)>
  89. result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_MAX(N, 1), A, &a)) const
  90. {
  91. return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a));
  92. }
  93. };
  94. template<typename T, typename A>
  95. struct construct_<proto::basic_expr<T, A, N>, true>
  96. {
  97. typedef proto::basic_expr<T, A, N> result_type;
  98. template<BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), typename A)>
  99. result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_MAX(N, 1), A, &a)) const
  100. {
  101. return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a));
  102. }
  103. };
  104. template<typename Type BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  105. Type construct(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a))
  106. {
  107. return construct_<Type>()(BOOST_PP_ENUM_PARAMS(N, a));
  108. }
  109. } // namespace detail
  110. /// \brief A PrimitiveTransform which computes a type by evaluating any
  111. /// nested transforms and then constructs an object of that type with the
  112. /// current expression, state and data, transformed according
  113. /// to \c A0 through \c AN.
  114. template<typename Object BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  115. struct make<Object(BOOST_PP_ENUM_PARAMS(N, A))>
  116. : transform<make<Object(BOOST_PP_ENUM_PARAMS(N, A))> >
  117. {
  118. template<typename Expr, typename State, typename Data>
  119. struct impl : transform_impl<Expr, State, Data>
  120. {
  121. /// \brief <tt>boost::result_of\<make\<Object\>(Expr, State, Data)\>::type</tt>
  122. typedef typename detail::make_if_<Object, Expr, State, Data>::type result_type;
  123. /// Let \c ax be <tt>when\<_, Ax\>()(e, s, d)</tt>
  124. /// for each \c x in <tt>[0,N]</tt>.
  125. /// Return <tt>result_type(a0, a1,... aN)</tt>.
  126. ///
  127. /// \param e The current expression
  128. /// \param s The current state
  129. /// \param d An arbitrary data
  130. result_type operator ()(
  131. typename impl::expr_param e
  132. , typename impl::state_param s
  133. , typename impl::data_param d
  134. ) const
  135. {
  136. proto::detail::ignore_unused(e);
  137. proto::detail::ignore_unused(s);
  138. proto::detail::ignore_unused(d);
  139. return detail::construct<result_type>(BOOST_PP_ENUM(N, BOOST_PROTO_CONSTRUCT_ARG, DATA));
  140. }
  141. };
  142. };
  143. #undef N
  144. #endif