Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-08-04 05:24:06


From: Liu Jin <cpp_at_[hidden]>
> >>>>> "David" == David Abrahams <dave_at_[hidden]> writes:
> > Anyway, saying that symmetry requires
> > none_of(a) == any_of(b)
> > to be equivalent to
> > any_of(a) == none_of(b)
> > is about as valid as saying
> > 3*x == 1+y
> > must be equivalent to
> > 1+x == 3*y
> > It makes no sense to me.
>
> But it does break symmetry when
> none_of(a) == any_of(b) [no x in a equals to any y in b]
> is different from
> any_of(b) == none_of(a) [some x in b equals to nothing in a]

According to English rules, they are sensibly asymmetrical. Dave
suggested previously that we should use that as our guide and it
does make sense. Otherwise, one winds up forcing oneself to
process special cases. (If none with any, put the any first (or
second, whichever might be selected) to get the meaning correct.)

To clarify:

   if (none_of(a) == any_of(b)) ...

      "if none of the values in a is equal to any value in b"

   if (any_of(b) == none_of(a)) ...

      "if any value in b is equal to none of the values in a"

Whether written with the *_of() notation or in their English
equivalents, these sound asymmetrical.

In my implementation, none_of first leads to a different loop
than any_of first. Thus, to force symmetry, one must play games
with detecting the combinations to decide when to swap
arguments. Allowing the asymmetry is straightforward, at least
for my implementation.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

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