...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::matches — A Boolean metafunction that evaluates whether a given expression type matches a grammar.
// In header: <boost/proto/matches.hpp>
template<typename Expr, typename Grammar>
struct matches : mpl::bool_<true-or-false
> {
};
proto::matches
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:
The wildcard pattern,
proto::_
, matches any expression.
An expression
proto::basic_expr
matches a grammar
proto::basic_expr
if
BT
is
proto::_
or
AT
, and if
Ax
matches
Bx
for each x
in [0,n]
.
An expression
proto::basic_expr
matches a grammar
proto::basic_expr
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]
.
An expression E
matches
proto::or_0,...Bn>
if
E
matches some
Bx
for
x
in [0,n]
.
An expression E
matches
proto::and_0,...Bn>
if
E
matches all
Bx
for
x
in [0,n]
.
An expression E
matches
proto::if_
if:
boost::result_of<proto::when<proto::_,T>(E)>::type::value
is true
and
E
matches
U
, or
boost::result_of<proto::when<proto::_,T>(E)>::type::value
is false
and E
matches
V
.
Note: U
defaults to
proto::_
and V
defaults to
proto::not_<proto::_>
.
An expression E
matches
proto::not_
if
E
does not match T
.
An expression E
matches
proto::switch_
if
E
matches C::case_
.
A terminal expression
proto::basic_expr
matches a grammar
proto::basic_expr
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
B
is
proto::convertible_to
and boost::is_convertible::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: