File indexing completed on 2025-12-16 10:07:34
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007
0010 #define BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007
0011
0012 #include <boost/mpl/if.hpp>
0013 #include <boost/proto/proto_fwd.hpp>
0014 #include <boost/proto/traits.hpp>
0015 #include <boost/proto/transform/impl.hpp>
0016 #include <boost/type_traits/is_array.hpp>
0017 #include <boost/proto/transform/env.hpp>
0018
0019 namespace boost { namespace proto
0020 {
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 struct _expr : transform<_expr>
0033 {
0034 template<typename Expr, typename State, typename Data>
0035 struct impl : transform_impl<Expr, State, Data>
0036 {
0037 typedef Expr result_type;
0038
0039
0040
0041
0042
0043 BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param)
0044 operator()(
0045 typename impl::expr_param e
0046 , typename impl::state_param
0047 , typename impl::data_param
0048 ) const
0049 {
0050 return e;
0051 }
0052 };
0053 };
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 struct _state : transform<_state>
0066 {
0067 template<typename Expr, typename State, typename Data>
0068 struct impl : transform_impl<Expr, State, Data>
0069 {
0070 typedef State result_type;
0071
0072
0073
0074
0075
0076 BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::state_param)
0077 operator ()(
0078 typename impl::expr_param
0079 , typename impl::state_param s
0080 , typename impl::data_param
0081 ) const
0082 {
0083 return s;
0084 }
0085 };
0086 };
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 struct _data : transform<_data>
0100 {
0101 template<typename Expr, typename State, typename Data>
0102 struct impl
0103 : mpl::if_c<
0104 is_env<Data>::value
0105 , _env_var<data_type>
0106 , _env
0107 >::type::template impl<Expr, State, Data>
0108 {};
0109 };
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121 template<int N>
0122 struct _child_c : transform<_child_c<N> >
0123 {
0124 template<typename Expr, typename State, typename Data>
0125 struct impl : transform_impl<Expr, State, Data>
0126 {
0127 typedef
0128 typename result_of::child_c<Expr, N>::type
0129 result_type;
0130
0131
0132
0133
0134
0135
0136 #ifdef BOOST_PROTO_STRICT_RESULT_OF
0137 result_type
0138 #else
0139 typename result_of::child_c<typename impl::expr_param, N>::type
0140 #endif
0141 operator ()(
0142 typename impl::expr_param e
0143 , typename impl::state_param
0144 , typename impl::data_param
0145 ) const
0146 {
0147 return proto::child_c<N>(e);
0148 }
0149 };
0150 };
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162 struct _value : transform<_value>
0163 {
0164 template<typename Expr, typename State, typename Data>
0165 struct impl : transform_impl<Expr, State, Data>
0166 {
0167 typedef
0168 typename result_of::value<Expr>::type
0169 result_type;
0170
0171
0172
0173
0174
0175
0176 #ifdef BOOST_PROTO_STRICT_RESULT_OF
0177 typename mpl::if_c<is_array<result_type>::value, result_type &, result_type>::type
0178 #else
0179 typename result_of::value<typename impl::expr_param>::type
0180 #endif
0181 operator ()(
0182 typename impl::expr_param e
0183 , typename impl::state_param
0184 , typename impl::data_param
0185 ) const
0186 {
0187 return proto::value(e);
0188 }
0189 };
0190 };
0191
0192
0193
0194 struct _void : transform<_void>
0195 {
0196 template<typename Expr, typename State, typename Data>
0197 struct impl : transform_impl<Expr, State, Data>
0198 {
0199 typedef void result_type;
0200
0201
0202 void operator ()(
0203 typename impl::expr_param
0204 , typename impl::state_param
0205 , typename impl::data_param
0206 ) const
0207 {}
0208 };
0209 };
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222 struct _byref : callable
0223 {
0224 template<typename Sig>
0225 struct result;
0226
0227 template<typename This, typename T>
0228 struct result<This(T)>
0229 {
0230 typedef boost::reference_wrapper<T const> const type;
0231 };
0232
0233 template<typename This, typename T>
0234 struct result<This(T &)>
0235 {
0236 typedef boost::reference_wrapper<T> const type;
0237 };
0238
0239
0240
0241
0242
0243 template<typename T>
0244 boost::reference_wrapper<T> const operator ()(T &t) const
0245 {
0246 return boost::reference_wrapper<T>(t);
0247 }
0248
0249
0250
0251 template<typename T>
0252 boost::reference_wrapper<T const> const operator ()(T const &t) const
0253 {
0254 return boost::reference_wrapper<T const>(t);
0255 }
0256 };
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269 struct _byval : callable
0270 {
0271 template<typename Sig>
0272 struct result;
0273
0274 template<typename This, typename T>
0275 struct result<This(T)>
0276 {
0277 typedef T type;
0278 };
0279
0280 template<typename This, typename T>
0281 struct result<This(T &)>
0282 : result<This(T)>
0283 {};
0284
0285 template<typename This, typename T>
0286 struct result<This(boost::reference_wrapper<T>)>
0287 : result<This(T)>
0288 {};
0289
0290
0291
0292
0293 template<typename T>
0294 T operator ()(T const &t) const
0295 {
0296 return t;
0297 }
0298
0299
0300
0301 template<typename T>
0302 T operator ()(boost::reference_wrapper<T> const &t) const
0303 {
0304 return t;
0305 }
0306 };
0307
0308
0309
0310 template<>
0311 struct is_callable<_expr>
0312 : mpl::true_
0313 {};
0314
0315
0316
0317 template<>
0318 struct is_callable<_state>
0319 : mpl::true_
0320 {};
0321
0322
0323
0324 template<>
0325 struct is_callable<_data>
0326 : mpl::true_
0327 {};
0328
0329
0330
0331 template<int N>
0332 struct is_callable<_child_c<N> >
0333 : mpl::true_
0334 {};
0335
0336
0337
0338 template<>
0339 struct is_callable<_value>
0340 : mpl::true_
0341 {};
0342
0343
0344
0345 template<>
0346 struct is_callable<_byref>
0347 : mpl::true_
0348 {};
0349
0350
0351
0352 template<>
0353 struct is_callable<_byval>
0354 : mpl::true_
0355 {};
0356
0357 }}
0358
0359 #endif