Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:46:33

0001 /*==============================================================================
0002     Copyright (c) 2005-2010 Joel de Guzman
0003     Copyright (c) 2010 Thomas Heller
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_SCOPE_SCOPED_ENVIRONMENT_HPP
0009 #define BOOST_PHOENIX_SCOPE_SCOPED_ENVIRONMENT_HPP
0010 
0011 #include <boost/phoenix/core/limits.hpp>
0012 #include <boost/mpl/int.hpp>
0013 #include <boost/fusion/sequence/sequence_facade.hpp>
0014 #include <boost/fusion/sequence/intrinsic/begin.hpp>
0015 #include <boost/fusion/sequence/intrinsic/end.hpp>
0016 #include <boost/fusion/sequence/intrinsic/size.hpp>
0017 #include <boost/fusion/sequence/intrinsic/value_at.hpp>
0018 #include <boost/fusion/sequence/intrinsic/at.hpp>
0019 #include <boost/fusion/support/category_of.hpp>
0020 #include <boost/fusion/include/pop_front.hpp>
0021 #include <boost/utility/result_of.hpp>
0022 
0023 namespace boost { namespace phoenix
0024 {
0025     template<typename Env, typename OuterEnv, typename Locals, typename Map>
0026     struct scoped_environment
0027         : fusion::sequence_facade<
0028             scoped_environment<Env, OuterEnv, Locals, Map>
0029           , fusion::random_access_traversal_tag
0030         >
0031     {
0032         typedef Env env_type;
0033         typedef OuterEnv outer_env_type;
0034         typedef Locals locals_type;
0035         typedef Map map_type;
0036 
0037         scoped_environment(
0038             Env const & env_
0039           , OuterEnv const &outer_env_
0040           , Locals const &locals_
0041         )
0042             : env(env_)
0043             , outer_env(outer_env_)
0044             , locals(locals_)
0045         {}
0046 
0047         scoped_environment(scoped_environment const & o)
0048             : env(o.env)
0049             , outer_env(o.outer_env)
0050             , locals(o.locals)
0051         {}
0052 
0053         Env      const & env;
0054         OuterEnv const & outer_env;
0055         Locals   const & locals;
0056 
0057         typedef typename
0058             fusion::result_of::pop_front<
0059                 typename add_const<
0060                     typename proto::detail::uncvref<Env>::type
0061                 >::type
0062             >::type
0063             args_type;
0064 
0065         args_type args() const
0066         {
0067             return fusion::pop_front(env);
0068         }
0069     
0070         #define BOOST_PHOENIX_ADAPT_SCOPED_ENVIRONMENT(INTRINSIC)               \
0071         template <typename Seq>                                                 \
0072         struct INTRINSIC                                                        \
0073         {                                                                       \
0074             typedef                                                             \
0075                 typename fusion::result_of::INTRINSIC<                          \
0076                     typename mpl::eval_if_c<                                    \
0077                         is_const<                                               \
0078                             typename remove_reference<                          \
0079                                 typename Seq::env_type                          \
0080                             >::type                                             \
0081                         >::value                                                \
0082                       , add_const<                                              \
0083                             typename proto::detail::uncvref<                    \
0084                                 typename Seq::env_type                          \
0085                             >::type                                             \
0086                         >                                                       \
0087                       , proto::detail::uncvref<                                 \
0088                             typename Seq::env_type                              \
0089                         >                                                       \
0090                     >::type                                                     \
0091                 >::type                                                         \
0092                 type;                                                           \
0093                                                                                 \
0094             static type call(Seq & seq)                                         \
0095             {                                                                   \
0096                 return fusion::INTRINSIC(seq.env);                              \
0097             }                                                                   \
0098         }                                                                       \
0099         /**/
0100         BOOST_PHOENIX_ADAPT_SCOPED_ENVIRONMENT(begin);
0101         BOOST_PHOENIX_ADAPT_SCOPED_ENVIRONMENT(end);
0102         BOOST_PHOENIX_ADAPT_SCOPED_ENVIRONMENT(size);
0103         #undef BOOST_PHOENIX_ADAPT_SCOPED_ENVIRONMENT
0104     
0105         template <typename Seq, typename N>
0106         struct value_at
0107         {
0108             typedef
0109                 typename fusion::result_of::value_at<
0110                     typename mpl::eval_if_c<
0111                         is_const<
0112                             typename remove_reference<
0113                                 typename Seq::env_type
0114                             >::type
0115                         >::value
0116                       , add_const<
0117                             typename proto::detail::uncvref<
0118                                 typename Seq::env_type
0119                             >::type
0120                         >
0121                       , proto::detail::uncvref<
0122                             typename Seq::env_type
0123                         >
0124                     >::type
0125                   , N
0126                 >::type
0127                 type;
0128         };
0129         
0130         template <typename Seq, typename N>
0131         struct at
0132         {
0133             typedef
0134                 typename fusion::result_of::at<
0135                     typename mpl::eval_if_c<
0136                         is_const<
0137                             typename remove_reference<
0138                                 typename Seq::env_type
0139                             >::type
0140                         >::value
0141                       , add_const<
0142                             typename proto::detail::uncvref<
0143                                 typename Seq::env_type
0144                             >::type
0145                         >
0146                       , proto::detail::uncvref<
0147                             typename Seq::env_type
0148                         >
0149                     >::type
0150                   , N
0151                 >::type
0152                 type;
0153 
0154             static type call(Seq & seq)
0155             {
0156                 return fusion::at<N>(seq.env);
0157             }
0158         };
0159     };
0160 
0161     template <typename Env, typename Dummy = void>
0162     struct is_scoped_environment : mpl::false_ {};
0163     
0164     template <typename Env>
0165     struct is_scoped_environment<Env&> : is_scoped_environment<Env> {};
0166     
0167     template <typename Env, typename OuterEnv, typename Locals, typename Map>
0168     struct is_scoped_environment<scoped_environment<Env, OuterEnv, Locals, Map> >
0169         : mpl::true_
0170     {};
0171 
0172     template <typename Env, typename OuterEnv, typename Locals, typename Map>
0173     struct is_scoped_environment<scoped_environment<Env, OuterEnv, Locals, Map> const>
0174         : mpl::true_
0175     {};
0176 }}
0177 
0178 #endif