Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2007-04-19 16:15:32


On 04/19/2007 12:35 PM, Eric Niebler wrote:
> Larry Evans wrote:
>
>>On 04/19/2007 11:46 AM, Eric Niebler wrote:
>>[snip]
>>
>>>Oh! You're chaining or_'s together. Sure, that works. So for your
>>>initial state, all you need is a pattern that never matches anything.
>>>For that, you can use proto::not<proto::_>.
>>
>>I couldn't get that to compile; however, proto::logical_not<proto::_>
>>does. Thanks.
>
>
>
> proto::not_<> is a fairly recent addition. Be sure you're sync'ed up.
> logical_not<_> is certainly not what you want here. It will successfully
> match proto expressions such as !as_expr('a'). You want something that
> will never match anything. You could also use
> proto::if_<mpl::always<mpl::false_> >.
>
>
Yeah, I thought about it some more and the name, logical_not, suggests
that if the argument, X, doesn't match, then logical_not<X>, would
match, which, as you've noted, is certainly not what I want.
However, I think proto::not_ also suffers the same name confusion. Like
logical_not<X>, I'd think not_<X> would mean "if X fails then not_<X>
succeeds". proto::if_<mpl::always<mpl::false_> > is much clearer
although more verbose. Maybe proto::always_false or maybe proto::no
would be less confusing and about as verbose.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk