From: Eric Niebler (eric_at_[hidden])
Date: 2007-04-19 22:33:54
Larry Evans wrote:
> On 04/19/2007 12:35 PM, Eric Niebler wrote:
>> Larry Evans wrote:
>>> On 04/19/2007 11:46 AM, Eric Niebler wrote:
>>>> 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.
No, you're mixing two things up. logical_not<> doesn't logically negate
its argument. It matches the ! operator. The pattern "logical_not<
terminal< char > >" would match the expression template generated by
not_<> is different. It *does* logically negate its argument. The
pattern "not_< terminal< char > >" will match any expression *except*
those that match the pattern terminal<char>.
The pattern _ is a wildcard that matches anything. So not_<_> is a
degenerate pattern that matches nothing.
> 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>
That's precisely what it does.
-- Eric Niebler Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk