File indexing completed on 2025-12-16 10:07:35
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_PROTO_TRANSFORM_FOLD_TREE_HPP_EAN_11_05_2007
0010 #define BOOST_PROTO_TRANSFORM_FOLD_TREE_HPP_EAN_11_05_2007
0011
0012 #include <boost/type_traits/is_same.hpp>
0013 #include <boost/proto/proto_fwd.hpp>
0014 #include <boost/proto/traits.hpp>
0015 #include <boost/proto/matches.hpp>
0016 #include <boost/proto/transform/fold.hpp>
0017 #include <boost/proto/transform/impl.hpp>
0018
0019 namespace boost { namespace proto
0020 {
0021 namespace detail
0022 {
0023 template<typename Tag>
0024 struct has_tag
0025 {
0026 template<typename Expr, typename State, typename Data, typename EnableIf = Tag>
0027 struct impl
0028 {
0029 typedef mpl::false_ result_type;
0030 };
0031
0032 template<typename Expr, typename State, typename Data>
0033 struct impl<Expr, State, Data, typename Expr::proto_tag>
0034 {
0035 typedef mpl::true_ result_type;
0036 };
0037
0038 template<typename Expr, typename State, typename Data>
0039 struct impl<Expr &, State, Data, typename Expr::proto_tag>
0040 {
0041 typedef mpl::true_ result_type;
0042 };
0043 };
0044
0045 template<typename Tag, typename Fun>
0046 struct fold_tree_
0047 : if_<has_tag<Tag>, fold<_, _state, fold_tree_<Tag, Fun> >, Fun>
0048 {};
0049
0050 template<typename Tag, typename Fun>
0051 struct reverse_fold_tree_
0052 : if_<has_tag<Tag>, reverse_fold<_, _state, reverse_fold_tree_<Tag, Fun> >, Fun>
0053 {};
0054 }
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088 template<typename Sequence, typename State0, typename Fun>
0089 struct fold_tree
0090 : transform<fold_tree<Sequence, State0, Fun> >
0091 {
0092 template<typename Expr, typename State, typename Data>
0093 struct impl
0094 : fold<
0095 Sequence
0096 , State0
0097 , detail::fold_tree_<typename Expr::proto_tag, Fun>
0098 >::template impl<Expr, State, Data>
0099 {};
0100
0101 template<typename Expr, typename State, typename Data>
0102 struct impl<Expr &, State, Data>
0103 : fold<
0104 Sequence
0105 , State0
0106 , detail::fold_tree_<typename Expr::proto_tag, Fun>
0107 >::template impl<Expr &, State, Data>
0108 {};
0109 };
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 template<typename Sequence, typename State0, typename Fun>
0144 struct reverse_fold_tree
0145 : transform<reverse_fold_tree<Sequence, State0, Fun> >
0146 {
0147 template<typename Expr, typename State, typename Data>
0148 struct impl
0149 : reverse_fold<
0150 Sequence
0151 , State0
0152 , detail::reverse_fold_tree_<typename Expr::proto_tag, Fun>
0153 >::template impl<Expr, State, Data>
0154 {};
0155
0156 template<typename Expr, typename State, typename Data>
0157 struct impl<Expr &, State, Data>
0158 : reverse_fold<
0159 Sequence
0160 , State0
0161 , detail::reverse_fold_tree_<typename Expr::proto_tag, Fun>
0162 >::template impl<Expr &, State, Data>
0163 {};
0164 };
0165
0166
0167
0168 template<typename Sequence, typename State0, typename Fun>
0169 struct is_callable<fold_tree<Sequence, State0, Fun> >
0170 : mpl::true_
0171 {};
0172
0173
0174
0175 template<typename Sequence, typename State0, typename Fun>
0176 struct is_callable<reverse_fold_tree<Sequence, State0, Fun> >
0177 : mpl::true_
0178 {};
0179
0180 }}
0181
0182 #endif