File indexing completed on 2025-01-18 09:50:27
0001 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
0002
0003 #include <boost/proto/detail/preprocessed/traits.hpp>
0004
0005 #elif !defined(BOOST_PP_IS_ITERATING)
0006
0007 #define BOOST_PROTO_CHILD(Z, N, DATA) \
0008 \
0009 typedef BOOST_PP_CAT(DATA, N) BOOST_PP_CAT(proto_child, N); \
0010
0011
0012 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0013 #pragma wave option(preserve: 2, line: 0, output: "preprocessed/traits.hpp")
0014 #endif
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0025 #pragma wave option(preserve: 1)
0026 #endif
0027
0028 #define BOOST_PP_ITERATION_PARAMS_1 \
0029 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/traits.hpp>))
0030 #include BOOST_PP_ITERATE()
0031
0032 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0033 #pragma wave option(output: null)
0034 #endif
0035
0036 #undef BOOST_PROTO_CHILD
0037
0038 #else
0039
0040 #define N BOOST_PP_ITERATION()
0041
0042 #if N > 0
0043
0044
0045
0046
0047 template<BOOST_PP_ENUM_PARAMS(N, typename A)>
0048 struct function
0049 #if N != BOOST_PROTO_MAX_ARITY
0050 <
0051 BOOST_PP_ENUM_PARAMS(N, A)
0052 BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
0053 >
0054 #endif
0055 : proto::transform<
0056 function<
0057 BOOST_PP_ENUM_PARAMS(N, A)
0058 BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
0059 >
0060 , int
0061 >
0062 {
0063 typedef proto::expr<proto::tag::function, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> type;
0064 typedef proto::basic_expr<proto::tag::function, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> proto_grammar;
0065
0066 template<typename Expr, typename State, typename Data>
0067 struct impl
0068 : detail::pass_through_impl<function, deduce_domain, Expr, State, Data>
0069 {};
0070
0071
0072 typedef proto::tag::function proto_tag;
0073 BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, A)
0074 BOOST_PP_REPEAT_FROM_TO(
0075 N
0076 , BOOST_PROTO_MAX_ARITY
0077 , BOOST_PROTO_CHILD
0078 , detail::if_vararg<BOOST_PP_CAT(A, BOOST_PP_DEC(N))> BOOST_PP_INTERCEPT
0079 )
0080 };
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
0091 struct nary_expr
0092 #if N != BOOST_PROTO_MAX_ARITY
0093 <
0094 Tag
0095 BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
0096 BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
0097 >
0098 #endif
0099 : proto::transform<
0100 nary_expr<
0101 Tag
0102 BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
0103 BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
0104 >
0105 , int
0106 >
0107 {
0108 typedef proto::expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> type;
0109 typedef proto::basic_expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> proto_grammar;
0110
0111 template<typename Expr, typename State, typename Data>
0112 struct impl
0113 : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data>
0114 {};
0115
0116
0117 typedef Tag proto_tag;
0118 BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, A)
0119 BOOST_PP_REPEAT_FROM_TO(
0120 N
0121 , BOOST_PROTO_MAX_ARITY
0122 , BOOST_PROTO_CHILD
0123 , detail::if_vararg<BOOST_PP_CAT(A, BOOST_PP_DEC(N))> BOOST_PP_INTERCEPT
0124 )
0125 };
0126
0127 namespace detail
0128 {
0129 template<
0130 template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class T
0131 , BOOST_PP_ENUM_PARAMS(N, typename A)
0132 >
0133 struct is_callable_<T<BOOST_PP_ENUM_PARAMS(N, A)> BOOST_PROTO_TEMPLATE_ARITY_PARAM(N)>
0134 : is_same<BOOST_PP_CAT(A, BOOST_PP_DEC(N)), callable>
0135 {};
0136 }
0137
0138 #endif
0139
0140 namespace result_of
0141 {
0142
0143
0144
0145
0146
0147
0148 template<typename Expr>
0149 struct child_c<Expr, N>
0150 {
0151
0152 BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c);
0153
0154
0155
0156 typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type;
0157
0158
0159
0160
0161
0162
0163 typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::value_type type;
0164 };
0165
0166 template<typename Expr>
0167 struct child_c<Expr &, N>
0168 {
0169
0170 BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c);
0171
0172
0173
0174 typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type;
0175
0176
0177
0178
0179
0180
0181 typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::reference type;
0182
0183
0184
0185 BOOST_FORCEINLINE
0186 static type call(Expr &e)
0187 {
0188 return e.proto_base().BOOST_PP_CAT(child, N);
0189 }
0190 };
0191
0192 template<typename Expr>
0193 struct child_c<Expr const &, N>
0194 {
0195
0196 BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c);
0197
0198
0199
0200 typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type;
0201
0202
0203
0204
0205
0206
0207 typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::const_reference type;
0208
0209
0210
0211 BOOST_FORCEINLINE
0212 static type call(Expr const &e)
0213 {
0214 return e.proto_base().BOOST_PP_CAT(child, N);
0215 }
0216 };
0217 }
0218
0219 #undef N
0220
0221 #endif