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

Typo? in range.iota_view example #2717

Closed
robert-andrzejuk opened this issue Feb 28, 2019 · 2 comments
Closed

Typo? in range.iota_view example #2717

robert-andrzejuk opened this issue Feb 28, 2019 · 2 comments

Comments

@robert-andrzejuk
Copy link

robert-andrzejuk commented Feb 28, 2019

@CaseyCarter I believe the example in the draft standard might perhaps contain a very minor error.

http://eel.is/c++draft/range.iota#overview-2

Shouldn't the comment be prints: 1 2 3 4 5 6 7 8 9 10 ?

[ Example:

for (int i : iota_view{1, 10})
  cout << i << ' '; // prints: 1 2 3 4 5 6 7 8 9

— end example
 ]
@Rakete1111
Copy link
Contributor

Rakete1111 commented Feb 28, 2019

Why? See http://eel.is/c++draft/range.iota#sentinel-2 When the value of the iterator is equal to the upper bound (in this case 10), the iterator is equal to the sentinel and thus the loop stops.

@CaseyCarter
Copy link
Contributor

As @Rakete1111 says, the arguments to view::iota are treated as a half-open interval [first, last).

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

No branches or pull requests

4 participants