For an example:
All of that code that you're writing is in those few lines.Code:#include <algorithm> bool isPassingGrade(const Student_info& info) { return !fgrade(info); } vector<Student_info> extract_fails(vector<Student_info>& students) { // Partition students -- passing is on left of partition, failing is on right of partition vector<Student_info>::iterator it = std::stable_partition(students.begin(), students.end(), isPassingGrade); // iterator "it" is the partition point, so erase failures starting there students.erase(it, students.end()); return students; }
Regards,
Paul McKenzie




Reply With Quote