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

<ranges>: Fix ranges::equal for ranges with integer-class range_difference_t #3551

Merged
merged 3 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ _NODISCARD pair<_FwdIt1, _FwdIt2> mismatch(

#ifdef __cpp_lib_concepts
namespace ranges {
template <input_iterator _It1, input_iterator _It2, integral _Size, class _Pr, class _Pj1, class _Pj2>
template <input_iterator _It1, input_iterator _It2, _Integer_like _Size, class _Pr, class _Pj1, class _Pj2>
requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2>
_NODISCARD constexpr bool _Equal_count(
_It1 _First1, _It2 _First2, _Size _Count, _Pr _Pred, _Pj1 _Proj1, _Pj2 _Proj2) {
Expand Down
7 changes: 7 additions & 0 deletions tests/std/tests/P0896R4_ranges_alg_equal/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ constexpr void smoke_test() {
assert(!equal(begin(arr1), unreachable_sentinel, begin(arr2), end(arr2)));
assert(!equal(begin(arr1), end(arr1), begin(arr2), unreachable_sentinel));
}
#ifndef _M_CEE // TRANSITION, VSO-1666180
{
// Validate GH-3550: "<ranges>: ranges::equal does not work for ranges with integer-class range_difference_t"
auto v = ranges::subrange{std::views::iota(0ull, 10ull)} | std::views::drop(2);
assert(equal(v, v));
}
#endif // _M_CEE
}

int main() {
Expand Down