Test 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 of whether all, at least one, or no elements of a range satisfy the condition. As arguments, the functions need input iterators, 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.