| 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) |
| 2 | |
| 3 | #include <boost/proto/detail/preprocessed/unpack_expr_.hpp> |
| 4 | |
| 5 | #elif !defined(BOOST_PP_IS_ITERATING) |
| 6 | |
| 7 | /// INTERNAL ONLY |
| 8 | /// |
| 9 | #define BOOST_PROTO_FUSION_NEXT_ITERATOR_TYPE(Z, N, DATA) \ |
| 10 | typedef typename fusion::result_of::next< \ |
| 11 | BOOST_PP_CAT(fusion_iterator, N)>::type \ |
| 12 | BOOST_PP_CAT(fusion_iterator, BOOST_PP_INC(N)); \ |
| 13 | /**/ |
| 14 | |
| 15 | /// INTERNAL ONLY |
| 16 | /// |
| 17 | #define BOOST_PROTO_FUSION_ITERATORS_TYPE(N) \ |
| 18 | typedef \ |
| 19 | typename fusion::result_of::begin<Sequence const>::type \ |
| 20 | fusion_iterator0; \ |
| 21 | BOOST_PP_REPEAT(BOOST_PP_DEC(N), BOOST_PROTO_FUSION_NEXT_ITERATOR_TYPE, fusion_iterator) \ |
| 22 | /**/ |
| 23 | |
| 24 | /// INTERNAL ONLY |
| 25 | /// |
| 26 | #define BOOST_PROTO_FUSION_AT_TYPE(Z, N, DATA) \ |
| 27 | typename add_const< \ |
| 28 | typename fusion::result_of::value_of< \ |
| 29 | BOOST_PP_CAT(fusion_iterator, N) \ |
| 30 | >::type \ |
| 31 | >::type \ |
| 32 | /**/ |
| 33 | |
| 34 | /// INTERNAL ONLY |
| 35 | /// |
| 36 | #define BOOST_PROTO_FUSION_NEXT_ITERATOR(Z, N, DATA) \ |
| 37 | BOOST_PP_CAT(fusion_iterator, BOOST_PP_INC(N)) BOOST_PP_CAT(it, BOOST_PP_INC(N)) = \ |
| 38 | fusion::next(BOOST_PP_CAT(it, N)); \ |
| 39 | /**/ |
| 40 | |
| 41 | /// INTERNAL ONLY |
| 42 | /// |
| 43 | #define BOOST_PROTO_FUSION_ITERATORS(N) \ |
| 44 | fusion_iterator0 it0 = fusion::begin(sequence); \ |
| 45 | BOOST_PP_REPEAT(BOOST_PP_DEC(N), BOOST_PROTO_FUSION_NEXT_ITERATOR, fusion_iterator) \ |
| 46 | /**/ |
| 47 | |
| 48 | /// INTERNAL ONLY |
| 49 | /// |
| 50 | #define BOOST_PROTO_FUSION_AT(Z, N, DATA) \ |
| 51 | *BOOST_PP_CAT(it, N) \ |
| 52 | /**/ |
| 53 | |
| 54 | /// INTERNAL ONLY |
| 55 | /// |
| 56 | #define BOOST_PROTO_FUSION_AS_CHILD_AT_TYPE(Z, N, DATA) \ |
| 57 | typename detail::protoify< \ |
| 58 | BOOST_PROTO_FUSION_AT_TYPE(Z, N, DATA) \ |
| 59 | , Domain \ |
| 60 | >::result_type \ |
| 61 | /**/ |
| 62 | |
| 63 | /// INTERNAL ONLY |
| 64 | /// |
| 65 | #define BOOST_PROTO_FUSION_AS_CHILD_AT(Z, N, DATA) \ |
| 66 | detail::protoify< \ |
| 67 | BOOST_PROTO_FUSION_AT_TYPE(Z, N, DATA) \ |
| 68 | , Domain \ |
| 69 | >()(BOOST_PROTO_FUSION_AT(Z, N, DATA)) \ |
| 70 | /**/ |
| 71 | |
| 72 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) |
| 73 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/unpack_expr_.hpp") |
| 74 | #endif |
| 75 | |
| 76 | /////////////////////////////////////////////////////////////////////////////// |
| 77 | /// \file make_expr_.hpp |
| 78 | /// Contains definition of make_expr_\<\> class template. |
| 79 | // |
| 80 | // Copyright 2008 Eric Niebler. Distributed under the Boost |
| 81 | // Software License, Version 1.0. (See accompanying file |
| 82 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 83 | |
| 84 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) |
| 85 | #pragma wave option(preserve: 1) |
| 86 | #endif |
| 87 | |
| 88 | template<typename Tag, typename Domain, typename Sequence, std::size_t Size> |
| 89 | struct unpack_expr_ |
| 90 | {}; |
| 91 | |
| 92 | template<typename Domain, typename Sequence> |
| 93 | struct unpack_expr_<tag::terminal, Domain, Sequence, 1u> |
| 94 | { |
| 95 | typedef |
| 96 | typename add_const< |
| 97 | typename fusion::result_of::value_of< |
| 98 | typename fusion::result_of::begin<Sequence>::type |
| 99 | >::type |
| 100 | >::type |
| 101 | terminal_type; |
| 102 | |
| 103 | typedef |
| 104 | typename proto::detail::protoify< |
| 105 | terminal_type |
| 106 | , Domain |
| 107 | >::result_type |
| 108 | type; |
| 109 | |
| 110 | BOOST_FORCEINLINE |
| 111 | static type const call(Sequence const &sequence) |
| 112 | { |
| 113 | return proto::detail::protoify<terminal_type, Domain>()(fusion::at_c<0>(sequence)); |
| 114 | } |
| 115 | }; |
| 116 | |
| 117 | template<typename Sequence> |
| 118 | struct unpack_expr_<tag::terminal, deduce_domain, Sequence, 1u> |
| 119 | : unpack_expr_<tag::terminal, default_domain, Sequence, 1u> |
| 120 | {}; |
| 121 | |
| 122 | #define BOOST_PP_ITERATION_PARAMS_1 \ |
| 123 | (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/unpack_expr_.hpp>)) |
| 124 | #include BOOST_PP_ITERATE() |
| 125 | |
| 126 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) |
| 127 | #pragma wave option(output: null) |
| 128 | #endif |
| 129 | |
| 130 | #undef BOOST_PROTO_FUSION_AT |
| 131 | #undef BOOST_PROTO_FUSION_AT_TYPE |
| 132 | #undef BOOST_PROTO_FUSION_AS_CHILD_AT |
| 133 | #undef BOOST_PROTO_FUSION_AS_CHILD_AT_TYPE |
| 134 | #undef BOOST_PROTO_FUSION_NEXT_ITERATOR |
| 135 | #undef BOOST_PROTO_FUSION_NEXT_ITERATOR_TYPE |
| 136 | #undef BOOST_PROTO_FUSION_ITERATORS |
| 137 | #undef BOOST_PROTO_FUSION_ITERATORS_TYPE |
| 138 | |
| 139 | #else // BOOST_PP_IS_ITERATING |
| 140 | |
| 141 | #define N BOOST_PP_ITERATION() |
| 142 | #define M BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N) |
| 143 | |
| 144 | template<typename Tag, typename Domain, typename Sequence> |
| 145 | struct unpack_expr_<Tag, Domain, Sequence, N> |
| 146 | { |
| 147 | BOOST_PROTO_FUSION_ITERATORS_TYPE(N) |
| 148 | |
| 149 | typedef |
| 150 | BOOST_PP_CAT(list, N)< |
| 151 | BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AS_CHILD_AT_TYPE, ~) |
| 152 | > |
| 153 | proto_args; |
| 154 | |
| 155 | typedef typename base_expr<Domain, Tag, proto_args>::type expr_type; |
| 156 | typedef typename Domain::proto_generator proto_generator; |
| 157 | typedef typename proto_generator::template result<proto_generator(expr_type)>::type type; |
| 158 | |
| 159 | BOOST_FORCEINLINE |
| 160 | static type const call(Sequence const &sequence) |
| 161 | { |
| 162 | BOOST_PROTO_FUSION_ITERATORS(N) |
| 163 | expr_type const that = { |
| 164 | BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AS_CHILD_AT, ~) |
| 165 | }; |
| 166 | return proto_generator()(that); |
| 167 | } |
| 168 | }; |
| 169 | |
| 170 | template<typename Tag, typename Sequence> |
| 171 | struct unpack_expr_<Tag, deduce_domain, Sequence, N> |
| 172 | { |
| 173 | BOOST_PROTO_FUSION_ITERATORS_TYPE(N) |
| 174 | |
| 175 | typedef |
| 176 | unpack_expr_< |
| 177 | Tag |
| 178 | , typename BOOST_PP_CAT(deduce_domain, N)< |
| 179 | BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AT_TYPE, ~) |
| 180 | >::type |
| 181 | , Sequence |
| 182 | , N |
| 183 | > |
| 184 | other; |
| 185 | |
| 186 | typedef typename other::type type; |
| 187 | |
| 188 | BOOST_FORCEINLINE |
| 189 | static type const call(Sequence const &sequence) |
| 190 | { |
| 191 | return other::call(sequence); |
| 192 | } |
| 193 | }; |
| 194 | |
| 195 | #undef N |
| 196 | #undef M |
| 197 | |
| 198 | #endif |
| 199 | |