Boost logo

Boost :

Subject: Re: [boost] [Review:Algorithms] My review of Boost.Algorithm
From: lcaminiti (lorcaminiti_at_[hidden])
Date: 2011-09-30 12:39:18


Marshall Clow-2 wrote:
>
>> 1) [WANT] Could all/any/none/one_of_equal be made more general and
>> merged with all/any/none/one_of by accepting a binary predicate via
>> overloading?
>>
>> template<typename InputIterator, typename UnaryPred>
>> bool all_of ( InputIterator first, InputIterator last, Pred p );
>>
>> template&lt;typename InputIterator, typename BinaryPred, typename V&gt;
>> bool all_of ( InputIterator first, InputIterator last, BinaryPred p, V
>> const& v );
>
> I think that bind handles this for us:
> all_of ( first, last, bind ( pred, _1, v )) ?
>

Yes, of course but then why providing all/one/none/any_of_equal at all? Just
provide C++11 _of with the addition of one_of and use bind:

all_of(first, last bind(std::equal_to<V>(), _1, v)) // instead of
all_of_equal

BTW, if you stick with the _of_equal, why not providing more of them for
operators other than == and calling them
all/one/none/any_equal_to/_less/_greater/... to follow STL functional
convention?

>> 9) [WANT] Are these examples from the docs incorrect? (What's 3, 9, etc?)
>>
>> one_of ( c.begin (), c.end (), 3 ) --> true
>> one_of ( c, 3 ) --> true
>> none_of ( c, 9 ) --> true
>> any_of ( c.begin (), c.end (), 9 ) --> false
>
> Right before these examples is:
> Examples: Given the container c containing { 0, 1, 2, 3, 4, 5 }, then
>
> I guess I need to make that more noticeable.
>

I meant, don't you need a predicate here instead of 3, 9, etc?

Thanks,
--Lorenzo

--
View this message in context: http://boost.2283326.n4.nabble.com/Review-Algorithms-My-review-of-Boost-Algorithm-tp3858602p3860365.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

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