Boost logo

Boost :

Subject: Re: [boost] [Review:Algorithms] - Review by Neil Groves
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2011-10-17 19:55:35


On Oct 1, 2011, at 8:20 AM, Neil Groves wrote:

> It might be worth considering an assertion that p(lo,hi) is true in the clamp function.

i dont; think that this is correct; consider the (limiting) case of clamp ( x, 3, 3 ).
Probably not what the developer intended, but not incorrect.

> The documentation should make very clear that the result for empty ranges
> into all_of, any_of, none_of as this is currently ambiguous. The
> documentation should provide more clear performance guarantees about the
> number of predicate evaluations where this is possible eg. any_of can and
> does early exit. The documentation should also provide the exception
> guarantees.

How about this:

[heading Complexity]

All of the variants of `all_of` and `all_of_equal` run in ['O(N)] (linear) time; that is, they compare against each element in the list once. If any of the comparisons fail, the algorithm will terminate immediately, without examining the remaining members of the sequence.

[heading Exception Safety]

All of the variants of `all_of` and `all_of_equal` take their parameters by value or const reference, and do not depend upon any global state. Therefore, all the routines in this file provide the strong exception guarantee.

[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.

-- Marshall

Marshall Clow Idio Software <mailto:mclow.lists_at_[hidden]>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki


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