Is there anything that approximates all of Haskell or any functions as part of the STL? If not, is this a good implementation (I noticed that sgi STL performed a partial specialization if the iterators were random access, although I didn't bother with this)?
template <typename InputIterator, typename Predicate> inline bool all(InputIterator first, InputIterator last, Predicate pred) { while (first != last) { if (!pred(*first)) { return false; } ++first; } return true; }
Similarly, how would it be best to convert to iterate over two sequences and return true, where BinaryPredicate returns true for all, and false otherwise? I know this is relatively trivial, but it looks like it should be provided by an algorithm, and I want to make sure that I am not missing something.
source share