Skip to content

Use constant references when iterating over ranges in replace_range#680

Merged
fnc12 merged 2 commits into
fnc12:masterfrom
andrei-datcu:patch-1
Mar 15, 2021
Merged

Use constant references when iterating over ranges in replace_range#680
fnc12 merged 2 commits into
fnc12:masterfrom
andrei-datcu:patch-1

Conversation

@andrei-datcu
Copy link
Copy Markdown
Contributor

@andrei-datcu andrei-datcu commented Mar 15, 2021

This is required if one wants to use iterators that do not return references when are dereferenced.
Usually, this will happen whenever using something from std::ranges. Eg:

struct Message {
    int id;
    int code;
}
std::vector<int> messageCodes = {....};
int id = 0;
auto messages = messageCodes | std::views::transform([&id](int code) mutable { return Message {.id = id++, .code = code};});
storage.replace_range(messages.begin(), messages.end());

@fnc12
Copy link
Copy Markdown
Owner

fnc12 commented Mar 15, 2021

nice. Let's wait for builds

@fnc12 fnc12 merged commit 78d8fa7 into fnc12:master Mar 15, 2021
@fnc12
Copy link
Copy Markdown
Owner

fnc12 commented Mar 15, 2021

@andrei-datcu PRs must me merged into dev branch not master. I accidentally merged in and I am going to unmerge it right now. Please reopen it with a branch from dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants