]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/proto/context/detail/callable_eval.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / proto / context / detail / callable_eval.hpp
1 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
2
3 #include <boost/proto/context/detail/preprocessed/callable_eval.hpp>
4
5 #elif !defined(BOOST_PP_IS_ITERATING)
6
7 #define BOOST_PROTO_CHILD_N_TYPE(Z, N, Expr) \
8 typedef typename proto::result_of::child_c<Expr const &, N>::type BOOST_PP_CAT(child, N); \
9 /**/
10
11 #define BOOST_PROTO_CHILD_N(Z, N, expr) \
12 proto::child_c<N>(expr) \
13 /**/
14
15 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
16 #pragma wave option(preserve: 2, line: 0, output: "preprocessed/callable_eval.hpp")
17 #endif
18
19 ///////////////////////////////////////////////////////////////////////////////
20 /// \file callable_eval.hpp
21 /// Contains specializations of the callable_eval\<\> class template.
22 //
23 // Copyright 2008 Eric Niebler. Distributed under the Boost
24 // Software License, Version 1.0. (See accompanying file
25 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
26
27 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
28 #pragma wave option(preserve: 1)
29 #endif
30
31 #define BOOST_PP_ITERATION_PARAMS_1 \
32 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/context/detail/callable_eval.hpp>))
33 #include BOOST_PP_ITERATE()
34
35 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
36 #pragma wave option(output: null)
37 #endif
38
39 #undef BOOST_PROTO_CHILD_N_TYPE
40 #undef BOOST_PROTO_CHILD_N
41
42 #else
43
44 #define N BOOST_PP_ITERATION()
45
46 namespace detail
47 {
48 template<typename Expr, typename Context>
49 struct is_expr_handled<Expr, Context, N>
50 {
51 static callable_context_wrapper<Context> &sctx_;
52 static Expr &sexpr_;
53 static typename Expr::proto_tag &stag_;
54
55 static const bool value =
56 sizeof(yes_type) ==
57 sizeof(
58 detail::check_is_expr_handled(
59 (sctx_(
60 stag_
61 BOOST_PP_ENUM_TRAILING(N, BOOST_PROTO_CHILD_N, sexpr_)
62 ), 0)
63 )
64 );
65
66 typedef mpl::bool_<value> type;
67 };
68 }
69
70 namespace context
71 {
72 /// \brief A BinaryFunction that accepts a Proto expression and a
73 /// callable context and calls the context with the expression tag
74 /// and children as arguments, effectively fanning the expression
75 /// out.
76 ///
77 /// <tt>callable_eval\<\></tt> requires that \c Context is a
78 /// PolymorphicFunctionObject that can be invoked with \c Expr's
79 /// tag and children as expressions, as follows:
80 ///
81 /// \code
82 /// context(Expr::proto_tag(), child_c\<0\>(expr), child_c\<1\>(expr), ...)
83 /// \endcode
84 template<typename Expr, typename Context>
85 struct callable_eval<Expr, Context, N>
86 {
87 BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD_N_TYPE, Expr)
88
89 typedef
90 typename BOOST_PROTO_RESULT_OF<
91 Context(
92 typename Expr::proto_tag
93 BOOST_PP_ENUM_TRAILING_PARAMS(N, child)
94 )
95 >::type
96 result_type;
97
98 /// \param expr The current expression
99 /// \param context The callable evaluation context
100 /// \return <tt>context(Expr::proto_tag(), child_c\<0\>(expr), child_c\<1\>(expr), ...)</tt>
101 result_type operator ()(Expr &expr, Context &context) const
102 {
103 return context(
104 typename Expr::proto_tag()
105 BOOST_PP_ENUM_TRAILING(N, BOOST_PROTO_CHILD_N, expr)
106 );
107 }
108 };
109 }
110
111 #undef N
112
113 #endif