| Home | Libraries | People | FAQ | More

## Function as_expr

boost::proto::as_expr — A function that wraps non-Proto expression types in Proto terminals and leaves Proto expression types alone.

## Synopsis

    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);

## Description

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, ``proto::default_domain`` is assumed.

If ``proto::is_expr`<T>::value` is `true`, 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))`.