Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::proto::matches< Expr, Grammar > Struct Template Reference

A Boolean metafunction that evaluates whether a given expression type matches a grammar. More...

#include <proto_fwd.hpp>

Inheritance diagram for boost::proto::matches< Expr, Grammar >:
Collaboration diagram for boost::proto::matches< Expr, Grammar >:

Detailed Description

template<typename Expr, typename Grammar>
struct boost::proto::matches< Expr, Grammar >

A Boolean metafunction that evaluates whether a given expression type matches a grammar.

matches<Expr,Grammar> inherits (indirectly) from mpl::true_ if Expr::proto_grammar matches Grammar::proto_grammar, and from mpl::false_ otherwise.

Non-terminal expressions are matched against a grammar according to the following rules:

  • The wildcard pattern, _, matches any expression.
  • An expression expr<AT, listN<A0,A1,...An> > matches a grammar expr<BT, listN<B0,B1,...Bn> > if BT is _ or AT, and if Ax matches Bx for each x in [0,n).
  • An expression expr<AT, listN<A0,...An,U0,...Um> > matches a grammar expr<BT, listM<B0,...Bn,vararg<V> > > if BT is _ or AT, and if Ax matches Bx for each x in [0,n) and if Ux matches V for each x in [0,m).
  • An expression E matches or_<B0,B1,...Bn> if E matches some Bx for x in [0,n).
  • An expression E matches and_<B0,B1,...Bn> if E matches all Bx for x in [0,n).
  • An expression E matches if_<T,U,V> if boost::result_of<when<_,T>(E,int,int)>::type::value is true and E matches U; or, if boost::result_of<when<_,T>(E,int,int)>::type::value is false and E matches V. (Note: U defaults to _ and V defaults to not_<_>.)
  • An expression E matches not_<T> if E does not match T.
  • An expression E matches switch_<C,T> if E matches C::case_<boost::result_of<T(E)>::type>. (Note: T defaults to tag_of<_>().)

A terminal expression expr<AT,term<A> > matches a grammar expr<BT,term<B> > if BT is AT or proto::_ and if one of the following is true:

  • B is the wildcard pattern, _
  • A is B
  • A is B &
  • A is B const &
  • B is exact<A>
  • B is convertible_to<X> and is_convertible<A,X>value is true.
  • A is X[M] or X(&)[M] and B is X[proto::N].
  • A is X(&)[M] and B is X(&)[proto::N].
  • A is X[M] or X(&)[M] and B is X*.
  • B lambda-matches A (see below).

A type B lambda-matches A if one of the following is true:

  • B is A
  • B is the wildcard pattern, _
  • B is T<B0,B1,...Bn> and A is T<A0,A1,...An> and for each x in [0,n), Ax and Bx are types such that Ax lambda-matches Bx

The documentation for this struct was generated from the following file: