Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Struct template as_child

boost::proto::domain::as_child — A callable unary MonomorphicFunctionObject that specifies how objects are turned into Proto expressions in this domain, for use in scenarios where the resulting expression is intended to be made a child of another expression.

Synopsis

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



// A callable unary MonomorphicFunctionObject that specifies how objects are
// turned into Proto expressions in this domain, for use in scenarios where
// the resulting expression is intended to be made a child of another
// expression.
template<typename T> 
struct as_child :  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 as a child of another expression. In that scenario, it is usually preferable to store child expressions by reference; or, in the case of objects that are not yet Proto expressions, to wrap them by reference in a new Proto terminal expression. (Contrast this description with the description for proto::domain::as_expr.)

The as_child function object turns objects into Proto expressions, if they are not already, by making them Proto terminals held by reference. Objects that are already Proto expressions are simply returned by reference. 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 Generator()(E<tag::terminal, term< T & > >::make(t)).
  • Otherwise, the result is the lvalue t.

as_child public member functions

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

    Parameters:

    t

    The object to wrap.


PrevUpHomeNext