template<typename InputIterator, typename Predicate>
inline InputIterator
find_if(InputIterator first, InputIterator last, Predicate pred, input_iterator_tag)
{
while (first != last && !bool(pred(*first)))
++first;
return first;
}
I bumped into this snippet in the source code of the implementation of the C++ standard library shipped with GCC 4.7.0. This is the specialization of find_if
for an input iterator. I cleaned the leading underscores to make it more readable.
Why did they use a bool
cast on the predicate?