123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- #ifndef BOOST_PROTO_TRANSFORM_FOLD_TREE_HPP_EAN_11_05_2007
- #define BOOST_PROTO_TRANSFORM_FOLD_TREE_HPP_EAN_11_05_2007
- #include <boost/type_traits/is_same.hpp>
- #include <boost/proto/proto_fwd.hpp>
- #include <boost/proto/traits.hpp>
- #include <boost/proto/matches.hpp>
- #include <boost/proto/transform/fold.hpp>
- #include <boost/proto/transform/impl.hpp>
- namespace boost { namespace proto
- {
- namespace detail
- {
- template<typename Tag>
- struct has_tag
- {
- template<typename Expr, typename State, typename Data, typename EnableIf = Tag>
- struct impl
- {
- typedef mpl::false_ result_type;
- };
- template<typename Expr, typename State, typename Data>
- struct impl<Expr, State, Data, typename Expr::proto_tag>
- {
- typedef mpl::true_ result_type;
- };
- template<typename Expr, typename State, typename Data>
- struct impl<Expr &, State, Data, typename Expr::proto_tag>
- {
- typedef mpl::true_ result_type;
- };
- };
- template<typename Tag, typename Fun>
- struct fold_tree_
- : if_<has_tag<Tag>, fold<_, _state, fold_tree_<Tag, Fun> >, Fun>
- {};
- template<typename Tag, typename Fun>
- struct reverse_fold_tree_
- : if_<has_tag<Tag>, reverse_fold<_, _state, reverse_fold_tree_<Tag, Fun> >, Fun>
- {};
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<typename Sequence, typename State0, typename Fun>
- struct fold_tree
- : transform<fold_tree<Sequence, State0, Fun> >
- {
- template<typename Expr, typename State, typename Data>
- struct impl
- : fold<
- Sequence
- , State0
- , detail::fold_tree_<typename Expr::proto_tag, Fun>
- >::template impl<Expr, State, Data>
- {};
- template<typename Expr, typename State, typename Data>
- struct impl<Expr &, State, Data>
- : fold<
- Sequence
- , State0
- , detail::fold_tree_<typename Expr::proto_tag, Fun>
- >::template impl<Expr &, State, Data>
- {};
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<typename Sequence, typename State0, typename Fun>
- struct reverse_fold_tree
- : transform<reverse_fold_tree<Sequence, State0, Fun> >
- {
- template<typename Expr, typename State, typename Data>
- struct impl
- : reverse_fold<
- Sequence
- , State0
- , detail::reverse_fold_tree_<typename Expr::proto_tag, Fun>
- >::template impl<Expr, State, Data>
- {};
- template<typename Expr, typename State, typename Data>
- struct impl<Expr &, State, Data>
- : reverse_fold<
- Sequence
- , State0
- , detail::reverse_fold_tree_<typename Expr::proto_tag, Fun>
- >::template impl<Expr &, State, Data>
- {};
- };
-
-
- template<typename Sequence, typename State0, typename Fun>
- struct is_callable<fold_tree<Sequence, State0, Fun> >
- : mpl::true_
- {};
-
-
- template<typename Sequence, typename State0, typename Fun>
- struct is_callable<reverse_fold_tree<Sequence, State0, Fun> >
- : mpl::true_
- {};
- }}
- #endif
|