From dc2be0b4424ce9c5364a7a9234fe7d319da294d9 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 28 Mar 2022 22:39:19 +0300 Subject: [PATCH] utils: add seq_some --- lib/utils/mu-utils.hh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/utils/mu-utils.hh b/lib/utils/mu-utils.hh index 25f34207..69bf348d 100644 --- a/lib/utils/mu-utils.hh +++ b/lib/utils/mu-utils.hh @@ -297,6 +297,19 @@ typename Sequence::const_iterator seq_find_if(const Sequence& seq, UnaryPredicat return std::find_if(seq.cbegin(), seq.cend(), pred); } +/** + * Is at least pred(element) true for at least one element of sequence + * + * @param seq sequence + * @param pred a predicate + * + * @return true or false + */ +template +bool seq_some(const Sequence& seq, UnaryPredicate pred) { + return seq_find_if(seq, pred) != seq.cend(); +} + /** * Create a sequence that has all element of seq for which pred is true *