123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- #ifndef BOOST_PROTO_TRANSFORM_WHEN_HPP_EAN_10_29_2007
- #define BOOST_PROTO_TRANSFORM_WHEN_HPP_EAN_10_29_2007
- #include <boost/preprocessor/cat.hpp>
- #include <boost/preprocessor/repetition/enum_params.hpp>
- #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
- #include <boost/preprocessor/iteration/iterate.hpp>
- #include <boost/mpl/at.hpp>
- #include <boost/mpl/if.hpp>
- #include <boost/mpl/map.hpp>
- #include <boost/mpl/eval_if.hpp>
- #include <boost/proto/proto_fwd.hpp>
- #include <boost/proto/traits.hpp>
- #include <boost/proto/transform/call.hpp>
- #include <boost/proto/transform/make.hpp>
- #include <boost/proto/transform/impl.hpp>
- #include <boost/proto/transform/env.hpp>
- #if defined(_MSC_VER)
- # pragma warning(push)
- # pragma warning(disable : 4714)
- #endif
- namespace boost { namespace proto
- {
- namespace detail
- {
- template<typename Grammar, typename R, typename Fun>
- struct when_impl
- : transform<when<Grammar, Fun> >
- {
- typedef Grammar first;
- typedef Fun second;
- typedef typename Grammar::proto_grammar proto_grammar;
-
-
- template<typename Expr, typename State, typename Data>
- struct impl : transform_impl<Expr, State, Data>
- {
-
- typedef
- typename mpl::if_c<
- is_callable<R>::value
- , proto::call<Fun>
- , proto::make<Fun>
- >::type
- which;
- typedef typename which::template impl<Expr, State, Data>::result_type result_type;
-
-
-
-
-
-
-
-
-
-
- BOOST_FORCEINLINE
- result_type operator ()(
- typename impl::expr_param e
- , typename impl::state_param s
- , typename impl::data_param d
- ) const
- {
- return typename which::template impl<Expr, State, Data>()(e, s, d);
- }
- };
- };
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<typename Grammar, typename PrimitiveTransform >
- struct when
- : PrimitiveTransform
- {
- typedef Grammar first;
- typedef PrimitiveTransform second;
- typedef typename Grammar::proto_grammar proto_grammar;
- };
-
-
-
-
-
-
-
-
-
-
-
-
- template<typename Grammar, typename Fun>
- struct when<Grammar, Fun *>
- : when<Grammar, Fun>
- {};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<typename Fun>
- struct otherwise
- : when<_, Fun>
- {};
- namespace envns_
- {
-
- BOOST_PROTO_DEFINE_ENV_VAR(transforms_type, transforms);
- }
- using envns_::transforms;
-
-
-
-
-
-
-
-
-
- template<typename Grammar>
- struct when<Grammar, external_transform>
- : proto::transform<when<Grammar, external_transform> >
- {
- typedef Grammar first;
- typedef external_transform second;
- typedef typename Grammar::proto_grammar proto_grammar;
- template<typename Expr, typename State, typename Data>
- struct impl
- : remove_reference<
- typename mpl::eval_if_c<
- proto::result_of::has_env_var<Data, transforms_type>::value
- , proto::result_of::env_var<Data, transforms_type>
- , proto::result_of::env_var<Data, data_type>
- >::type
- >::type::template when<Grammar>::template impl<Expr, State, Data>
- {};
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_MPL_LIMIT_MAP_SIZE, typename T, mpl::na)>
- struct external_transforms
- {
- typedef mpl::map<BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_MAP_SIZE, T)> map_type;
- template<typename Rule>
- struct when
- : proto::when<_, typename mpl::at<map_type, Rule>::type>
- {};
- };
-
- #include <boost/proto/transform/detail/when.hpp>
-
-
- template<typename Grammar, typename Transform>
- struct is_callable<when<Grammar, Transform> >
- : mpl::true_
- {};
- }}
- #if defined(_MSC_VER)
- # pragma warning(pop)
- #endif
- #endif
|