PageRenderTime 50ms CodeModel.GetById 38ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

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