#if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) #include #elif !defined(BOOST_PP_IS_ITERATING) #define BOOST_PROTO_CHILD(Z, N, DATA) \ /** INTERNAL ONLY */ \ typedef BOOST_PP_CAT(DATA, N) BOOST_PP_CAT(proto_child, N); \ /**/ #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) #pragma wave option(preserve: 2, line: 0, output: "preprocessed/traits.hpp") #endif /////////////////////////////////////////////////////////////////////////////// /// \file traits.hpp /// Definitions of proto::function, proto::nary_expr and proto::result_of::child_c // // Copyright 2008 Eric Niebler. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) #pragma wave option(preserve: 1) #endif #define BOOST_PP_ITERATION_PARAMS_1 \ (3, (0, BOOST_PROTO_MAX_ARITY, )) #include BOOST_PP_ITERATE() #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) #pragma wave option(output: null) #endif #undef BOOST_PROTO_CHILD #else // BOOST_PP_IS_ITERATING #define N BOOST_PP_ITERATION() #if N > 0 /// \brief A metafunction for generating function-call expression types, /// a grammar element for matching function-call expressions, and a /// PrimitiveTransform that dispatches to the pass_through\<\> /// transform. template struct function #if N != BOOST_PROTO_MAX_ARITY < BOOST_PP_ENUM_PARAMS(N, A) BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT) > #endif : proto::transform< function< BOOST_PP_ENUM_PARAMS(N, A) BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT) > , int > { typedef proto::expr, N> type; typedef proto::basic_expr, N> proto_grammar; template struct impl : detail::pass_through_impl {}; /// INTERNAL ONLY typedef proto::tag::function proto_tag; BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, A) BOOST_PP_REPEAT_FROM_TO( N , BOOST_PROTO_MAX_ARITY , BOOST_PROTO_CHILD , detail::if_vararg BOOST_PP_INTERCEPT ) }; /// \brief A metafunction for generating n-ary expression types with a /// specified tag type, /// a grammar element for matching n-ary expressions, and a /// PrimitiveTransform that dispatches to the pass_through\<\> /// transform. /// /// Use nary_expr\<_, vararg\<_\> \> as a grammar element to match any /// n-ary expression; that is, any non-terminal. template struct nary_expr #if N != BOOST_PROTO_MAX_ARITY < Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, A) BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT) > #endif : proto::transform< nary_expr< Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, A) BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N), void BOOST_PP_INTERCEPT) > , int > { typedef proto::expr, N> type; typedef proto::basic_expr, N> proto_grammar; template struct impl : detail::pass_through_impl {}; /// INTERNAL ONLY typedef Tag proto_tag; BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD, A) BOOST_PP_REPEAT_FROM_TO( N , BOOST_PROTO_MAX_ARITY , BOOST_PROTO_CHILD , detail::if_vararg BOOST_PP_INTERCEPT ) }; namespace detail { template< template class T , BOOST_PP_ENUM_PARAMS(N, typename A) > struct is_callable_ BOOST_PROTO_TEMPLATE_ARITY_PARAM(N)> : is_same {}; } #endif namespace result_of { /// \brief A metafunction that returns the type of the Nth child /// of a Proto expression. /// /// A metafunction that returns the type of the Nth child /// of a Proto expression. \c N must be less than /// \c Expr::proto_arity::value. template struct child_c { /// Verify that we are not operating on a terminal BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c); /// The raw type of the Nth child as it is stored within /// \c Expr. This may be a value or a reference typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type; /// The "value" type of the child, suitable for return by value, /// computed as follows: /// \li T const & becomes T /// \li T & becomes T /// \li T becomes T typedef typename detail::expr_traits::value_type type; }; template struct child_c { /// Verify that we are not operating on a terminal BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c); /// The raw type of the Nth child as it is stored within /// \c Expr. This may be a value or a reference typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type; /// The "reference" type of the child, suitable for return by /// reference, computed as follows: /// \li T const & becomes T const & /// \li T & becomes T & /// \li T becomes T & typedef typename detail::expr_traits::reference type; /// INTERNAL ONLY /// BOOST_FORCEINLINE static type call(Expr &e) { return e.proto_base().BOOST_PP_CAT(child, N); } }; template struct child_c { /// Verify that we are not operating on a terminal BOOST_STATIC_ASSERT(0 != Expr::proto_arity_c); /// The raw type of the Nth child as it is stored within /// \c Expr. This may be a value or a reference typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type; /// The "const reference" type of the child, suitable for return by /// const reference, computed as follows: /// \li T const & becomes T const & /// \li T & becomes T & /// \li T becomes T const & typedef typename detail::expr_traits::const_reference type; /// INTERNAL ONLY /// BOOST_FORCEINLINE static type call(Expr const &e) { return e.proto_base().BOOST_PP_CAT(child, N); } }; } #undef N #endif