Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:27

0001 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
0002 
0003     #include <boost/proto/detail/preprocessed/traits.hpp>
0004 
0005 #elif !defined(BOOST_PP_IS_ITERATING)
0006 
0007     #define BOOST_PROTO_CHILD(Z, N, DATA)                                                           \
0008         /** INTERNAL ONLY */                                                                        \
0009         typedef BOOST_PP_CAT(DATA, N) BOOST_PP_CAT(proto_child, N);                                 \
0010         /**/
0011 
0012     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0013         #pragma wave option(preserve: 2, line: 0, output: "preprocessed/traits.hpp")
0014     #endif
0015 
0016     ///////////////////////////////////////////////////////////////////////////////
0017     /// \file traits.hpp
0018     /// Definitions of proto::function, proto::nary_expr and proto::result_of::child_c
0019     //
0020     //  Copyright 2008 Eric Niebler. Distributed under the Boost
0021     //  Software License, Version 1.0. (See accompanying file
0022     //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0023 
0024     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0025         #pragma wave option(preserve: 1)
0026     #endif
0027 
0028     #define BOOST_PP_ITERATION_PARAMS_1                                                             \
0029         (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/traits.hpp>))
0030     #include BOOST_PP_ITERATE()
0031 
0032     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
0033         #pragma wave option(output: null)
0034     #endif
0035 
0036     #undef BOOST_PROTO_CHILD
0037 
0038 #else // BOOST_PP_IS_ITERATING
0039 
0040     #define N BOOST_PP_ITERATION()
0041 
0042     #if N > 0
0043         /// \brief A metafunction for generating function-call expression types,
0044         /// a grammar element for matching function-call expressions, and a
0045         /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
0046         /// transform.
0047         template<BOOST_PP_ENUM_PARAMS(N, typename A)>
0048         struct function
0049         #if N != BOOST_PROTO_MAX_ARITY
0050         <
0051             BOOST_PP_ENUM_PARAMS(N, A)
0052             BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
0053         >
0054         #endif
0055           : proto::transform<
0056                 function<
0057                     BOOST_PP_ENUM_PARAMS(N, A)
0058                     BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
0059                 >
0060               , int
0061             >
0062         {
0063             typedef proto::expr<proto::tag::function, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> type;
0064             typedef proto::basic_expr<proto::tag::function, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> proto_grammar;
0065 
0066             template<typename Expr, typename State, typename Data>
0067             struct impl
0068               : detail::pass_through_impl<function, deduce_domain, Expr, State, Data>
0069             {};
0070 
0071             /// INTERNAL ONLY
0072             typedef proto::tag::function proto_tag;
0073             BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, A)
0074             BOOST_PP_REPEAT_FROM_TO(
0075                 N
0076               , BOOST_PROTO_MAX_ARITY
0077               , BOOST_PROTO_CHILD
0078               , detail::if_vararg<BOOST_PP_CAT(A, BOOST_PP_DEC(N))> BOOST_PP_INTERCEPT
0079             )
0080         };
0081 
0082         /// \brief A metafunction for generating n-ary expression types with a
0083         /// specified tag type,
0084         /// a grammar element for matching n-ary expressions, and a
0085         /// PrimitiveTransform that dispatches to the <tt>pass_through\<\></tt>
0086         /// transform.
0087         ///
0088         /// Use <tt>nary_expr\<_, vararg\<_\> \></tt> as a grammar element to match any
0089         /// n-ary expression; that is, any non-terminal.
0090         template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
0091         struct nary_expr
0092         #if N != BOOST_PROTO_MAX_ARITY
0093         <
0094             Tag
0095             BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
0096             BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
0097         >
0098         #endif
0099           : proto::transform<
0100                 nary_expr<
0101                     Tag
0102                     BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
0103                     BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT)
0104                 >
0105               , int
0106             >
0107         {
0108             typedef proto::expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> type;
0109             typedef proto::basic_expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, A)>, N> proto_grammar;
0110 
0111             template<typename Expr, typename State, typename Data>
0112             struct impl
0113               : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data>
0114             {};
0115 
0116             /// INTERNAL ONLY
0117             typedef Tag proto_tag;
0118             BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, A)
0119             BOOST_PP_REPEAT_FROM_TO(
0120                 N
0121               , BOOST_PROTO_MAX_ARITY
0122               , BOOST_PROTO_CHILD
0123               , detail::if_vararg<BOOST_PP_CAT(A, BOOST_PP_DEC(N))> BOOST_PP_INTERCEPT
0124             )
0125         };
0126 
0127         namespace detail
0128         {
0129             template<
0130                 template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class T
0131               , BOOST_PP_ENUM_PARAMS(N, typename A)
0132             >
0133             struct is_callable_<T<BOOST_PP_ENUM_PARAMS(N, A)> BOOST_PROTO_TEMPLATE_ARITY_PARAM(N)>
0134               : is_same<BOOST_PP_CAT(A, BOOST_PP_DEC(N)), callable>
0135             {};
0136         }
0137 
0138     #endif
0139 
0140         namespace result_of
0141         {
0142             /// \brief A metafunction that returns the type of the Nth child
0143             /// of a Proto expression.
0144             ///
0145             /// A metafunction that returns the type of the Nth child
0146             /// of a Proto expression. \c N must be less than
0147             /// \c Expr::proto_arity::value.
0148             template<typename Expr>
0149             struct child_c<Expr, N>
0150             {
0151                 /// Verify that we are not operating on a terminal
0152                 BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c);
0153 
0154                 /// The raw type of the Nth child as it is stored within
0155                 /// \c Expr. This may be a value or a reference
0156                 typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type;
0157 
0158                 /// The "value" type of the child, suitable for return by value,
0159                 /// computed as follows:
0160                 /// \li <tt>T const &</tt> becomes <tt>T</tt>
0161                 /// \li <tt>T &</tt> becomes <tt>T</tt>
0162                 /// \li <tt>T</tt> becomes <tt>T</tt>
0163                 typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::value_type type;
0164             };
0165 
0166             template<typename Expr>
0167             struct child_c<Expr &, N>
0168             {
0169                 /// Verify that we are not operating on a terminal
0170                 BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c);
0171 
0172                 /// The raw type of the Nth child as it is stored within
0173                 /// \c Expr. This may be a value or a reference
0174                 typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type;
0175 
0176                 /// The "reference" type of the child, suitable for return by
0177                 /// reference, computed as follows:
0178                 /// \li <tt>T const &</tt> becomes <tt>T const &</tt>
0179                 /// \li <tt>T &</tt> becomes <tt>T &</tt>
0180                 /// \li <tt>T</tt> becomes <tt>T &</tt>
0181                 typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::reference type;
0182 
0183                 /// INTERNAL ONLY
0184                 ///
0185                 BOOST_FORCEINLINE
0186                 static type call(Expr &e)
0187                 {
0188                     return e.proto_base().BOOST_PP_CAT(child, N);
0189                 }
0190             };
0191 
0192             template<typename Expr>
0193             struct child_c<Expr const &, N>
0194             {
0195                 /// Verify that we are not operating on a terminal
0196                 BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c);
0197 
0198                 /// The raw type of the Nth child as it is stored within
0199                 /// \c Expr. This may be a value or a reference
0200                 typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type;
0201 
0202                 /// The "const reference" type of the child, suitable for return by
0203                 /// const reference, computed as follows:
0204                 /// \li <tt>T const &</tt> becomes <tt>T const &</tt>
0205                 /// \li <tt>T &</tt> becomes <tt>T &</tt>
0206                 /// \li <tt>T</tt> becomes <tt>T const &</tt>
0207                 typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::const_reference type;
0208 
0209                 /// INTERNAL ONLY
0210                 ///
0211                 BOOST_FORCEINLINE
0212                 static type call(Expr const &e)
0213                 {
0214                     return e.proto_base().BOOST_PP_CAT(child, N);
0215                 }
0216             };
0217         }
0218 
0219     #undef N
0220 
0221 #endif