STRUCT TEMPLATE M(3)

NAME
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_grammar matches Grammar::proto_grammar, and from mpl::false_ otherwise.

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

    &#8226; The wildcard pattern, proto::_, matches any expression.

    &#8226; An expression proto::basic_expr<AT, proto::listN <A0,...An> > matches a grammar proto::basic_expr<BT, proto::listN <B0,...Bn> > if BT is proto::_ or AT, and if Ax matches Bx for each x in [0,n].

    &#8226; An expression proto::basic_expr<AT, proto::listN <A0,...An,U0,...Um> > matches a grammar proto::basic_expr<BT, proto::listM <B0,...Bn,proto::vararg<V> > > if BT is proto::_ or AT, and if Ax matches Bx for each x in [0,n] and if Ux matches V for each x in [0,m].

    &#8226; An expression E matches proto::or_<B0,...Bn> if E matches some Bx for x in [0,n].

    &#8226; An expression E matches proto::and_<B0,...Bn> if E matches all Bx for x in [0,n].

    &#8226; An expression E matches proto::if_<T,U,V> if:

        &#8226;
                                boost::result_of<proto::when<proto::_,T>(E)>::type::value

                              is true and
                              E matches
                              U, or.RE

            &#8226;
                                    boost::result_of<proto::when<proto::_,T>(E)>::type::value

                                  is false and E matches
                                  V.
                                .RE
                Note: U defaults to proto::_ and V defaults to proto::not_<proto::_>.

                &#8226; An expression E matches proto::not_<T> if E does not match T.

                &#8226; An expression E matches proto::switch_<C> if E matches C::case_<E::proto_tag>.

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

            &#8226; B is the wildcard pattern, proto::_

            &#8226; A is B

            &#8226; A is B &

            &#8226; A is B const &

            &#8226; B is proto::exact<A>

            &#8226; B is proto::convertible_to<X> and boost::is_convertible<A,X>::value is true.

            &#8226; A is X[M] or X(&)[M] and B is X[proto::N].

            &#8226; A is X(&)[M] and B is X(&)[proto::N].

            &#8226; A is X[M] or X(&)[M] and B is X*.

            &#8226; B lambda-matches A (see below).

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

        &#8226; B is A

        &#8226; B is the wildcard pattern, proto::_

        &#8226; 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