You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Only used the function in the places where it is a perfect match. So no ranges::swap_ranges with two sentinels, and no std::copy etc with weaker precondition.
I was very surprised to learn that copy_if / remove_copy / remove_copy_if / unique_copy require non-overlap as follows:
The ranges [first, last) and [result, result + (last - first)) do not overlap.
This implies that the destination range may fit the same element number as the source range contains. I thought only fitting the actually returned number of elements is enough.
Overall, now as I've done this, I'm not even sure if it is at all useful.
This implies that the destination range may fit the same element number as the source range contains. I thought only fitting the actually returned number of elements is enough.
They have:
std::array<S, 4> in = {{{4, 2}, {1, 3}, {3, 4}, {3, 5}}};
std::array<S, 2> out;
auto ret = std::ranges::copy_if(in.begin(), in.end(), out.begin(), [](int i) { return i == 3; }, &S::val);
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #5472.
Only used the function in the places where it is a perfect match. So no
ranges::swap_ranges
with two sentinels, and nostd::copy
etc with weaker precondition.I was very surprised to learn that
copy_if
/remove_copy
/remove_copy_if
/unique_copy
require non-overlap as follows:This implies that the destination range may fit the same element number as the source range contains. I thought only fitting the actually returned number of elements is enough.
Overall, now as I've done this, I'm not even sure if it is at all useful.