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 callunpack_expr_110 static type const call(Sequence const &sequence) 111 { 112 return proto::detail::protoify<terminal_type, Domain>()(fusion::at_c<0>(sequence)); 113 } 114 }; 115 116 template<typename Sequence> 117 struct unpack_expr_<tag::terminal, deduce_domain, Sequence, 1u> 118 : unpack_expr_<tag::terminal, default_domain, Sequence, 1u> 119 {}; 120 121 #define BOOST_PP_ITERATION_PARAMS_1 \ 122 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/unpack_expr_.hpp>)) 123 #include BOOST_PP_ITERATE() 124 125 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 126 #pragma wave option(output: null) 127 #endif 128 129 #undef BOOST_PROTO_FUSION_AT 130 #undef BOOST_PROTO_FUSION_AT_TYPE 131 #undef BOOST_PROTO_FUSION_AS_CHILD_AT 132 #undef BOOST_PROTO_FUSION_AS_CHILD_AT_TYPE 133 #undef BOOST_PROTO_FUSION_NEXT_ITERATOR 134 #undef BOOST_PROTO_FUSION_NEXT_ITERATOR_TYPE 135 #undef BOOST_PROTO_FUSION_ITERATORS 136 #undef BOOST_PROTO_FUSION_ITERATORS_TYPE 137 138 #else // BOOST_PP_IS_ITERATING 139 140 #define N BOOST_PP_ITERATION() 141 #define M BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N) 142 143 template<typename Tag, typename Domain, typename Sequence> 144 struct unpack_expr_<Tag, Domain, Sequence, N> 145 { 146 BOOST_PROTO_FUSION_ITERATORS_TYPE(N) 147 148 typedef 149 BOOST_PP_CAT(list, N)< 150 BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AS_CHILD_AT_TYPE, ~) 151 > 152 proto_args; 153 154 typedef typename base_expr<Domain, Tag, proto_args>::type expr_type; 155 typedef typename Domain::proto_generator proto_generator; 156 typedef typename proto_generator::template result<proto_generator(expr_type)>::type type; 157 callunpack_expr_158 static type const call(Sequence const &sequence) 159 { 160 BOOST_PROTO_FUSION_ITERATORS(N) 161 expr_type const that = { 162 BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AS_CHILD_AT, ~) 163 }; 164 return proto_generator()(that); 165 } 166 }; 167 168 template<typename Tag, typename Sequence> 169 struct unpack_expr_<Tag, deduce_domain, Sequence, N> 170 { 171 BOOST_PROTO_FUSION_ITERATORS_TYPE(N) 172 173 typedef 174 unpack_expr_< 175 Tag 176 , typename BOOST_PP_CAT(deduce_domain, N)< 177 BOOST_PP_ENUM(N, BOOST_PROTO_FUSION_AT_TYPE, ~) 178 >::type 179 , Sequence 180 , N 181 > 182 other; 183 184 typedef typename other::type type; 185 callunpack_expr_186 static type const call(Sequence const &sequence) 187 { 188 return other::call(sequence); 189 } 190 }; 191 192 #undef N 193 #undef M 194 195 #endif 196