/////////////////////////////////////////////////////////////////////////////// /// \file traits.hpp /// Contains definitions for child\<\>, child_c\<\>, left\<\>, /// right\<\>, tag_of\<\>, and the helper functions child(), child_c(), /// value(), left() and right(). // // 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) #ifndef BOOST_PROTO_ARG_TRAITS_HPP_EAN_04_01_2005 #define BOOST_PROTO_ARG_TRAITS_HPP_EAN_04_01_2005 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined(_MSC_VER) # pragma warning(push) # if BOOST_WORKAROUND( BOOST_MSVC, >= 1400 ) # pragma warning(disable: 4180) // warning C4180: qualifier applied to function type has no meaning; ignored # endif # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif namespace boost { namespace proto { namespace detail { template struct if_vararg {}; template struct if_vararg : T {}; template struct is_callable2_ : mpl::false_ {}; template struct is_callable2_ : mpl::true_ {}; template::value)> struct is_callable_ : is_callable2_ {}; } /// \brief Boolean metafunction which detects whether a type is /// a callable function object type or not. /// /// is_callable\<\> is used by the when\<\> transform /// to determine whether a function type R(A1,A2,...AN) is a /// callable transform or an object transform. (The former are evaluated /// using call\<\> and the later with make\<\>.) If /// is_callable\::value is \c true, the function type is /// a callable transform; otherwise, it is an object transform. /// /// Unless specialized for a type \c T, is_callable\::value /// is computed as follows: /// /// \li If \c T is a template type X\, where all \c Yx /// are types for \c x in [0,N], is_callable\::value /// is is_same\::value. /// \li If \c T has a nested type \c proto_is_callable_ that is a typedef /// for \c void, is_callable\::value is \c true. (Note: this is /// the case for any type that derives from \c proto::callable.) /// \li Otherwise, is_callable\::value is \c false. template struct is_callable : proto::detail::is_callable_ {}; /// INTERNAL ONLY /// template<> struct is_callable : mpl::true_ {}; /// INTERNAL ONLY /// template<> struct is_callable : mpl::false_ {}; /// INTERNAL ONLY /// template struct is_callable > : mpl::false_ {}; #if BOOST_WORKAROUND(__GNUC__, == 3) || (BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0) // work around GCC bug template struct is_callable > : mpl::false_ {}; // work around GCC bug template struct is_callable > : mpl::false_ {}; #endif namespace detail { template struct is_transform_ : mpl::false_ {}; template struct is_transform_ : mpl::true_ {}; } /// \brief Boolean metafunction which detects whether a type is /// a PrimitiveTransform type or not. /// /// is_transform\<\> is used by the call\<\> transform /// to determine whether the function types R(), R(A1), /// and R(A1, A2) should be passed the expression, state and data /// parameters (as needed). /// /// Unless specialized for a type \c T, is_transform\::value /// is computed as follows: /// /// \li If \c T has a nested type \c proto_is_transform_ that is a typedef /// for \c void, is_transform\::value is \c true. (Note: this is /// the case for any type that derives from an instantiation of \c proto::transform.) /// \li Otherwise, is_transform\::value is \c false. template struct is_transform : proto::detail::is_transform_ {}; namespace detail { template struct is_aggregate_ : is_pod {}; template struct is_aggregate_, void> : mpl::true_ {}; template struct is_aggregate_, void> : mpl::true_ {}; template struct is_aggregate_ : mpl::true_ {}; } /// \brief A Boolean metafunction that indicates whether a type requires /// aggregate initialization. /// /// is_aggregate\<\> is used by the make\<\> transform /// to determine how to construct an object of some type \c T, given some /// initialization arguments a0,a1,...aN. /// If is_aggregate\::value is \c true, then an object of /// type T will be initialized as T t = {a0,a1,...aN};. Otherwise, /// it will be initialized as T t(a0,a1,...aN). template struct is_aggregate : proto::detail::is_aggregate_ {}; /// \brief A Boolean metafunction that indicates whether a given /// type \c T is a Proto expression type. /// /// If \c T has a nested type \c proto_is_expr_ that is a typedef /// for \c void, is_expr\::value is \c true. (Note, this /// is the case for proto::expr\<\>, any type that is derived /// from proto::extends\<\> or that uses the /// BOOST_PROTO_BASIC_EXTENDS() macro.) Otherwise, /// is_expr\::value is \c false. template struct is_expr : mpl::false_ {}; /// \brief A Boolean metafunction that indicates whether a given /// type \c T is a Proto expression type. /// /// If \c T has a nested type \c proto_is_expr_ that is a typedef /// for \c void, is_expr\::value is \c true. (Note, this /// is the case for proto::expr\<\>, any type that is derived /// from proto::extends\<\> or that uses the /// BOOST_PROTO_BASIC_EXTENDS() macro.) Otherwise, /// is_expr\::value is \c false. template struct is_expr : mpl::true_ {}; template struct is_expr : is_expr {}; /// \brief A metafunction that returns the tag type of a /// Proto expression. template struct tag_of { typedef typename Expr::proto_tag type; }; template struct tag_of { typedef typename Expr::proto_tag type; }; /// \brief A metafunction that returns the arity of a /// Proto expression. template struct arity_of : Expr::proto_arity {}; template struct arity_of : Expr::proto_arity {}; namespace result_of { /// \brief A metafunction that computes the return type of the \c as_expr() /// function. template struct as_expr { typedef typename Domain::template as_expr::result_type type; }; /// \brief A metafunction that computes the return type of the \c as_child() /// function. template struct as_child { typedef typename Domain::template as_child::result_type type; }; /// \brief A metafunction that returns the type of the Nth child /// of a Proto expression, where N is an MPL Integral Constant. /// /// result_of::child\ is equivalent to /// result_of::child_c\. template*/> struct child : child_c {}; /// \brief A metafunction that returns the type of the value /// of a terminal Proto expression. /// template struct value { /// Verify that we are actually 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::proto_child0 value_type; /// The "value" type of the child, suitable for storage by value, /// computed as follows: /// \li T const(&)[N] becomes T[N] /// \li T[N] becomes T[N] /// \li T(&)[N] becomes T[N] /// \li R(&)(A0,...) becomes R(&)(A0,...) /// \li T const & becomes T /// \li T & becomes T /// \li T becomes T typedef typename detail::term_traits::value_type type; }; template struct value { /// Verify that we are actually 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::proto_child0 value_type; /// The "reference" type of the child, suitable for storage by /// reference, computed as follows: /// \li T const(&)[N] becomes T const(&)[N] /// \li T[N] becomes T(&)[N] /// \li T(&)[N] becomes T(&)[N] /// \li R(&)(A0,...) becomes R(&)(A0,...) /// \li T const & becomes T const & /// \li T & becomes T & /// \li T becomes T & typedef typename detail::term_traits::reference type; }; template struct value { /// Verify that we are actually 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::proto_child0 value_type; /// The "const reference" type of the child, suitable for storage by /// const reference, computed as follows: /// \li T const(&)[N] becomes T const(&)[N] /// \li T[N] becomes T const(&)[N] /// \li T(&)[N] becomes T(&)[N] /// \li R(&)(A0,...) becomes R(&)(A0,...) /// \li T const & becomes T const & /// \li T & becomes T & /// \li T becomes T const & typedef typename detail::term_traits::const_reference type; }; /// \brief A metafunction that returns the type of the left child /// of a binary Proto expression. /// /// result_of::left\ is equivalent to /// result_of::child_c\. template struct left : child_c {}; /// \brief A metafunction that returns the type of the right child /// of a binary Proto expression. /// /// result_of::right\ is equivalent to /// result_of::child_c\. template struct right : child_c {}; } // namespace result_of /// \brief A metafunction for generating terminal expression types, /// a grammar element for matching terminal expressions, and a /// PrimitiveTransform that returns the current expression unchanged. template struct terminal : proto::transform, int> { typedef proto::expr, 0> type; typedef proto::basic_expr, 0> proto_grammar; template struct impl : transform_impl { typedef Expr result_type; /// \param e The current expression /// \pre matches\ \>::value is \c true. /// \return \c e /// \throw nothrow BOOST_FORCEINLINE BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param) operator ()( typename impl::expr_param e , typename impl::state_param , typename impl::data_param ) const { return e; } }; /// INTERNAL ONLY typedef proto::tag::terminal proto_tag; /// INTERNAL ONLY typedef T proto_child0; }; /// \brief A metafunction for generating ternary conditional expression types, /// a grammar element for matching ternary conditional expressions, and a /// PrimitiveTransform that dispatches to the pass_through\<\> /// transform. template struct if_else_ : proto::transform, int> { typedef proto::expr, 3> type; typedef proto::basic_expr, 3> proto_grammar; template struct impl : detail::pass_through_impl {}; /// INTERNAL ONLY typedef proto::tag::if_else_ proto_tag; /// INTERNAL ONLY typedef T proto_child0; /// INTERNAL ONLY typedef U proto_child1; /// INTERNAL ONLY typedef V proto_child2; }; /// \brief A metafunction for generating nullary expression types with a /// specified tag type, /// a grammar element for matching nullary expressions, and a /// PrimitiveTransform that returns the current expression unchanged. /// /// Use nullary_expr\<_, _\> as a grammar element to match any /// nullary expression. template struct nullary_expr : proto::transform, int> { typedef proto::expr, 0> type; typedef proto::basic_expr, 0> proto_grammar; template struct impl : transform_impl { typedef Expr result_type; /// \param e The current expression /// \pre matches\ \>::value is \c true. /// \return \c e /// \throw nothrow BOOST_FORCEINLINE BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param) operator ()( typename impl::expr_param e , typename impl::state_param , typename impl::data_param ) const { return e; } }; /// INTERNAL ONLY typedef Tag proto_tag; /// INTERNAL ONLY typedef T proto_child0; }; /// \brief A metafunction for generating unary expression types with a /// specified tag type, /// a grammar element for matching unary expressions, and a /// PrimitiveTransform that dispatches to the pass_through\<\> /// transform. /// /// Use unary_expr\<_, _\> as a grammar element to match any /// unary expression. template struct unary_expr : proto::transform, int> { typedef proto::expr, 1> type; typedef proto::basic_expr, 1> proto_grammar; template struct impl : detail::pass_through_impl {}; /// INTERNAL ONLY typedef Tag proto_tag; /// INTERNAL ONLY typedef T proto_child0; }; /// \brief A metafunction for generating binary expression types with a /// specified tag type, /// a grammar element for matching binary expressions, and a /// PrimitiveTransform that dispatches to the pass_through\<\> /// transform. /// /// Use binary_expr\<_, _, _\> as a grammar element to match any /// binary expression. template struct binary_expr : proto::transform, int> { typedef proto::expr, 2> type; typedef proto::basic_expr, 2> proto_grammar; template struct impl : detail::pass_through_impl {}; /// INTERNAL ONLY typedef Tag proto_tag; /// INTERNAL ONLY typedef T proto_child0; /// INTERNAL ONLY typedef U proto_child1; }; #define BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(Op) \ template \ struct Op \ : proto::transform, int> \ { \ typedef proto::expr, 1> type; \ typedef proto::basic_expr, 1> proto_grammar; \ \ template \ struct impl \ : detail::pass_through_impl \ {}; \ \ typedef proto::tag::Op proto_tag; \ typedef T proto_child0; \ }; \ /**/ #define BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(Op) \ template \ struct Op \ : proto::transform, int> \ { \ typedef proto::expr, 2> type; \ typedef proto::basic_expr, 2> proto_grammar; \ \ template \ struct impl \ : detail::pass_through_impl \ {}; \ \ typedef proto::tag::Op proto_tag; \ typedef T proto_child0; \ typedef U proto_child1; \ }; \ /**/ BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(unary_plus) BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(negate) BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(dereference) BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(complement) BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(address_of) BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(logical_not) BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(pre_inc) BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(pre_dec) BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(post_inc) BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(post_dec) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_left) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_right) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(multiplies) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(divides) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(modulus) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(plus) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(minus) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(less) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(greater) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(less_equal) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(greater_equal) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(equal_to) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(not_equal_to) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(logical_or) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(logical_and) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_or) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_and) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_xor) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(comma) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(mem_ptr) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_left_assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_right_assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(multiplies_assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(divides_assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(modulus_assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(plus_assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(minus_assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_or_assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_and_assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_xor_assign) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(subscript) BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(member) #undef BOOST_PROTO_DEFINE_UNARY_METAFUNCTION #undef BOOST_PROTO_DEFINE_BINARY_METAFUNCTION #include namespace functional { /// \brief A callable PolymorphicFunctionObject that is /// equivalent to the \c as_expr() function. template struct as_expr { BOOST_PROTO_CALLABLE() template struct result; template struct result { typedef typename Domain::template as_expr::result_type type; }; template struct result { typedef typename Domain::template as_expr::result_type type; }; /// \brief Wrap an object in a Proto terminal if it isn't a /// Proto expression already. /// \param t The object to wrap. /// \return proto::as_expr\(t) template BOOST_FORCEINLINE typename add_const::type>::type operator ()(T &t) const { return typename Domain::template as_expr()(t); } /// \overload /// template BOOST_FORCEINLINE typename add_const::type>::type operator ()(T const &t) const { return typename Domain::template as_expr()(t); } #if BOOST_WORKAROUND(BOOST_MSVC, == 1310) template BOOST_FORCEINLINE typename add_const::type>::type operator ()(T (&t)[N_]) const { return typename Domain::template as_expr()(t); } template BOOST_FORCEINLINE typename add_const::type>::type operator ()(T const (&t)[N_]) const { return typename Domain::template as_expr()(t); } #endif }; /// \brief A callable PolymorphicFunctionObject that is /// equivalent to the \c as_child() function. template struct as_child { BOOST_PROTO_CALLABLE() template struct result; template struct result { typedef typename Domain::template as_child::result_type type; }; template struct result { typedef typename Domain::template as_child::result_type type; }; /// \brief Wrap an object in a Proto terminal if it isn't a /// Proto expression already. /// \param t The object to wrap. /// \return proto::as_child\(t) template BOOST_FORCEINLINE typename add_const::type>::type operator ()(T &t) const { return typename Domain::template as_child()(t); } /// \overload /// template BOOST_FORCEINLINE typename add_const::type>::type operator ()(T const &t) const { return typename Domain::template as_child()(t); } }; /// \brief A callable PolymorphicFunctionObject that is /// equivalent to the \c child_c() function. template struct child_c { BOOST_PROTO_CALLABLE() template struct result; template struct result { typedef typename result_of::child_c::type type; }; /// \brief Return the Nth child of the given expression. /// \param expr The expression node. /// \pre is_expr\::value is \c true /// \pre N \< Expr::proto_arity::value /// \return proto::child_c\(expr) /// \throw nothrow template BOOST_FORCEINLINE typename result_of::child_c::type operator ()(Expr &e) const { return result_of::child_c::call(e); } /// \overload /// template BOOST_FORCEINLINE typename result_of::child_c::type operator ()(Expr const &e) const { return result_of::child_c::call(e); } }; /// \brief A callable PolymorphicFunctionObject that is /// equivalent to the \c child() function. /// /// A callable PolymorphicFunctionObject that is /// equivalent to the \c child() function. \c N is required /// to be an MPL Integral Constant. template*/> struct child { BOOST_PROTO_CALLABLE() template struct result; template struct result { typedef typename result_of::child::type type; }; /// \brief Return the Nth child of the given expression. /// \param expr The expression node. /// \pre is_expr\::value is \c true /// \pre N::value \< Expr::proto_arity::value /// \return proto::child\(expr) /// \throw nothrow template BOOST_FORCEINLINE typename result_of::child::type operator ()(Expr &e) const { return result_of::child::call(e); } /// \overload /// template BOOST_FORCEINLINE typename result_of::child::type operator ()(Expr const &e) const { return result_of::child::call(e); } }; /// \brief A callable PolymorphicFunctionObject that is /// equivalent to the \c value() function. struct value { BOOST_PROTO_CALLABLE() template struct result; template struct result { typedef typename result_of::value::type type; }; /// \brief Return the value of the given terminal expression. /// \param expr The terminal expression node. /// \pre is_expr\::value is \c true /// \pre 0 == Expr::proto_arity::value /// \return proto::value(expr) /// \throw nothrow template BOOST_FORCEINLINE typename result_of::value::type operator ()(Expr &e) const { return e.proto_base().child0; } /// \overload /// template BOOST_FORCEINLINE typename result_of::value::type operator ()(Expr const &e) const { return e.proto_base().child0; } }; /// \brief A callable PolymorphicFunctionObject that is /// equivalent to the \c left() function. struct left { BOOST_PROTO_CALLABLE() template struct result; template struct result { typedef typename result_of::left::type type; }; /// \brief Return the left child of the given binary expression. /// \param expr The expression node. /// \pre is_expr\::value is \c true /// \pre 2 == Expr::proto_arity::value /// \return proto::left(expr) /// \throw nothrow template BOOST_FORCEINLINE typename result_of::left::type operator ()(Expr &e) const { return e.proto_base().child0; } /// \overload /// template BOOST_FORCEINLINE typename result_of::left::type operator ()(Expr const &e) const { return e.proto_base().child0; } }; /// \brief A callable PolymorphicFunctionObject that is /// equivalent to the \c right() function. struct right { BOOST_PROTO_CALLABLE() template struct result; template struct result { typedef typename result_of::right::type type; }; /// \brief Return the right child of the given binary expression. /// \param expr The expression node. /// \pre is_expr\::value is \c true /// \pre 2 == Expr::proto_arity::value /// \return proto::right(expr) /// \throw nothrow template BOOST_FORCEINLINE typename result_of::right::type operator ()(Expr &e) const { return e.proto_base().child1; } template BOOST_FORCEINLINE typename result_of::right::type operator ()(Expr const &e) const { return e.proto_base().child1; } }; } /// \brief A function that wraps non-Proto expression types in Proto /// terminals and leaves Proto expression types alone. /// /// The as_expr() function turns objects into Proto terminals if /// they are not Proto expression types already. Non-Proto types are /// held by value, if possible. Types which are already Proto types are /// left alone and returned by reference. /// /// This function can be called either with an explicitly specified /// \c Domain parameter (i.e., as_expr\(t)), or /// without (i.e., as_expr(t)). If no domain is /// specified, \c default_domain is assumed. /// /// If is_expr\::value is \c true, then the argument is /// returned unmodified, by reference. Otherwise, the argument is wrapped /// in a Proto terminal expression node according to the following rules. /// If \c T is a function type, let \c A be T &. Otherwise, let /// \c A be the type \c T stripped of cv-qualifiers. Then, \c as_expr() /// returns Domain()(terminal\::type::make(t)). /// /// \param t The object to wrap. template BOOST_FORCEINLINE typename add_const::type>::type as_expr(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T) BOOST_PROTO_DISABLE_IF_IS_FUNCTION(T)) { return default_domain::as_expr()(t); } /// \overload /// template BOOST_FORCEINLINE typename add_const::type>::type as_expr(T const &t) { return default_domain::as_expr()(t); } /// \overload /// template BOOST_FORCEINLINE typename add_const::type>::type as_expr(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T) BOOST_PROTO_DISABLE_IF_IS_FUNCTION(T)) { return typename Domain::template as_expr()(t); } /// \overload /// template BOOST_FORCEINLINE typename add_const::type>::type as_expr(T const &t) { return typename Domain::template as_expr()(t); } /// \brief A function that wraps non-Proto expression types in Proto /// terminals (by reference) and returns Proto expression types by /// reference /// /// The as_child() function turns objects into Proto terminals if /// they are not Proto expression types already. Non-Proto types are /// held by reference. Types which are already Proto types are simply /// returned as-is. /// /// This function can be called either with an explicitly specified /// \c Domain parameter (i.e., as_child\(t)), or /// without (i.e., as_child(t)). If no domain is /// specified, \c default_domain is assumed. /// /// If is_expr\::value is \c true, then the argument is /// returned as-is. Otherwise, \c as_child() returns /// Domain()(terminal\::type::make(t)). /// /// \param t The object to wrap. template BOOST_FORCEINLINE typename add_const::type>::type as_child(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T) BOOST_PROTO_DISABLE_IF_IS_FUNCTION(T)) { return default_domain::as_child()(t); } /// \overload /// template BOOST_FORCEINLINE typename add_const::type>::type as_child(T const &t) { return default_domain::as_child()(t); } /// \overload /// template BOOST_FORCEINLINE typename add_const::type>::type as_child(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T) BOOST_PROTO_DISABLE_IF_IS_FUNCTION(T)) { return typename Domain::template as_child()(t); } /// \overload /// template BOOST_FORCEINLINE typename add_const::type>::type as_child(T const &t) { return typename Domain::template as_child()(t); } /// \brief Return the Nth child of the specified Proto expression. /// /// Return the Nth child of the specified Proto expression. If /// \c N is not specified, as in \c child(expr), then \c N is assumed /// to be mpl::long_\<0\>. The child is returned by /// reference. /// /// \param expr The Proto expression. /// \pre is_expr\::value is \c true. /// \pre \c N is an MPL Integral Constant. /// \pre N::value \< Expr::proto_arity::value /// \throw nothrow /// \return A reference to the Nth child template BOOST_FORCEINLINE typename result_of::child::type child(Expr &e BOOST_PROTO_DISABLE_IF_IS_CONST(Expr)) { return result_of::child::call(e); } /// \overload /// template BOOST_FORCEINLINE typename result_of::child::type child(Expr const &e) { return result_of::child::call(e); } /// \overload /// template BOOST_FORCEINLINE typename detail::expr_traits::reference child(Expr2 &expr2 BOOST_PROTO_DISABLE_IF_IS_CONST(Expr2)) { return expr2.proto_base().child0; } /// \overload /// template BOOST_FORCEINLINE typename detail::expr_traits::const_reference child(Expr2 const &expr2) { return expr2.proto_base().child0; } /// \brief Return the Nth child of the specified Proto expression. /// /// Return the Nth child of the specified Proto expression. The child /// is returned by reference. /// /// \param expr The Proto expression. /// \pre is_expr\::value is \c true. /// \pre N \< Expr::proto_arity::value /// \throw nothrow /// \return A reference to the Nth child template BOOST_FORCEINLINE typename result_of::child_c::type child_c(Expr &e BOOST_PROTO_DISABLE_IF_IS_CONST(Expr)) { return result_of::child_c::call(e); } /// \overload /// template BOOST_FORCEINLINE typename result_of::child_c::type child_c(Expr const &e) { return result_of::child_c::call(e); } /// \brief Return the value stored within the specified Proto /// terminal expression. /// /// Return the value stored within the specified Proto /// terminal expression. The value is returned by /// reference. /// /// \param expr The Proto terminal expression. /// \pre N::value == 0 /// \throw nothrow /// \return A reference to the terminal's value template BOOST_FORCEINLINE typename result_of::value::type value(Expr &e BOOST_PROTO_DISABLE_IF_IS_CONST(Expr)) { return e.proto_base().child0; } /// \overload /// template BOOST_FORCEINLINE typename result_of::value::type value(Expr const &e) { return e.proto_base().child0; } /// \brief Return the left child of the specified binary Proto /// expression. /// /// Return the left child of the specified binary Proto expression. The /// child is returned by reference. /// /// \param expr The Proto expression. /// \pre is_expr\::value is \c true. /// \pre 2 == Expr::proto_arity::value /// \throw nothrow /// \return A reference to the left child template BOOST_FORCEINLINE typename result_of::left::type left(Expr &e BOOST_PROTO_DISABLE_IF_IS_CONST(Expr)) { return e.proto_base().child0; } /// \overload /// template BOOST_FORCEINLINE typename result_of::left::type left(Expr const &e) { return e.proto_base().child0; } /// \brief Return the right child of the specified binary Proto /// expression. /// /// Return the right child of the specified binary Proto expression. The /// child is returned by reference. /// /// \param expr The Proto expression. /// \pre is_expr\::value is \c true. /// \pre 2 == Expr::proto_arity::value /// \throw nothrow /// \return A reference to the right child template BOOST_FORCEINLINE typename result_of::right::type right(Expr &e BOOST_PROTO_DISABLE_IF_IS_CONST(Expr)) { return e.proto_base().child1; } /// \overload /// template BOOST_FORCEINLINE typename result_of::right::type right(Expr const &e) { return e.proto_base().child1; } /// INTERNAL ONLY /// template struct is_callable > : mpl::true_ {}; /// INTERNAL ONLY /// template struct is_callable > : mpl::true_ {}; /// INTERNAL ONLY /// template struct is_callable > : mpl::true_ {}; /// INTERNAL ONLY /// template struct is_callable > : mpl::true_ {}; }} #if defined(_MSC_VER) # pragma warning(pop) #endif #endif