diff --git a/stl/inc/__msvc_iter_core.hpp b/stl/inc/__msvc_iter_core.hpp index cfcd369c848..d79d5db7777 100644 --- a/stl/inc/__msvc_iter_core.hpp +++ b/stl/inc/__msvc_iter_core.hpp @@ -406,7 +406,8 @@ concept input_or_output_iterator = requires(_It __i) { } && weakly_incrementable<_It>; _EXPORT_STD template -concept sentinel_for = semiregular<_Se> && input_or_output_iterator<_It> && _Weakly_equality_comparable_with<_Se, _It>; +concept sentinel_for = semiregular<_Se> && !_Integer_like<_Se> && input_or_output_iterator<_It> + && _Weakly_equality_comparable_with<_Se, _It>; _EXPORT_STD template // specializations allowed by N5014 [iterator.concept.sizedsentinel]/3 constexpr bool disable_sized_sentinel_for = false; diff --git a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp index 52e55ab8a12..f9f9320da2e 100644 --- a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp +++ b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include <__msvc_int128.hpp> #include #include #include @@ -3677,6 +3678,33 @@ namespace lwg3420 { static_assert(!has_member_value_type>); } // namespace lwg3420 +namespace lwg4510 { + // Test LWG-4510 + // "Ambiguity of std::ranges::advance and std::ranges::next when the difference type is also a sentinel type" + template + struct IterType { + using difference_type = int; + + IterType& operator++(); + IterType operator++(int); + IterType& operator*() const; + + friend bool operator==(const IterType&, const IterType&); + }; + + struct AnyType { + template + AnyType(const T&); + + friend bool operator==(const AnyType&, const AnyType&); + }; + + static_assert(std::input_or_output_iterator>); + static_assert(std::sentinel_for, IterType>); + static_assert(!std::sentinel_for>); + static_assert(!std::sentinel_for>); +} // namespace lwg4510 + namespace vso1121031 { // Validate that indirectly_readable_traits accepts type arguments with both value_type and element_type nested // types if they are consistent.