Boost logo

Proto :

Subject: Re: [proto] Difference between BOOST_PROTO_ASSERT_MATCHES(expr, grammar) and BOOST_MPL_ASSERT(proto::matches<Expr, Grammar>)
From: Eric Niebler (eric_at_[hidden])
Date: 2010-08-18 13:51:07


On 8/18/2010 11:54 AM, Thomas Heller wrote:
> Hi all,
>
> I just noticed that Eric wrote BOOST_MPL_ASSERT(proto::matches<Expr,
> Grammar>) in one of his latest posts here on the list (see thread about
> boost::parameters).
>
> So I wonder, where is the fundamental difference between
> BOOST_PROTO_ASSERT_MATCHES and the BOOS_MPL_ASSERT expression.

Well, you know, you *could* check the docs:

http://www.boost.org/doc/libs/1_44_0/doc/html/BOOST_PROTO_ASSERT_MATCHES.html

;-)

The difference is that BOOST_PROTO_ASSERT_MATCHES takes a runtime
expression and a grammar type, and checks that the expression matches
the grammar. It's handy for quickie one-offs like the example in the docs:

typedef
  proto::plus< proto::terminal< int >, proto::terminal< int > >
PlusInts;

BOOST_PROTO_ASSERT_MATCHES( proto::lit(1) + 42, PlusInts );

But really, that's the only difference. It's implemented in terms of
BOOST_MPL_ASSERT.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Proto list run by eric at boostpro.com