X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Falgorithm.h;fp=source%2Fcore%2Falgorithm.h;h=30ca267bfe73435bd2bf2e995e781f3d083a7ca4;hp=251a81ef1113b7f63cc849d1e78302bf5c941449;hb=de6ba04370a505484747a81c74ad8f532b4b88e6;hpb=39da82b967c70282973025e4b12186625e29fe26 diff --git a/source/core/algorithm.h b/source/core/algorithm.h index 251a81e..30ca267 100644 --- a/source/core/algorithm.h +++ b/source/core/algorithm.h @@ -30,6 +30,20 @@ inline typename Container::const_iterator find_if(const Container &cont, Predica return std::find_if(cont.begin(), cont.end(), pred); } +template +struct ValueMatch +{ + const T &value; + + bool operator()(const T &v) { return v==value; } +}; + +template +inline bool any_equals(Container &cont, const T &value) +{ + return std::any_of(cont.begin(), cont.end(), ValueMatch{value}); +} + template inline typename Container::iterator lower_bound(Container &cont, const T &value) {