@@ -63,19 +63,31 @@ struct order_by_major_section {
63
63
lwg::section_map& section_db;
64
64
};
65
65
66
+ // Create a LessThanComparable object that defines an ordering based on date,
67
+ // with newer dates first.
68
+ auto ordered_date (lwg::issue const & issue) {
69
+ std::chrono::sys_days date (issue.mod_date );
70
+ return -date.time_since_epoch ().count ();
71
+ }
72
+
73
+ // Create a LessThanComparable object that defines an ordering that depends on
74
+ // the section number (e.g. 23.5.1) first and then on the section stable tag.
75
+ // Using both is not redundant, because we use section 99 for all sections of some TS's.
76
+ // Including the tag in the order gives a total order for sections in those TS's,
77
+ // e.g., {99,[arrays.ts::dynarray]} < {99,[arrays.ts::dynarraconstructible_from.cons]}.
78
+ auto ordered_section (lwg::section_map & section_db, lwg::issue const & issue) {
79
+ assert (!issue.tags .empty ());
80
+ return std::tie (section_db[issue.tags .front ()], issue.tags .front ());
81
+ }
82
+
66
83
struct order_by_section {
67
84
explicit order_by_section (lwg::section_map §ions)
68
85
: section_db(sections)
69
86
{
70
87
}
71
88
72
89
auto operator ()(lwg::issue const & x, lwg::issue const & y) const -> bool {
73
- assert (!x.tags .empty ());
74
- assert (!y.tags .empty ());
75
- // This sorts by the section number (e.g. 23.5.1) then by the section stable tag.
76
- // This is not redundant, because for e.g. Arrays TS the entire paper has section num 99,
77
- // so including the tag orders [arrays.ts::dynarray] before [arrays.ts::dynarray.cons].
78
- return std::tie (section_db[x.tags .front ()], x.tags .front ()) < std::tie (section_db[y.tags .front ()], y.tags .front ());
90
+ return ordered_section (section_db, x) < ordered_section (section_db, y);
79
91
}
80
92
81
93
private:
@@ -696,10 +708,10 @@ sorted by priority.</p>
696
708
697
709
698
710
void report_generator::make_sort_by_status (std::vector<issue>& issues, fs::path const & filename) {
699
- sort (issues. begin (), issues. end (), order_by_issue_number{});
700
- stable_sort (issues. begin ( ), issues. end ( ), [](issue const & x, issue const & y) { return x. mod_date > y. mod_date ; } );
701
- stable_sort (issues. begin (), issues. end (), order_by_section{section_db}) ;
702
- stable_sort (issues.begin (), issues.end (), order_by_status{} );
711
+ auto proj = [ this ]( const auto & i) {
712
+ return std::make_tuple ( lwg::get_status_priority (i. stat ), ordered_section (section_db, i ), ordered_date (i), i. num );
713
+ } ;
714
+ std::ranges::sort (issues.begin (), issues.end (), {}, proj );
703
715
704
716
std::ofstream out{filename};
705
717
if (!out)
@@ -733,10 +745,10 @@ This document is the Index by Status and Section for the <a href="lwg-active.htm
733
745
734
746
735
747
void report_generator::make_sort_by_status_mod_date (std::vector<issue> & issues, fs::path const & filename) {
736
- sort (issues. begin (), issues. end (), order_by_issue_number{});
737
- stable_sort (issues. begin ( ), issues. end ( ), order_by_section{ section_db} );
738
- stable_sort (issues. begin (), issues. end (), [](issue const & x, issue const & y) { return x. mod_date > y. mod_date ; } ) ;
739
- stable_sort (issues.begin (), issues.end (), order_by_status{} );
748
+ auto proj = [ this ]( const auto & i) {
749
+ return std::make_tuple ( lwg::get_status_priority (i. stat ), ordered_date (i ), ordered_section ( section_db, i), i. num );
750
+ } ;
751
+ std::ranges::sort (issues.begin (), issues.end (), {}, proj );
740
752
741
753
std::ofstream out{filename};
742
754
if (!out)
@@ -769,9 +781,11 @@ This document is the Index by Status and Date for the <a href="lwg-active.html">
769
781
770
782
771
783
void report_generator::make_sort_by_section (std::vector<issue>& issues, fs::path const & filename, bool active_only) {
772
- sort (issues.begin (), issues.end (), order_by_issue_number{});
773
- stable_sort (issues.begin (), issues.end (), [](issue const & x, issue const & y) { return x.mod_date > y.mod_date ; } );
774
- stable_sort (issues.begin (), issues.end (), order_by_status{});
784
+ auto proj = [this ](const auto & i) {
785
+ return std::make_tuple (lwg::get_status_priority (i.stat ), ordered_date (i), i.num );
786
+ };
787
+ std::ranges::sort (issues.begin (), issues.end (), {}, proj);
788
+
775
789
auto b = issues.begin ();
776
790
auto e = issues.end ();
777
791
if (active_only) {
0 commit comments