Skip to content

Conversation

hewillk
Copy link
Contributor

@hewillk hewillk commented Jul 26, 2024

Explicit casting of the result of ranges::size is too verbose; simply comparing the values ​​of ranges::distance is sufficient as they are guaranteed to be signed integers.
This aligns with the implementation in ranges::is_permutation:

STL/stl/inc/algorithm

Lines 1084 to 1088 in 8657d15

if constexpr (sized_range<_Rng1> && sized_range<_Rng2>) {
const auto _Count = _RANGES distance(_Range1);
if (_RANGES distance(_Range2) != _Count) {
return false;
}

@hewillk hewillk requested a review from a team as a code owner July 26, 2024 15:44
@StephanTLavavej StephanTLavavej added enhancement Something can be improved ranges C++20/23 ranges labels Jul 30, 2024
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit bdcd8ea into microsoft:main Aug 8, 2024
@StephanTLavavej
Copy link
Member

Thanks for this nice simplification! 🪄 😸 🐈‍⬛

@hewillk hewillk deleted the main-size branch August 8, 2024 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved ranges C++20/23 ranges
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants