Skip to content
Open
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
36 changes: 28 additions & 8 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -2605,30 +2605,50 @@ public:
return _Current <=> _Right;
}

template <_Not_a_const_iterator _Other>
template <_Not_a_const_iterator _Other, same_as<_Iter> _Jter
#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-11111696
,
_Iter* = nullptr
#endif // ^^^ workaround ^^^
>
requires random_access_iterator<_Iter> && totally_ordered_with<_Iter, _Other>
_NODISCARD friend constexpr bool operator<(const _Other& _Left, const basic_const_iterator& _Right)
_NODISCARD friend constexpr bool operator<(const _Other& _Left, const basic_const_iterator<_Jter>& _Right)
noexcept(noexcept(_STD _Fake_copy_init<bool>(_Left < _Right._Current))) /* strengthened */ {
return _Left < _Right._Current;
}

template <_Not_a_const_iterator _Other>
template <_Not_a_const_iterator _Other, same_as<_Iter> _Jter
#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-11111696
,
_Iter* = nullptr
#endif // ^^^ workaround ^^^
>
requires random_access_iterator<_Iter> && totally_ordered_with<_Iter, _Other>
_NODISCARD friend constexpr bool operator>(const _Other& _Left, const basic_const_iterator& _Right)
_NODISCARD friend constexpr bool operator>(const _Other& _Left, const basic_const_iterator<_Jter>& _Right)
noexcept(noexcept(_STD _Fake_copy_init<bool>(_Left > _Right._Current))) /* strengthened */ {
return _Left > _Right._Current;
}

template <_Not_a_const_iterator _Other>
template <_Not_a_const_iterator _Other, same_as<_Iter> _Jter
#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-11111696
,
_Iter* = nullptr
#endif // ^^^ workaround ^^^
>
requires random_access_iterator<_Iter> && totally_ordered_with<_Iter, _Other>
_NODISCARD friend constexpr bool operator<=(const _Other& _Left, const basic_const_iterator& _Right)
_NODISCARD friend constexpr bool operator<=(const _Other& _Left, const basic_const_iterator<_Jter>& _Right)
noexcept(noexcept(_STD _Fake_copy_init<bool>(_Left <= _Right._Current))) /* strengthened */ {
return _Left <= _Right._Current;
}

template <_Not_a_const_iterator _Other>
template <_Not_a_const_iterator _Other, same_as<_Iter> _Jter
#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-11111696
,
_Iter* = nullptr
#endif // ^^^ workaround ^^^
>
requires random_access_iterator<_Iter> && totally_ordered_with<_Iter, _Other>
_NODISCARD friend constexpr bool operator>=(const _Other& _Left, const basic_const_iterator& _Right)
_NODISCARD friend constexpr bool operator>=(const _Other& _Left, const basic_const_iterator<_Jter>& _Right)
noexcept(noexcept(_STD _Fake_copy_init<bool>(_Left >= _Right._Current))) /* strengthened */ {
return _Left >= _Right._Current;
}
Expand Down
26 changes: 26 additions & 0 deletions tests/std/tests/P2278R4_basic_const_iterator/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,32 @@ static constexpr int some_ints[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
using Zipped = decltype(views::zip(some_ints) | views::as_const | views::as_rvalue);
static_assert(same_as<ranges::range_reference_t<Zipped>, tuple<const int&&>>);

// LWG-4218 "Constraint recursion in basic_const_iterator's relational operators due to ADL + CWG 2369"
namespace lwg_4218 {
template <class T>
struct adl_conversion_source {
operator T() const;

friend bool operator==(const adl_conversion_source&, const adl_conversion_source&) {
return true;
}
friend bool operator==(const adl_conversion_source&, const T&) {
return true;
}

template <same_as<adl_conversion_source> Self>
friend partial_ordering operator<=>(const adl_conversion_source&, const Self&) {
return partial_ordering::equivalent;
}
};

using cvi = basic_const_iterator<vector<int>::iterator>;
static_assert(totally_ordered_with<adl_conversion_source<cvi>, cvi>);

using rcvi = reverse_iterator<cvi>;
static_assert(totally_ordered<rcvi>);
} // namespace lwg_4218

struct instantiator {
template <input_iterator It>
static constexpr void call() {
Expand Down