What is 'jobs' in your pseudo-code? Can it be a user-defined type? Does the author of that class need to explicitly state that their type meets some trait? Is 'Any' part of the type, a trait, or the language?
What humanrebar wrote is an algorithm that will work with any range of any type that has a 'failed()' member function.
Here's another formalisation:
auto batch_failed = [](auto const& batch) {
return std::any_of (begin (batch), end (batch),
[](auto& testcase) { return testcase.failed (); });
}
This function will basically work with anything.