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.
// 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;
};
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
:
T
is not a Proto expression type, the resulting
terminal is calculated as follows:
T
is a function type, an abstract type, or
a type derived from std::ios_base
, let
A
be T &
.
A
be the type
T
stripped of cv-qualifiers.
as_expr<T>()(t)
is
Generator()(E
<tag::terminal,
term< A
> >::make(t))
.
t
converted to an
(un-const) rvalue.