Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<iterator>: move_sentinel could be unwrappable #3009

Closed
JMazurkiewicz opened this issue Aug 8, 2022 · 2 comments · Fixed by #3098
Closed

<iterator>: move_sentinel could be unwrappable #3009

JMazurkiewicz opened this issue Aug 8, 2022 · 2 comments · Fixed by #3098
Labels
fixed Something works now, yay! performance Must go faster ranges C++20/23 ranges

Comments

@JMazurkiewicz
Copy link
Contributor

JMazurkiewicz commented Aug 8, 2022

As the title says, std::move_sentinel could be unwrappable.

Outdated (fixed by #3024)

Since std::move_sentinel<X> is not unwrappable, it cannot be used with ranges algorithms when corresponding std::move_iterator<X> is unwrappable.

#include <algorithm>
#include <cassert>
#include <iterator>
#include <vector>

using namespace std;

int main() {
    vector<int> ints = {1, 2, 3};
    auto is_positive = [](auto x) { return x > 0; };
    assert(ranges::all_of(move_iterator{ints.begin()}, move_sentinel{ints.end()}, is_positive));
}

Expected behavior: This code should compile.

Additional context:

@JMazurkiewicz
Copy link
Contributor Author

JMazurkiewicz commented Sep 8, 2022

This is no longer a bug (thanks to #3024), so it should be labelled with enhancement or performance.

@JMazurkiewicz JMazurkiewicz changed the title <iterator>: move_sentinel should be unwrappable <iterator>: move_sentinel could be unwrappable Sep 8, 2022
@StephanTLavavej StephanTLavavej added performance Must go faster and removed bug Something isn't working labels Sep 10, 2022
@StephanTLavavej
Copy link
Member

Relabeled - thanks @JMazurkiewicz!

strega-nil-ms pushed a commit to strega-nil/stl that referenced this issue Sep 12, 2022
@StephanTLavavej StephanTLavavej added the fixed Something works now, yay! label Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Something works now, yay! performance Must go faster ranges C++20/23 ranges
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants