Skip to content
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
3 changes: 2 additions & 1 deletion stl/inc/__msvc_iter_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ concept input_or_output_iterator = requires(_It __i) {
} && weakly_incrementable<_It>;

_EXPORT_STD template <class _Se, class _It>
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 <class _Se, class _It> // specializations allowed by N5014 [iterator.concept.sizedsentinel]/3
constexpr bool disable_sized_sentinel_for = false;
Expand Down
28 changes: 28 additions & 0 deletions tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <__msvc_int128.hpp>
#include <cassert>
#include <compare>
#include <concepts>
Expand Down Expand Up @@ -3677,6 +3678,33 @@ namespace lwg3420 {
static_assert(!has_member_value_type<std::iterator_traits<X>>);
} // 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 <class T>
struct IterType {
using difference_type = int;

IterType& operator++();
IterType operator++(int);
IterType& operator*() const;

friend bool operator==(const IterType&, const IterType&);
};

struct AnyType {
template <class T>
AnyType(const T&);

friend bool operator==(const AnyType&, const AnyType&);
};

static_assert(std::input_or_output_iterator<IterType<AnyType>>);
static_assert(std::sentinel_for<IterType<AnyType>, IterType<AnyType>>);
static_assert(!std::sentinel_for<int, IterType<AnyType>>);
static_assert(!std::sentinel_for<std::_Unsigned128, IterType<AnyType>>);
} // 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.
Expand Down