
Boost : 
Subject: Re: [boost] [Review:Algorithms]  Review by Neil Groves
From: Christopher Jefferson (chris_at_[hidden])
Date: 20111018 13:38:14
On 18 Oct 2011, at 18:02, Stewart, Robert wrote:
> Marshall Clow wrote:
>> On Oct 18, 2011, at 5:30 AM, Stewart, Robert wrote:
>>> Marshall Clow wrote:
>>>>
>>>> How about this:
>>>
>>> You can be more succinct:
>>
>> I'm not really sure that being succinct is a goal.
>
> In and of itself, it isn't, but when clarity is retained, succinctness is better. There might be the rub, however.
>
>>>> [heading Notes]
>>>>
>>>> * `all_of` and `all_of_equal` both return true for empty
>>>> ranges, no matter what is passed to test against. When
>>>> there are no items in the sequence to test, they all satisfy
>>>> the condition to be tested against.
>>>
>>> [heading Empty Ranges]
>>>
>>> All variants of `all_of` and `all_of_equal` always return
>>> true for empty ranges.
>>
>> This is a case where a bit of rationale adds to the
>> explanation, I think.
>
> Your rationale added nothing, as far as I'm concerned. Besides, a statement like, "when there are no items...they all satisfy", is nonsensical. No matter how you try to rationalize the result, the other could be justified equally. That is, since there are no elements, none satisfied the criteria, so return false. Returning true or false for empty ranges is determined by fiat.
No, I agree with the justification. Almost all of mathematics relies on a basis which requires "forall i in S. p(i)" is true when S is empty, and "exists i in S. p(i)" is false when S is empty.
There are lots of conditions people expect to hold like:
If T is a subset of S, then "forall i in S.p(i)" implies "forall i in T.p(i)".
Which would be violated with forall wasn't always true for an empty set (or in our case, empty range).
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk