STRUCT TEMPLAT(3)

NAME
boost::proto::context::default_eval - A BinaryFunction that accepts a Proto expression and a context, evaluates each child expression with the context, and combines the result using the standard C++ meaning for the operator represented by the current expression node.

SYNOPSIS

// In header: <boost/proto/context/default.hpp>
template<typename Expr, typename Context>
struct default_eval {
  // types
  typedef typename Expr::tag_type Tag;          // For exposition only
  typedef see-below result_type;
  // public member functions
  result_type operator()(Expr &, Context &) const;
  static Expr & s_expr;  // For exposition only
  static Context & s_context;  // For exposition only
};

DESCRIPTION

Let OP be the C++ operator corresponding to Expr::proto_tag. (For example, if Tag is proto::tag::plus, let OP be +.)

The behavior of this class is specified in terms of the C++0x decltype keyword. In systems where this keyword is not available, Proto uses the Boost.Typeof library to approximate the behavior.

  default_eval public types

    1. typedef see-below result_type;

        &#8226; If Tag corresponds to a unary prefix operator, then the result type is

            decltype(
              OP proto::eval(proto::child(s_expr), s_context)
            )

        &#8226; If Tag corresponds to a unary postfix operator, then the result type is

            decltype(
              proto::eval(proto::child(s_expr), s_context) OP
            )

        &#8226; If Tag corresponds to a binary infix operator, then the result type is

            decltype(
              proto::eval(proto::left(s_expr), s_context) OP
              proto::eval(proto::right(s_expr), s_context)
            )

        &#8226; If Tag is proto::tag::subscript, then the result type is

            decltype(
              proto::eval(proto::left(s_expr), s_context) [
              proto::eval(proto::right(s_expr), s_context) ]
            )

        &#8226; If Tag is proto::tag::if_else_, then the result type is

            decltype(
              proto::eval(proto::child_c<0>(s_expr), s_context) ?
              proto::eval(proto::child_c<1>(s_expr), s_context) :
              proto::eval(proto::child_c<2>(s_expr), s_context)
            )

        &#8226; If Tag is proto::tag::function, then the result type is

            decltype(
              proto::eval(proto::child_c<0>(s_expr), s_context) (
              proto::eval(proto::child_c<1>(s_expr), s_context),
              ...
              proto::eval(proto::child_c<N>(s_expr), s_context) )
            )

  default_eval public member functions

    1.

    result_type operator()(Expr & expr, Context & context) const;

        &#8226; If Tag corresponds to a unary prefix operator, then return

            OP proto::eval(proto::child(expr), context)

        &#8226; If Tag corresponds to a unary postfix operator, then return

            proto::eval(proto::child(expr), context) OP

        &#8226; If Tag corresponds to a binary infix operator, then return

            proto::eval(proto::left(expr), context) OP
            proto::eval(proto::right(expr), context)

        &#8226; If Tag is proto::tag::subscript, then return

            proto::eval(proto::left(expr), context) [
            proto::eval(proto::right(expr), context) ]

        &#8226; If Tag is proto::tag::if_else_, then return

            proto::eval(proto::child_c<0>(expr), context) ?
            proto::eval(proto::child_c<1>(expr), context) :
            proto::eval(proto::child_c<2>(expr), context)

        &#8226; If Tag is proto::tag::function, then return

            proto::eval(proto::child_c<0>(expr), context) (
            proto::eval(proto::child_c<1>(expr), context),
            ...
            proto::eval(proto::child_c<N>(expr), context) )

        Parameters:

            context
                The evaluation context

            expr
                The current expression