Skip to content

Commit 865806a

Browse files
committed
Replace 'order_by_priority' with std::ranges::sort with projection
1 parent 9afb6dd commit 865806a

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

src/report_generator.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,6 @@ struct order_by_status {
9595
};
9696

9797

98-
struct order_by_priority {
99-
explicit order_by_priority(lwg::section_map &sections)
100-
: section_db(sections)
101-
{
102-
}
103-
104-
auto operator()(lwg::issue const & x, lwg::issue const & y) const -> bool {
105-
assert(!x.tags.empty());
106-
assert(!y.tags.empty());
107-
auto tie = [this](auto& i) {
108-
return std::tie(i.priority, section_db[i.tags.front()], i.num);
109-
};
110-
return tie(x) < tie(y);
111-
}
112-
113-
private:
114-
lwg::section_map& section_db;
115-
};
116-
11798
// Replace spaces to make a string usable as an 'id' attribute,
11899
// or as an URL fragment (#foo) that links to an 'id' attribute.
119100
inline std::string spaces_to_underscores(std::string s) {
@@ -673,7 +654,10 @@ R"(<h1>C++ Standard Library Issues List (Revision )" << lwg_issues_xml.get_revis
673654

674655

675656
void report_generator::make_sort_by_priority(std::vector<issue>& issues, fs::path const & filename) {
676-
sort(issues.begin(), issues.end(), order_by_priority{section_db});
657+
auto proj = [this](const auto& i) {
658+
return std::tie(i.priority, section_db[i.tags.front()], i.num);
659+
};
660+
std::ranges::sort(issues, {}, proj);
677661

678662
std::ofstream out{filename};
679663
if (!out)

0 commit comments

Comments
 (0)