The syntax might seem strange to you, but this is pretty slick:
bool batch_failed = std::any_of(
jobs.begin(), jobs.end(),
[](const auto & job) { return job.failed(); }
);
In C++03-plus-auto, you'd have to define an helper function or class: bool isJobFailed(const Job& job) {
return job.failed();
}
And then use find_if, I guess: auto last = jobs.end();
auto iter = std::find_if(
jobs.begin(), jobs.end(),
isJobFailed
);
bool batch_failed = (iter == last);