Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Struct template matches

boost::proto::matches — A Boolean metafunction that evaluates whether a given expression type matches a grammar.

Synopsis

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

template<typename Expr, typename Grammar> 
struct matches :  mpl::bool_<true-or-false> {
};

Description

proto::matches<Expr, Grammar> inherits from mpl::true_ if Expr::proto_base_expr matches Grammar::proto_base_expr, and from mpl::false_ otherwise.

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

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

  • B is the wildcard pattern, proto::_

  • A is B

  • A is B &

  • A is B const &

  • B is proto::exact<A>

  • B is proto::convertible_to<X> and boost::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, proto::_

  • B is T<B0,...Bn> and A is T<A0,...An> and for each x in [0,n], Ax and Bx are types such that Ax lambda-matches Bx


PrevUpHomeNext