Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:19

0001 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
0002 
0003     #include <boost/proto/context/detail/preprocessed/callable_eval.hpp>
0004 
0005 #elif !defined(BOOST_PP_IS_ITERATING)
0006 
0007     #define BOOST_PROTO_CHILD_N_TYPE(Z, N, Expr)                                                    \
0008         typedef typename proto::result_of::child_c<Expr const &, N>::type BOOST_PP_CAT(child, N);   \
0009         /**/
0010 
0011     #define BOOST_PROTO_CHILD_N(Z, N, expr)                                                         \
0012         proto::child_c<N>(expr)                                                                     \
0013         /**/
0014 
0015     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0016         #pragma wave option(preserve: 2, line: 0, output: "preprocessed/callable_eval.hpp")
0017     #endif
0018 
0019     ///////////////////////////////////////////////////////////////////////////////
0020     /// \file callable_eval.hpp
0021     /// Contains specializations of the callable_eval\<\> class template.
0022     //
0023     //  Copyright 2008 Eric Niebler. Distributed under the Boost
0024     //  Software License, Version 1.0. (See accompanying file
0025     //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0026 
0027     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0028         #pragma wave option(preserve: 1)
0029     #endif
0030 
0031     #define BOOST_PP_ITERATION_PARAMS_1                                                             \
0032         (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/context/detail/callable_eval.hpp>))
0033     #include BOOST_PP_ITERATE()
0034 
0035     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0036         #pragma wave option(output: null)
0037     #endif
0038 
0039     #undef BOOST_PROTO_CHILD_N_TYPE
0040     #undef BOOST_PROTO_CHILD_N
0041 
0042 #else
0043 
0044     #define N BOOST_PP_ITERATION()
0045 
0046     namespace detail
0047     {
0048         template<typename Expr, typename Context>
0049         struct is_expr_handled<Expr, Context, N>
0050         {
0051             static callable_context_wrapper<Context> &sctx_;
0052             static Expr &sexpr_;
0053             static typename Expr::proto_tag &stag_;
0054 
0055             static const bool value =
0056                 sizeof(yes_type) ==
0057                 sizeof(
0058                     detail::check_is_expr_handled(
0059                         (sctx_(
0060                             stag_
0061                             BOOST_PP_ENUM_TRAILING(N, BOOST_PROTO_CHILD_N, sexpr_)
0062                         ), 0)
0063                     )
0064                 );
0065 
0066             typedef mpl::bool_<value> type;
0067         };
0068     }
0069 
0070     namespace context
0071     {
0072         /// \brief A BinaryFunction that accepts a Proto expression and a
0073         /// callable context and calls the context with the expression tag
0074         /// and children as arguments, effectively fanning the expression
0075         /// out.
0076         ///
0077         /// <tt>callable_eval\<\></tt> requires that \c Context is a
0078         /// PolymorphicFunctionObject that can be invoked with \c Expr's
0079         /// tag and children as expressions, as follows:
0080         ///
0081         /// \code
0082         /// context(Expr::proto_tag(), child_c\<0\>(expr), child_c\<1\>(expr), ...)
0083         /// \endcode
0084         template<typename Expr, typename Context>
0085         struct callable_eval<Expr, Context, N>
0086         {
0087             BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD_N_TYPE, Expr)
0088 
0089             typedef
0090                 typename BOOST_PROTO_RESULT_OF<
0091                     Context(
0092                         typename Expr::proto_tag
0093                         BOOST_PP_ENUM_TRAILING_PARAMS(N, child)
0094                     )
0095                 >::type
0096             result_type;
0097 
0098             /// \param expr The current expression
0099             /// \param context The callable evaluation context
0100             /// \return <tt>context(Expr::proto_tag(), child_c\<0\>(expr), child_c\<1\>(expr), ...)</tt>
0101             result_type operator ()(Expr &expr, Context &context) const
0102             {
0103                 return context(
0104                     typename Expr::proto_tag()
0105                     BOOST_PP_ENUM_TRAILING(N, BOOST_PROTO_CHILD_N, expr)
0106                 );
0107             }
0108         };
0109     }
0110 
0111     #undef N
0112 
0113 #endif