Skip to content

Implement ranges::unique family - #1039

Merged
Casey Carter (CaseyCarter) merged 22 commits into
microsoft:masterfrom
miscco:ranges_unique
Jul 27, 2020
Merged

Implement ranges::unique family#1039
Casey Carter (CaseyCarter) merged 22 commits into
microsoft:masterfrom
miscco:ranges_unique

Conversation

@miscco

@miscco Michael Schellenberger Costa (miscco) commented Jul 12, 2020

Copy link
Copy Markdown
Contributor

This implements ranges::unique and ranges::unique_copy.

Casey Carter (@CaseyCarter): Any good idea on how to test which implementation is actually used? I thought about counting inside the projection if the projected object lies within input or output or somewhere else. But that does not fully work because some of the combinations of the store path trigger the higher ones.

Comment thread tests/std/test.lst Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Comment thread stl/inc/algorithm Outdated
Comment thread stl/inc/algorithm Outdated
Comment thread stl/inc/algorithm Outdated
Comment thread stl/inc/algorithm Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Comment thread stl/inc/algorithm Outdated
Comment thread tests/std/test.lst Outdated
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
@miscco

Copy link
Copy Markdown
Contributor Author

For whatever reasons GitHub (@github) does not update the branch. Seems it has trouble

@StephanTLavavej

Copy link
Copy Markdown
Member

GitHub apparently had some downtime earlier, but I see a code format validation failure because my requested comment edit made the line exceed 120 characters 😹 I think if you fix that, it should pass?

@miscco

Michael Schellenberger Costa (miscco) commented Jul 13, 2020

Copy link
Copy Markdown
Contributor Author

I already fixed that and pushed it to github so I do not really know what to do that it picks up the new commit

miscco@89b50da

Comment thread stl/inc/algorithm Outdated
Comment thread stl/inc/algorithm Outdated
Comment thread stl/inc/algorithm
Comment thread stl/inc/algorithm Outdated
Comment thread stl/inc/algorithm Outdated
Comment thread stl/inc/algorithm Outdated
Comment thread stl/inc/algorithm Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
@CaseyCarter

Copy link
Copy Markdown
Contributor

Casey Carter (@CaseyCarter): Any good idea on how to test which implementation is actually used? I thought about counting inside the projection if the projected object lies within input or output or somewhere else. But that does not fully work because some of the combinations of the store path trigger the higher ones.

I recommend embracing that fact that each of the generator templates is going to generate cases that are handled by each of the three backends in the algorithm. Analyze instantiator::call's template parameters to determine which backend will be used, and then verify that it is.

Comment thread stl/inc/algorithm Outdated
Comment thread stl/inc/algorithm Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Comment thread tests/std/test.lst Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated

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.

LGTM after addressing Stephan's comments.

Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
@miscco

Copy link
Copy Markdown
Contributor Author

hiss at clang

I guess we should limit some of the instantiations here

@miscco

Copy link
Copy Markdown
Contributor Author

So ranges::unique_copy should be ready to go.

ranges::unique: I got an ICE for you...

@miscco

Michael Schellenberger Costa (miscco) commented Jul 18, 2020

Copy link
Copy Markdown
Contributor Author

As far as I can tell the new unwrapping for continuous ranges leads to the ICE.

If i go back to b4fb1f9 and add that lines and the changes to _Seek_to I get the ICE

@miscco

Copy link
Copy Markdown
Contributor Author

ssiH at reverse

@CaseyCarter

Copy link
Copy Markdown
Contributor

As far as I can tell the new unwrapping for continuous ranges leads to the ICE.

Yes; I applied the if constexpr (!ranges::contiguous_range<ReadWrite>) workaround for VSO-938163 after observing the "all MSVC configs ICE" syndrome. In the unique_copy test, I simplified the projection counting by using the non-key pair member to store the count and split the iterator overload / range overload into separate instantions so TEST_EVERYTHING actually compiles.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good modulo two trivial nitpicks.

Comment thread tests/std/tests/P0896R4_ranges_alg_unique/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_ranges_alg_unique_copy/test.cpp Outdated
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
@CaseyCarter
Casey Carter (CaseyCarter) merged commit 28efc70 into microsoft:master Jul 27, 2020
@CaseyCarter

Copy link
Copy Markdown
Contributor

Thanks for your, err, one-of-a-kind contribution.

@CaseyCarter Casey Carter (CaseyCarter) removed their assignment Jul 27, 2020
Casey Carter (CaseyCarter) added a commit to CaseyCarter/STL that referenced this pull request Jul 28, 2020
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Co-authored-by: Casey Carter <Casey@Carter.net>
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