Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:45:07

0001 /*==============================================================================
0002     Copyright (c) 2010 Thomas Heller
0003     Copyright (c) 2010 Eric Niebler
0004 
0005     Distributed under the Boost Software License, Version 1.0. (See accompanying
0006     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 ==============================================================================*/
0008 #ifndef BOOST_PHOENIX_CORE_ARITY_HPP
0009 #define BOOST_PHOENIX_CORE_ARITY_HPP
0010 
0011 #include <boost/phoenix/core/limits.hpp>
0012 #include <boost/is_placeholder.hpp>
0013 #include <boost/mpl/max.hpp>
0014 #include <boost/mpl/int.hpp>
0015 #include <boost/phoenix/core/meta_grammar.hpp>
0016 #include <boost/phoenix/core/terminal_fwd.hpp>
0017 #include <boost/phoenix/support/vector.hpp>
0018 #include <boost/proto/matches.hpp>
0019 #include <boost/proto/transform/fold.hpp>
0020 
0021 namespace boost { namespace phoenix
0022 {
0023     /////////////////////////////////////////////////////////////////////////////
0024     //
0025     //  Calculate the arity of an expression using proto transforms
0026     //
0027     /////////////////////////////////////////////////////////////////////////////
0028     
0029     struct arity;
0030 
0031     namespace result_of
0032     {
0033         template <typename Expr>
0034         struct arity
0035             : mpl::int_<
0036                 evaluator::impl<
0037                     Expr const&
0038                   , vector2<
0039                         mpl::int_<0>
0040                       , boost::phoenix::arity
0041                     >&
0042                   , proto::empty_env
0043                 >::result_type::value
0044             >
0045         {};
0046     }
0047 
0048     struct arity
0049     {
0050         template <typename Rule, typename Dummy = void>
0051         struct when
0052             : proto::fold<
0053                 proto::_
0054               , mpl::int_<0>
0055               , proto::make<mpl::max<
0056                     proto::_state
0057                   , proto::call<
0058                         evaluator(
0059                             proto::_
0060                           , proto::call<
0061                                 functional::context(_env, _actions)
0062                             >
0063                         )
0064                     >
0065                 >()>
0066             >
0067         {};
0068     };
0069 
0070     template <typename Dummy>
0071     struct arity::when<rule::argument, Dummy>
0072         : proto::make<is_placeholder<proto::_value>()>
0073     {};
0074     
0075     template <typename Dummy>
0076     struct arity::when<rule::custom_terminal, Dummy>
0077         : proto::make<mpl::int_<0>()>
0078     {};
0079     
0080     template <typename Dummy>
0081     struct arity::when<rule::terminal, Dummy>
0082         : proto::make<mpl::int_<0>()>
0083     {};
0084 }}
0085 
0086 #endif