...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::proto::as_expr — A function that wraps non-Proto expression types in Proto terminals and leaves Proto expression types alone.
// In header: <boost/proto/traits.hpp> template<typename T> typename proto::result_of::as_expr< T >::type as_expr(T & t); template<typename T> typename proto::result_of::as_expr< T const >::type as_expr(T const & t); template<typename Domain, typename T> typename proto::result_of::as_expr< T, Domain >::type as_expr(T & t); template<typename Domain, typename T> typename proto::result_of::as_expr< T const, Domain >::type as_expr(T const & t);
The proto::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.
This function can be called either with an explicitly specified
Domain
parameter
(i.e., proto::as_expr<Domain>(t)
), or without
(i.e., proto::as_expr(t)
). If no domain is specified,
is assumed.
proto::default_domain
If
is
proto::is_expr
<T>::valuetrue
, then the argument is returned unmodified. Otherwise,
the argument is wrapped in a Proto terminal expression node according to the following rules.
If T
is a function type, let
A
be T &
. Otherwise, let
A
be the type T
stripped of
cv-qualifiers. Then, proto::as_expr()
returns
Domain()(
.
proto::terminal
<A>::type::make(t))