|
Boost : |
Subject: Re: [boost] [Review:Algorithms]
From: dariomt (dariomt_at_[hidden])
Date: 2011-09-28 05:02:46
Marshall Clow <mclow.lists <at> gmail.com> writes:
>
> >
> > I thought I had suggested any_equal, all_equal, etc. in a previous
> > email. Maybe I forgot to send it :)
>
> Ok - I've changed the names, and pushed the changes to github.
> https://github.com/mclow/Boost.Algorithm
>
> If people are more comfortable downloading zip files, I can make another one
of those.
>
I'd like to suggest the following
----------------
template<typename R, typename V>
bool all_equal_to ( const R &range, const V &val );
returns true iff each item in the sequence compares *equal to* the value val
----------------
template<typename R>
bool all_equal (const R &range);
returns true iff each item in the sequence compares *equal* to each other (since
the comparison is transitive this can be implemented comparing each element in
the sequence to the first one).
sequences of size 0 and 1 return true, larger sequences can be implemented as
all_equal_to ( range, *begin(range) );
----------------
I have my own version of all_equal and I find it quite useful.
What do you think?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk