Modernize std::stable_sort with ranges and projections

This commit is contained in:
mitaclaw
2024-09-28 22:20:48 -07:00
parent 8b9f92a0af
commit c9f589faa5
4 changed files with 13 additions and 27 deletions

View File

@ -1335,8 +1335,7 @@ void VolumeVerifier::Finish()
}
// Show the most serious problems at the top
std::stable_sort(m_result.problems.begin(), m_result.problems.end(),
[](const Problem& p1, const Problem& p2) { return p1.severity > p2.severity; });
std::ranges::stable_sort(m_result.problems, std::ranges::greater{}, &Problem::severity);
const Severity highest_severity =
m_result.problems.empty() ? Severity::None : m_result.problems[0].severity;