SCGH SCGH - 3 months ago 8
Python Question

C++11 equivalent to Python's all() function

Is there an equivalent function to Python's

built-in function?

In other words: Does a C++11 function exist that returns
true
when all of the elements of an iterable meet a certain condition and
false
otherwise?

Answer

Check out std::all_of in the <algorithm> header. You can pass a custom predicate that evaluates to true or false on each element.