Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/phoenix/core/actor.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*=============================================================================
0002     Copyright (c) 2005-2010 Joel de Guzman
0003     Copyright (c) 2010 Eric Niebler
0004     Copyright (c) 2010 Thomas Heller
0005     Copyright (c) 2014 John Fletcher
0006 
0007     Distributed under the Boost Software License, Version 1.0. (See accompanying
0008     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 ==============================================================================*/
0010 #ifndef BOOST_PHOENIX_CORE_ACTOR_HPP
0011 #define BOOST_PHOENIX_CORE_ACTOR_HPP
0012 
0013 #include <boost/phoenix/core/limits.hpp>
0014 
0015 #include <boost/is_placeholder.hpp>
0016 #include <boost/mpl/identity.hpp>
0017 #include <boost/mpl/eval_if.hpp>
0018 #include <boost/phoenix/core/domain.hpp>
0019 #include <boost/phoenix/core/environment.hpp>
0020 #include <boost/phoenix/core/is_nullary.hpp>
0021 #include <boost/phoenix/core/meta_grammar.hpp>
0022 #include <boost/phoenix/support/iterate.hpp>
0023 #include <boost/phoenix/support/vector.hpp>
0024 #include <boost/proto/extends.hpp>
0025 #include <boost/proto/make_expr.hpp>
0026 #include <boost/utility/result_of.hpp>
0027 #include <boost/mpl/void.hpp>
0028 #include <cstring>
0029 #ifndef BOOST_PHOENIX_NO_VARIADIC_ACTOR
0030 #   include <boost/mpl/if.hpp>
0031 #   include <boost/type_traits/is_reference.hpp>
0032 #   include <boost/phoenix/core/detail/index_sequence.hpp>
0033 #endif
0034 
0035 #ifdef BOOST_MSVC
0036 #pragma warning(push)
0037 #pragma warning(disable: 4522) // 'this' used in base member initializer list
0038 #pragma warning(disable: 4510) // default constructor could not be generated
0039 #pragma warning(disable: 4610) // can never be instantiated - user defined cons
0040 #endif
0041 
0042 namespace boost { namespace phoenix
0043 {
0044     template <typename Expr>
0045     struct actor;
0046 
0047     namespace detail
0048     {
0049         struct error_expecting_arguments
0050         {
0051             template <typename T>
0052             error_expecting_arguments(T const&) {}
0053         };
0054 
0055         struct error_invalid_lambda_expr
0056         {
0057             template <typename T>
0058             error_invalid_lambda_expr(T const&) {}
0059         };
0060 
0061         template <typename T>
0062         struct result_type_deduction_helper
0063         {
0064             typedef T const & type;
0065         };
0066 
0067         template <typename T>
0068         struct result_type_deduction_helper<T &>
0069         {
0070             typedef T & type;
0071         };
0072 
0073         template <typename T>
0074         struct result_type_deduction_helper<T const &>
0075         {
0076             typedef T const & type;
0077         };
0078     }
0079 
0080     namespace result_of
0081     {
0082 #ifdef BOOST_PHOENIX_NO_VARIADIC_ACTOR
0083         // Bring in the result_of::actor<>
0084         #include <boost/phoenix/core/detail/cpp03/actor_result_of.hpp>
0085 #else
0086         template <typename Expr, typename... A>
0087         struct actor_impl
0088         {
0089             typedef
0090                 typename boost::phoenix::evaluator::impl<
0091                     Expr const&
0092                   , vector2<
0093                         typename vector_chooser<sizeof...(A) + 1>::
0094                           template apply<const ::boost::phoenix::actor<Expr> *, A...>::type&
0095                       , default_actions
0096                     > const &
0097                   , proto::empty_env
0098                 >::result_type
0099                 type;
0100         };
0101 
0102         template <typename Expr, typename... A>
0103         struct actor : actor_impl<Expr, A...> {};
0104 
0105         template <typename Expr>
0106         struct nullary_actor_result : actor_impl<Expr> {};
0107 #endif
0108 
0109         template <typename Expr>
0110         struct actor<Expr>
0111         {
0112             typedef
0113                 // avoid calling result_of::actor when this is false
0114                 typename mpl::eval_if_c<
0115                     result_of::is_nullary<Expr>::value
0116                   , nullary_actor_result<Expr>
0117                   , mpl::identity<detail::error_expecting_arguments>
0118                 >::type
0119             type;
0120         };
0121     }
0122 
0123     ////////////////////////////////////////////////////////////////////////////
0124     //
0125     //  actor
0126     //
0127     //      The actor class. The main thing! In phoenix, everything is an actor
0128     //      This class is responsible for full function evaluation. Partial
0129     //      function evaluation involves creating a hierarchy of actor objects.
0130     //
0131     ////////////////////////////////////////////////////////////////////////////
0132 #if defined __clang__ && defined __has_warning
0133 #  pragma clang diagnostic push
0134 #  if __has_warning("-Wdeprecated-copy")
0135 #    pragma clang diagnostic ignored "-Wdeprecated-copy"
0136 #  endif
0137 #endif
0138     template <typename Expr>
0139     struct actor
0140     {
0141         typedef typename
0142             mpl::eval_if_c<
0143                 mpl::or_<
0144                     is_custom_terminal<Expr>
0145                   , mpl::bool_<is_placeholder<Expr>::value>
0146                 >::value
0147               , proto::terminal<Expr>
0148               , mpl::identity<Expr>
0149             >::type
0150             expr_type;
0151 
0152         BOOST_PROTO_BASIC_EXTENDS(expr_type, actor<Expr>, phoenix_domain)
0153         BOOST_PROTO_EXTENDS_SUBSCRIPT()
0154         BOOST_PROTO_EXTENDS_ASSIGN_()
0155 
0156         template <typename Sig>
0157         struct result;
0158 
0159         typename result_of::actor<proto_base_expr>::type
0160         operator()()
0161         {
0162             typedef vector1<const actor<Expr> *> env_type;
0163             env_type env = {this};
0164 
0165             return phoenix::eval(*this, phoenix::context(env, default_actions()));
0166         }
0167 
0168         typename result_of::actor<proto_base_expr>::type
0169         operator()() const
0170         {
0171             typedef vector1<const actor<Expr> *> env_type;
0172             env_type env = {this};
0173 
0174             return phoenix::eval(*this, phoenix::context(env, default_actions()));
0175         }
0176 
0177         template <typename Env>
0178         typename evaluator::impl<
0179             proto_base_expr const &
0180           , typename result_of::context<
0181                 Env const &
0182               , default_actions const &
0183             >::type
0184           , proto::empty_env
0185         >::result_type
0186         eval(Env const & env) const
0187         {
0188             return phoenix::eval(*this, phoenix::context(env, default_actions()));
0189         }
0190 
0191 #ifdef BOOST_PHOENIX_NO_VARIADIC_ACTOR
0192         // Bring in the rest
0193         #include <boost/phoenix/core/detail/cpp03/actor_operator.hpp>
0194 #else
0195         template <typename This, typename... A>
0196         struct result<This(A...)>
0197             : result_of::actor<
0198                 proto_base_expr
0199               , typename mpl::if_<is_reference<A>, A, A const &>::type...
0200             >
0201         {};
0202 
0203         template <typename... A>
0204         typename result<actor(A...)>::type
0205         operator()(A &&... a)
0206         {
0207             typedef
0208                 typename vector_chooser<sizeof...(A) + 1>::template apply<
0209                     const actor<Expr> *
0210                   , typename mpl::if_<is_reference<A>, A, A const &>::type...
0211                 >::type
0212             env_type;
0213 
0214             env_type env = {this, a...};
0215             return phoenix::eval(*this, phoenix::context(env, default_actions()));
0216         }
0217 
0218         template <typename... A>
0219         typename result<actor(A...)>::type
0220         operator()(A &&... a) const
0221         {
0222             typedef
0223                 typename vector_chooser<sizeof...(A) + 1>::template apply<
0224                     const actor<Expr> *
0225                   , typename mpl::if_<is_reference<A>, A, A const &>::type...
0226                 >::type
0227             env_type;
0228 
0229             env_type env = {this, a...};
0230             return phoenix::eval(*this, phoenix::context(env, default_actions()));
0231         }
0232 #endif
0233 
0234         BOOST_DELETED_FUNCTION(actor& operator=(actor const&))
0235     };
0236 #if defined __clang__ && defined __has_warning
0237 #  pragma clang diagnostic pop
0238 #endif
0239 }}
0240 
0241 namespace boost
0242 {
0243     // specialize boost::result_of to return the proper result type
0244     template <typename Expr>
0245     struct result_of<phoenix::actor<Expr>()>
0246         : phoenix::result_of::actor<typename phoenix::actor<Expr>::proto_base_expr>
0247     {};
0248 
0249     template <typename Expr>
0250     struct result_of<phoenix::actor<Expr> const()>
0251         : phoenix::result_of::actor<typename phoenix::actor<Expr>::proto_base_expr>
0252     {};
0253 }
0254 
0255 
0256 #ifdef BOOST_MSVC
0257 #pragma warning(pop)
0258 #endif
0259 
0260 #endif
0261