Skip to content

Commit

Permalink
2023 day 5: add note about an unnecessary-looking copy
Browse files Browse the repository at this point in the history
  • Loading branch information
yut23 committed Jan 24, 2024
1 parent 2800793 commit f17eecb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions 2023/src/day05.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ int main(int argc, char **argv) {
std::size_t N = map.entries.size();
long curr = 0;
for (std::size_t i = 0; i < N; ++i) {
// make a copy here, as emplace_back can invalidate a reference
const auto entry = map.entries[i];
if (curr < entry.start) {
map.entries.emplace_back(curr, curr, entry.start - curr);
Expand Down

0 comments on commit f17eecb

Please sign in to comment.