Boost logo

Boost Users :

Subject: [Boost-users] [boost][algorithm] Overload of boost::algorithm::all_of_equal
From: dariomt_at_[hidden]
Date: 2015-05-21 05:21:17


Hi list,

I usually find useful an overload of this function to check whether all
elements in a range are equal *to each other*.

Something like:

template <typename Range>
bool all_of_equal(const Range & r)
{
    // return true on empty range
    if (boost::empty(r)) return true;
    // return true if all other elements are equal to the first element
    return boost::all_of_equal( boost::next( boost::begin(r) ),
boost::end(r), *boost::begin(r));
}

Would this be a useful addition to Boost.Algorithm?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net