| Home | Libraries | People | FAQ | More

## Struct template as_expr

boost::proto::domain::as_expr — A callable unary MonomorphicFunctionObject that specifies how objects are turned into Proto expressions in this domain. The resulting expression object is suitable for storage in a local variable.

## Synopsis

    // In header: <boost/proto/domain.hpp>

    // A callable unary MonomorphicFunctionObject that specifies how objects are
    // turned into Proto expressions in this domain. The resulting expression
    // object is suitable for storage in a local variable.
    template<typename T>
    struct as_expr :  proto::callable {
      // types
      typedef see-below result_type;

      // public member functions
      result_type operator()(T &) const;
    };

## Description

A unary MonomorphicFunctionObject that specifies how objects are turned into Proto expressions in this domain. The resulting expression object is suitable for storage in a local variable. In that scenario, it is usually preferable to return expressions by value; and, in the case of objects that are not yet Proto expressions, to wrap them by value (if possible) in a new Proto terminal expression. (Contrast this description with the description for `proto::domain::as_child`.)

The `as_expr` function object turns objects into Proto expressions, if they are not already, by making them Proto terminals held by value if possible. Objects that are already Proto expressions are simply returned by value. If `wants_basic_expr<Generator>::value` is true, then let E be `proto::basic_expr`; otherwise, let E be `proto::expr`. Given an lvalue `t` of type `T`:

- If `T` is not a Proto expression type, the resulting terminal is calculated as follows:
  - If `T` is a function type, an abstract type, or a type derived from `std::ios_base`, let `A` be `T &`.
  - Otherwise, let `A` be the type `T` stripped of cv-qualifiers.
  Then, the result of `as_expr<T>()(t)` is `Generator()(`E`<tag::terminal, term< `A` > >::make(t))`.
- Otherwise, the result is `t` converted to an (un-const) rvalue.

### `as_expr` public member functions

1.     result_type operator()(T & t) const;

   Parameters:

   `t` | The object to wrap.