123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- #ifndef BOOST_PROTO_CONTEXT_CALLABLE_HPP_EAN_06_23_2007
- #define BOOST_PROTO_CONTEXT_CALLABLE_HPP_EAN_06_23_2007
- #include <boost/config.hpp>
- #include <boost/detail/workaround.hpp>
- #include <boost/preprocessor/cat.hpp>
- #include <boost/preprocessor/iteration/iterate.hpp>
- #include <boost/preprocessor/facilities/intercept.hpp>
- #include <boost/preprocessor/repetition/repeat.hpp>
- #include <boost/preprocessor/repetition/enum_params.hpp>
- #include <boost/preprocessor/repetition/enum_trailing.hpp>
- #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
- #include <boost/preprocessor/arithmetic/inc.hpp>
- #include <boost/preprocessor/selection/max.hpp>
- #include <boost/mpl/if.hpp>
- #include <boost/mpl/bool.hpp>
- #include <boost/utility/result_of.hpp>
- #include <boost/type_traits/remove_cv.hpp>
- #include <boost/proto/proto_fwd.hpp>
- #include <boost/proto/traits.hpp> // for child_c
- namespace boost { namespace proto
- {
- namespace detail
- {
- template<typename Context>
- struct callable_context_wrapper
- : remove_cv<Context>::type
- {
- callable_context_wrapper();
- typedef private_type_ fun_type(...);
- operator fun_type *() const;
- private:
- callable_context_wrapper &operator =(callable_context_wrapper const &);
- };
- template<typename T>
- yes_type check_is_expr_handled(T const &);
- no_type check_is_expr_handled(private_type_ const &);
- template<typename Expr, typename Context, long Arity = Expr::proto_arity_c>
- struct is_expr_handled;
- template<typename Expr, typename Context>
- struct is_expr_handled<Expr, Context, 0>
- {
- static callable_context_wrapper<Context> &sctx_;
- static Expr &sexpr_;
- static typename Expr::proto_tag &stag_;
- static const bool value =
- sizeof(yes_type) ==
- sizeof(
- detail::check_is_expr_handled(
- (sctx_(stag_, proto::value(sexpr_)), 0)
- )
- );
- typedef mpl::bool_<value> type;
- };
- }
- namespace context
- {
-
-
-
-
-
-
-
-
-
-
-
-
- template<
- typename Expr
- , typename Context
- , long Arity
- >
- struct callable_eval
- {};
-
-
-
-
-
-
-
-
-
-
-
-
- template<typename Expr, typename Context>
- struct callable_eval<Expr, Context, 0>
- {
- typedef typename proto::result_of::value<Expr const &>::type value_type;
- typedef
- typename BOOST_PROTO_RESULT_OF<
- Context(typename Expr::proto_tag, value_type)
- >::type
- result_type;
-
-
-
- result_type operator ()(Expr &expr, Context &context) const
- {
- return context(typename Expr::proto_tag(), proto::value(expr));
- }
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<
- typename Context
- , typename DefaultCtx
- >
- struct callable_context
- {
-
-
-
-
-
-
-
-
-
-
-
-
- template<typename Expr, typename ThisContext = Context>
- struct eval
- : mpl::if_c<
- detail::is_expr_handled<Expr, Context>::value
- , callable_eval<Expr, ThisContext>
- , typename DefaultCtx::template eval<Expr, Context>
- >::type
- {};
- };
- }
- #include <boost/proto/context/detail/callable_eval.hpp>
- }}
- #endif
|