From d1fcf2b508f0145c226b69dd43c187c71f45c6a2 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 4 Nov 2024 16:49:44 +0000 Subject: [PATCH] Replace 'order_by_priority' with std::ranges::sort with projection --- src/report_generator.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/report_generator.cpp b/src/report_generator.cpp index 4adc65672e..3cf74160f1 100644 --- a/src/report_generator.cpp +++ b/src/report_generator.cpp @@ -95,25 +95,6 @@ struct order_by_status { }; -struct order_by_priority { - explicit order_by_priority(lwg::section_map §ions) - : section_db(sections) - { - } - - auto operator()(lwg::issue const & x, lwg::issue const & y) const -> bool { - assert(!x.tags.empty()); - assert(!y.tags.empty()); - auto tie = [this](auto& i) { - return std::tie(i.priority, section_db[i.tags.front()], i.num); - }; - return tie(x) < tie(y); - } - -private: - lwg::section_map& section_db; -}; - // Replace spaces to make a string usable as an 'id' attribute, // or as an URL fragment (#foo) that links to an 'id' attribute. inline std::string spaces_to_underscores(std::string s) { @@ -673,7 +654,10 @@ R"(

C++ Standard Library Issues List (Revision )" << lwg_issues_xml.get_revis void report_generator::make_sort_by_priority(std::vector& issues, fs::path const & filename) { - sort(issues.begin(), issues.end(), order_by_priority{section_db}); + auto proj = [this](const auto& i) { + return std::tie(i.priority, section_db[i.tags.front()], i.num); + }; + std::ranges::sort(issues.begin(), issues.end(), {}, proj); std::ofstream out{filename}; if (!out)