]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/include/boost/phoenix/core/arity.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / phoenix / include / boost / phoenix / core / arity.hpp
1 /*==============================================================================
2 Copyright (c) 2010 Thomas Heller
3 Copyright (c) 2010 Eric Niebler
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #ifndef BOOST_PHOENIX_CORE_ARITY_HPP
9 #define BOOST_PHOENIX_CORE_ARITY_HPP
10
11 #include <boost/phoenix/core/limits.hpp>
12 #include <boost/is_placeholder.hpp>
13 #include <boost/mpl/max.hpp>
14 #include <boost/mpl/int.hpp>
15 #include <boost/phoenix/core/meta_grammar.hpp>
16 #include <boost/phoenix/core/terminal_fwd.hpp>
17 #include <boost/phoenix/support/vector.hpp>
18 #include <boost/proto/matches.hpp>
19 #include <boost/proto/transform/fold.hpp>
20
21 namespace boost { namespace phoenix
22 {
23 /////////////////////////////////////////////////////////////////////////////
24 //
25 // Calculate the arity of an expression using proto transforms
26 //
27 /////////////////////////////////////////////////////////////////////////////
28
29 struct arity;
30
31 namespace result_of
32 {
33 template <typename Expr>
34 struct arity
35 : mpl::int_<
36 evaluator::impl<
37 Expr const&
38 , vector2<
39 mpl::int_<0>
40 , boost::phoenix::arity
41 >&
42 , proto::empty_env
43 >::result_type::value
44 >
45 {};
46 }
47
48 struct arity
49 {
50 template <typename Rule, typename Dummy = void>
51 struct when
52 : proto::fold<
53 proto::_
54 , mpl::int_<0>
55 , proto::make<mpl::max<
56 proto::_state
57 , proto::call<
58 evaluator(
59 proto::_
60 , proto::call<
61 functional::context(_env, _actions)
62 >
63 )
64 >
65 >()>
66 >
67 {};
68 };
69
70 template <typename Dummy>
71 struct arity::when<rule::argument, Dummy>
72 : proto::make<is_placeholder<proto::_value>()>
73 {};
74
75 template <typename Dummy>
76 struct arity::when<rule::custom_terminal, Dummy>
77 : proto::make<mpl::int_<0>()>
78 {};
79
80 template <typename Dummy>
81 struct arity::when<rule::terminal, Dummy>
82 : proto::make<mpl::int_<0>()>
83 {};
84 }}
85
86 #endif