|
Boost : |
From: Larry Evans (cppljevans_at_[hidden])
Date: 2007-04-21 08:57:24
On 04/17/2007 09:24 PM, Maurizio Vitale wrote:
>> (and maybe 0 arguments as
>>
>>>well).
>>
>>
>>Ick, no. It's not obvious what it should mean.
>
>
> A way to define it would be similar to what scheme/lisp do for
> operators applied to no arguments: they return the identity
> for the operation.
> For logical and and or, the identities would be #t and #f.
>
> For grammars, and_ would be something that always matches
> and or_ would be something that never matches,
>
> Maybe not particularly useful here, because probably nobody
> recurses on grammars this way, but very useful to have
> in scheme and lisp.
>
> But I think having the same behaviour as mpl::and_ and mpl::or_
> is very important, so if one is changed the other probably should
> as well. The nice thing about this change is that it shouldn't
> make any code that was valid invalid (unless there's a way
> to have SFINAE effects visible).
So, to summarize, what you want is:
proto::and_<> == proto::_
proto::or_<> == proto::not_<_>
where == means, "matches the same expressions".
IOW, _ and not_<_> would be the "ones"
of the and_ and or_ operators since:
proto::and_<proto::and_<X0,X1,...,Xn>, proto::_ >
== proto::and_<X0,X1,...,Xn>
and likewise for or_ and proto::not_<_>. The zeros
would be just the reverse. IOW,
zero one
____ ___
and_: not_<_> _
or_ : _ not_<_>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk