Skip to content

Implement views::counted - #1375

Merged
Casey Carter (CaseyCarter) merged 12 commits into
microsoft:masterfrom
miscco:views_counted
Nov 4, 2020
Merged

Casey Carter (CaseyCarter) merged 12 commits into
microsoft:masterfrom
miscco:views_counted

Conversation

@miscco

Copy link
Copy Markdown
Contributor

Partially addresses #39

Note: Reading the requirement in http://eel.is/c++draft/ranges#range.counted-2 I was lazy and assumed that it is sufficient that the passed argument is convertible. Is that correct or do we need to add some _Choice magic?

Comment thread stl/inc/ranges Outdated
@miscco

Copy link
Copy Markdown
Contributor Author

Casey Carter (@CaseyCarter), I am unsure whether we should test anything more as we essentially tested everything already with the span and subrange tests.

Other test ideas besides checking for content?

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added cxx20 C++20 feature ranges C++20/23 ranges labels Oct 16, 2020
@miscco

Copy link
Copy Markdown
Contributor Author

Urgh, that conversion warning of auto result = ranges::views::counted(Iter{input}, 3); sets me off.

I guess I should have been more careful regarding the convertible_to<iter_difference<_Iter>> requirement

@miscco

Copy link
Copy Markdown
Contributor Author

Casey Carter (@CaseyCarter) I feel like the convertible_to<_Diff, iter_difference_t<_It>> requirement on views::counted would also make sense for counted_iterator, where we explicitly require the second argument to be of type iter_difference_t<_It>

This was also the reason that in the test we have these two lines in the test:

            counted_iterator<Iter> constructed(Iter{input}, iter_difference_t<Iter>{2});
            counted_iterator<Iter> constructedEmpty{Iter{input}, iter_difference_t<Iter>{0}};

Would you say that this is something we might want to change?

@miscco

Copy link
Copy Markdown
Contributor Author

Also the actual error is that std::span takes an size_t as second argument, so I assume we would need to cast it to size_t before passing it so std::span even if that might be impossible :(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a real review, just correcting the problem from #1393.

Comment thread stl/inc/ranges Outdated
Comment thread tests/std/tests/P0896R4_views_counted_death/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_views_counted_death/test.cpp Outdated
Comment thread stl/inc/ranges Outdated
Comment thread tests/std/tests/P0896R4_views_counted/test.cpp
Comment thread tests/std/tests/P0896R4_views_counted/test.cpp Outdated
Comment thread stl/inc/ranges
Comment thread stl/inc/ranges Outdated
* Missed a `decay_t` in `operator()`

* Discard the result in the death test

* Only death test when `_DEBUG` (since the check is an `_STL_ASSERT`)
Comment thread stl/inc/ranges
I'm not paranoid!
@CaseyCarter Casey Carter (CaseyCarter) removed their assignment Oct 30, 2020
Comment thread stl/inc/ranges
... resolving simple conflicts from adding things in the same place in both `tests/std/test.lst` and `tests/std/tests/P0896R4_ranges_range_machinery`.
@CaseyCarter
Casey Carter (CaseyCarter) merged commit 2380824 into microsoft:master Nov 4, 2020
@CaseyCarter

Casey Carter (CaseyCarter) commented Nov 4, 2020

Copy link
Copy Markdown
Contributor

Every contribution counts! (But some more than others.)

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

Labels

cxx20 C++20 feature ranges C++20/23 ranges

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants