Skip to content

Commit 4496720

Browse files
committed
Remove unnecessary uses of std::reference_wrapper in predicates
These function objects only need to be copy-constructible, not assignable, so reference members are fine.
1 parent 64d801b commit 4496720

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/report_generator.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <algorithm>
1212
#include <cassert>
1313
#include <fstream>
14-
#include <functional> // reference_wrapper
1514
#include <memory>
1615
#include <sstream>
1716
#include <stdexcept>
@@ -70,13 +69,13 @@ struct order_by_major_section {
7069
auto operator()(lwg::issue const & x, lwg::issue const & y) const -> bool {
7170
assert(!x.tags.empty());
7271
assert(!y.tags.empty());
73-
lwg::section_num const & xn = section_db.get()[x.tags[0]];
74-
lwg::section_num const & yn = section_db.get()[y.tags[0]];
72+
lwg::section_num const & xn = section_db[x.tags[0]];
73+
lwg::section_num const & yn = section_db[y.tags[0]];
7574
return std::tie(xn.prefix, xn.num[0]) < std::tie(yn.prefix, yn.num[0]);
7675
}
7776

7877
private:
79-
std::reference_wrapper<lwg::section_map> section_db;
78+
lwg::section_map& section_db;
8079
};
8180

8281
struct order_by_section {
@@ -91,11 +90,11 @@ struct order_by_section {
9190
// This sorts by the section number (e.g. 23.5.1) then by the section stable tag.
9291
// This is not redundant, because for e.g. Arrays TS the entire paper has section num 99,
9392
// so including the tag orders [arrays.ts::dynarray] before [arrays.ts::dynarray.cons].
94-
return std::tie(section_db.get()[x.tags.front()], x.tags.front()) < std::tie(section_db.get()[y.tags.front()], y.tags.front());
93+
return std::tie(section_db[x.tags.front()], x.tags.front()) < std::tie(section_db[y.tags.front()], y.tags.front());
9594
}
9695

9796
private:
98-
std::reference_wrapper<lwg::section_map> section_db;
97+
lwg::section_map& section_db;
9998
};
10099

101100
struct order_by_status {
@@ -121,13 +120,13 @@ struct order_by_priority {
121120
assert(!x.tags.empty());
122121
assert(!y.tags.empty());
123122
auto tie = [this](auto& i) {
124-
return std::tie(i.priority, section_db.get()[i.tags.front()], i.num);
123+
return std::tie(i.priority, section_db[i.tags.front()], i.num);
125124
};
126125
return tie(x) < tie(y);
127126
}
128127

129128
private:
130-
std::reference_wrapper<lwg::section_map> section_db;
129+
lwg::section_map& section_db;
131130
};
132131

133132
// Replace spaces to make a string usable as an 'id' attribute,

0 commit comments

Comments
 (0)