replace a for-loop with iterator and break by a std::all_of