Check Conditions on Ranges
C++17 contains several algorithms to check whether a value or values in a range fulfill our given condition. Let's look at these algorithms now.
The three functions std::all_of
, std::any_of
and std::none_of
answer the question, if all, at least one or no element of a range satisfies the condition. The functions need as arguments input iterators and a unary predicate and return a boolean.
Checks if all elements of the range satisfy the condition:
Get hands-on with 1400+ tech skills courses.