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>: Make views ADL-proof #4389

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
87 changes: 44 additions & 43 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -2217,9 +2217,9 @@ namespace ranges {
is_nothrow_move_constructible_v<iterator_t<_Vw>>) // strengthened
: _Current(_STD move(_Current_)), _Parent{_STD addressof(_Parent_)} {
#if _ITERATOR_DEBUG_LEVEL != 0
_Adl_verify_range(_Current, _RANGES end(_Parent_._Range));
_STD _Adl_verify_range(_Current, _RANGES end(_Parent_._Range));
if constexpr (forward_range<_Vw>) {
_Adl_verify_range(_RANGES begin(_Parent_._Range), _Current);
_STD _Adl_verify_range(_RANGES begin(_Parent_._Range), _Current);
}
#endif // _ITERATOR_DEBUG_LEVEL != 0
}
Expand Down Expand Up @@ -2324,7 +2324,7 @@ namespace ranges {
}

_NODISCARD constexpr bool _Equal(const sentinel_t<_Vw>& _Last) const
noexcept(noexcept(_Fake_copy_init<bool>(_Current == _Last))) {
noexcept(noexcept(_STD _Fake_copy_init<bool>(_Current == _Last))) {
return _Current == _Last;
}
};
Expand Down Expand Up @@ -2494,9 +2494,9 @@ namespace ranges {
is_nothrow_move_constructible_v<iterator_t<_Base>>) // strengthened
: _Current{_STD move(_Current_)}, _Parent{_STD addressof(_Parent_)} {
#if _ITERATOR_DEBUG_LEVEL != 0
_Adl_verify_range(_Current, _RANGES end(_Parent_._Range));
_STD _Adl_verify_range(_Current, _RANGES end(_Parent_._Range));
if constexpr (forward_range<_Base>) {
_Adl_verify_range(_RANGES begin(_Parent_._Range), _Current);
_STD _Adl_verify_range(_RANGES begin(_Parent_._Range), _Current);
}
#endif // _ITERATOR_DEBUG_LEVEL != 0
}
Expand Down Expand Up @@ -3752,8 +3752,8 @@ namespace ranges {
requires forward_range<_Base>
: _Mybase{_STD move(_Outer_)}, _Parent{_STD addressof(_Parent_)} {
#if _ITERATOR_DEBUG_LEVEL != 0
_Adl_verify_range(this->_Outer, _RANGES end(_Parent_._Range));
_Adl_verify_range(_RANGES begin(_Parent_._Range), this->_Outer);
_STD _Adl_verify_range(this->_Outer, _RANGES end(_Parent_._Range));
_STD _Adl_verify_range(_RANGES begin(_Parent_._Range), this->_Outer);
#endif // _ITERATOR_DEBUG_LEVEL != 0
_Satisfy();
}
Expand Down Expand Up @@ -3809,7 +3809,7 @@ namespace ranges {
_STL_VERIFY(_Get_outer() != _RANGES end(_Parent->_Range), "cannot dereference join_view end iterator");
sentinel_t<_InnerRng<_Const>> _Last;
if constexpr (_Deref_is_glvalue) {
_Last = _RANGES end(_As_lvalue(*_Get_outer()));
_Last = _RANGES end(_RANGES _As_lvalue(*_Get_outer()));
} else {
_Last = _RANGES end((*_Parent->_Inner)._Val);
}
Expand Down Expand Up @@ -3858,7 +3858,7 @@ namespace ranges {
constexpr _Iterator& operator++() {
auto& _Outer = _Get_outer();
if constexpr (_Deref_is_glvalue) {
if (++*_Inner == _RANGES end(_As_lvalue(*_Outer))) {
if (++*_Inner == _RANGES end(_RANGES _As_lvalue(*_Outer))) {
++_Outer;
_Satisfy();
}
Expand Down Expand Up @@ -3888,11 +3888,11 @@ namespace ranges {
auto& _Outer = _Get_outer();
if (_Outer == _RANGES end(_Parent->_Range)) {
--_Outer;
_Inner = _RANGES end(_As_lvalue(*_Outer));
_Inner = _RANGES end(_RANGES _As_lvalue(*_Outer));
}
while (*_Inner == _RANGES begin(_As_lvalue(*_Outer))) {
while (*_Inner == _RANGES begin(_RANGES _As_lvalue(*_Outer))) {
--_Outer;
*_Inner = _RANGES end(_As_lvalue(*_Outer));
*_Inner = _RANGES end(_RANGES _As_lvalue(*_Outer));
}
--*_Inner;
return *this;
Expand Down Expand Up @@ -3954,7 +3954,7 @@ namespace ranges {
template <bool _OtherConst>
requires sentinel_for<sentinel_t<_Base>, _Maybe_const_iter<_OtherConst>>
_NODISCARD constexpr bool _Equal(const _Iterator<_OtherConst>& _It) const
noexcept(noexcept(_Fake_copy_init<bool>(_It._Get_outer() == _Last))) {
noexcept(noexcept(_STD _Fake_copy_init<bool>(_It._Get_outer() == _Last))) {
return _It._Get_outer() == _Last;
}

Expand Down Expand Up @@ -4221,15 +4221,15 @@ namespace ranges {

_NODISCARD constexpr auto& _Update_inner() {
if constexpr (_Deref_is_glvalue) {
return _As_lvalue(*_Get_outer());
return _RANGES _As_lvalue(*_Get_outer());
} else {
return _Parent->_Inner._Emplace(_Construct_tag{}, _Get_outer())._Val;
}
}

_NODISCARD constexpr auto& _Get_inner() noexcept {
if constexpr (_Deref_is_glvalue) {
return _As_lvalue(*_Get_outer());
return _RANGES _As_lvalue(*_Get_outer());
} else {
return (*_Parent->_Inner)._Val;
}
Expand Down Expand Up @@ -4467,7 +4467,7 @@ namespace ranges {

template <bool _OtherConst>
_NODISCARD constexpr bool _Equal(const _Iterator<_OtherConst>& _It) const
noexcept(noexcept(_Fake_copy_init<bool>(_It._Get_outer() == _Last))) {
noexcept(noexcept(_STD _Fake_copy_init<bool>(_It._Get_outer() == _Last))) {
_STL_INTERNAL_STATIC_ASSERT(
sentinel_for<sentinel_t<_Base>, iterator_t<_Maybe_const<_OtherConst, _Vw>>>);
return _It._Get_outer() == _Last;
Expand Down Expand Up @@ -4693,7 +4693,7 @@ namespace ranges {
}

_NODISCARD constexpr bool _At_end() const
noexcept(noexcept(_Fake_copy_init<bool>(_Get_current() == _RANGES end(_Parent->_Range)))) {
noexcept(noexcept(_STD _Fake_copy_init<bool>(_Get_current() == _RANGES end(_Parent->_Range)))) {
return _Get_current() == _RANGES end(_Parent->_Range);
}

Expand Down Expand Up @@ -5113,7 +5113,7 @@ namespace ranges {
/* [[no_unique_address]] */ sentinel_t<_Vw> _Last{};

_NODISCARD constexpr bool _Equal(const _Iterator& _It) const
noexcept(noexcept(_Fake_copy_init<bool>(_It._Current == _Last))) {
noexcept(noexcept(_STD _Fake_copy_init<bool>(_It._Current == _Last))) {
return !_It._Trailing_empty && _It._Current == _Last;
}

Expand Down Expand Up @@ -6306,7 +6306,7 @@ namespace ranges {
template <bool _OtherConst>
requires sentinel_for<_Base_sentinel, iterator_t<_Maybe_const<_OtherConst, _Vw>>>
_NODISCARD constexpr bool _Equal(const _Iterator<_OtherConst>& _It) const
noexcept(noexcept(_Fake_copy_init<bool>(_It._Current == _End))) {
noexcept(noexcept(_STD _Fake_copy_init<bool>(_It._Current == _End))) {
return _It._Current == _End;
}

Expand Down Expand Up @@ -6850,38 +6850,38 @@ namespace ranges {
}

_NODISCARD_FRIEND constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current == _Right._Current))) /* strengthened */ {
noexcept(_STD _Fake_copy_init<bool>(_Left._Current == _Right._Current))) /* strengthened */ {
return _Left._Current == _Right._Current;
}

_NODISCARD_FRIEND constexpr bool operator==(const _Iterator& _Left, default_sentinel_t) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current == _Left._End))) /* strengthened */ {
noexcept(_STD _Fake_copy_init<bool>(_Left._Current == _Left._End))) /* strengthened */ {
return _Left._Current == _Left._End;
}

_NODISCARD_FRIEND constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current < _Right._Current))) /* strengthened */
noexcept(_STD _Fake_copy_init<bool>(_Left._Current < _Right._Current))) /* strengthened */
requires random_access_range<_Base>
{
return _Left._Current < _Right._Current;
}

_NODISCARD_FRIEND constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Right._Current < _Left._Current))) /* strengthened */
noexcept(_STD _Fake_copy_init<bool>(_Right._Current < _Left._Current))) /* strengthened */
requires random_access_range<_Base>
{
return _Right._Current < _Left._Current;
}

_NODISCARD_FRIEND constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(!(_Right._Current < _Left._Current)))) /* strengthened */
noexcept(_STD _Fake_copy_init<bool>(!(_Right._Current < _Left._Current)))) /* strengthened */
requires random_access_range<_Base>
{
return !(_Right._Current < _Left._Current);
}

_NODISCARD_FRIEND constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(!(_Left._Current < _Right._Current)))) /* strengthened */
noexcept(_STD _Fake_copy_init<bool>(!(_Left._Current < _Right._Current)))) /* strengthened */
requires random_access_range<_Base>
{
return !(_Left._Current < _Right._Current);
Expand Down Expand Up @@ -7209,7 +7209,7 @@ namespace ranges {
}

_NODISCARD_FRIEND constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current == _Right._Current))) /* strengthened */ {
noexcept(_STD _Fake_copy_init<bool>(_Left._Current == _Right._Current))) /* strengthened */ {
if constexpr (_Slide_caches_first<_Base>) {
return _Left._Last_element == _Right._Last_element;
} else {
Expand All @@ -7218,28 +7218,28 @@ namespace ranges {
}

_NODISCARD_FRIEND constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current < _Right._Current))) /* strengthened */
noexcept(_STD _Fake_copy_init<bool>(_Left._Current < _Right._Current))) /* strengthened */
requires random_access_range<_Base>
{
return _Left._Current < _Right._Current;
}

_NODISCARD_FRIEND constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Right._Current < _Left._Current))) /* strengthened */
noexcept(_STD _Fake_copy_init<bool>(_Right._Current < _Left._Current))) /* strengthened */
requires random_access_range<_Base>
{
return _Right._Current < _Left._Current;
}

_NODISCARD_FRIEND constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(!(_Right._Current < _Left._Current)))) /* strengthened */
noexcept(_STD _Fake_copy_init<bool>(!(_Right._Current < _Left._Current)))) /* strengthened */
requires random_access_range<_Base>
{
return !(_Right._Current < _Left._Current);
}

_NODISCARD_FRIEND constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(!(_Left._Current < _Right._Current)))) /* strengthened */
noexcept(_STD _Fake_copy_init<bool>(!(_Left._Current < _Right._Current)))) /* strengthened */
requires random_access_range<_Base>
{
return !(_Left._Current < _Right._Current);
Expand Down Expand Up @@ -7304,8 +7304,8 @@ namespace ranges {
_Sentinel() = default;

_NODISCARD_FRIEND constexpr bool
operator==(const _Iterator<false>& _Left, const _Sentinel& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Get_last_element() == _Right._Last))) /* strengthened */ {
operator==(const _Iterator<false>& _Left, const _Sentinel& _Right) noexcept(noexcept(
_STD _Fake_copy_init<bool>(_Left._Get_last_element() == _Right._Last))) /* strengthened */ {
return _Left._Get_last_element() == _Right._Last;
}

Expand Down Expand Up @@ -7557,12 +7557,12 @@ namespace ranges {
}

_NODISCARD_FRIEND constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current == _Right._Current))) /* strengthened */ {
noexcept(_STD _Fake_copy_init<bool>(_Left._Current == _Right._Current))) /* strengthened */ {
return _Left._Current == _Right._Current;
}

_NODISCARD_FRIEND constexpr bool operator==(const _Iterator& _Left, default_sentinel_t) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current == _Left._Next))) /* strengthened */ {
noexcept(_STD _Fake_copy_init<bool>(_Left._Current == _Left._Next))) /* strengthened */ {
return _Left._Current == _Left._Next;
}
};
Expand Down Expand Up @@ -7824,40 +7824,40 @@ namespace ranges {
}

_NODISCARD_FRIEND constexpr bool operator==(const _Iterator& _It, default_sentinel_t) noexcept(
noexcept(_Fake_copy_init<bool>(_It._Current == _It._End))) /* strengthened */ {
noexcept(_STD _Fake_copy_init<bool>(_It._Current == _It._End))) /* strengthened */ {
return _It._Current == _It._End;
}

_NODISCARD_FRIEND constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current == _Right._Current))) // strengthened
noexcept(_STD _Fake_copy_init<bool>(_Left._Current == _Right._Current))) // strengthened
requires equality_comparable<_Base_iterator>
{
return _Left._Current == _Right._Current;
}

_NODISCARD_FRIEND constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current < _Right._Current))) // strengthened
noexcept(_STD _Fake_copy_init<bool>(_Left._Current < _Right._Current))) // strengthened
requires random_access_range<_Base>
{
return _Left._Current < _Right._Current;
}

_NODISCARD_FRIEND constexpr bool operator>(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Right._Current < _Left._Current))) // strengthened
noexcept(_STD _Fake_copy_init<bool>(_Right._Current < _Left._Current))) // strengthened
requires random_access_range<_Base>
{
return _Right._Current < _Left._Current;
}

_NODISCARD_FRIEND constexpr bool operator<=(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(!(_Right._Current < _Left._Current)))) // strengthened
noexcept(_STD _Fake_copy_init<bool>(!(_Right._Current < _Left._Current)))) // strengthened
requires random_access_range<_Base>
{
return !(_Right._Current < _Left._Current);
}

_NODISCARD_FRIEND constexpr bool operator>=(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(!(_Left._Current < _Right._Current)))) // strengthened
noexcept(_STD _Fake_copy_init<bool>(!(_Left._Current < _Right._Current)))) // strengthened
requires random_access_range<_Base>
{
return !(_Left._Current < _Right._Current);
Expand Down Expand Up @@ -9126,12 +9126,13 @@ namespace ranges {
}

_NODISCARD_FRIEND constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current.back() == _Right._Current.back()))) /* strengthened */ {
noexcept(_STD _Fake_copy_init<bool>(_Left._Current.back() == _Right._Current.back()))) // strengthened
{
return _Left._Current.back() == _Right._Current.back();
}

_NODISCARD_FRIEND constexpr bool operator<(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Fake_copy_init<bool>(_Left._Current.back() < _Right._Current.back()))) // strengthened
noexcept(_STD _Fake_copy_init<bool>(_Left._Current.back() < _Right._Current.back()))) // strengthened
requires random_access_range<_Base>
{
return _Left._Current.back() < _Right._Current.back();
Expand Down Expand Up @@ -9236,7 +9237,7 @@ namespace ranges {
template <bool _OtherConst>
requires sentinel_for<_Base_sentinel, iterator_t<_Maybe_const<_OtherConst, _Vw>>>
_NODISCARD constexpr bool _Equal(const _Iterator<_OtherConst>& _It) const
noexcept(noexcept(_Fake_copy_init<bool>(_It._Current.back() == _End))) {
noexcept(noexcept(_STD _Fake_copy_init<bool>(_It._Current.back() == _End))) {
return _It._Current.back() == _End;
}

Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ tests\Dev11_1150223_shared_mutex
tests\Dev11_1158803_regex_thread_safety
tests\Dev11_1180290_filesystem_error_code
tests\GH_000140_adl_proof_comparison
tests\GH_000140_adl_proof_views
tests\GH_000177_forbidden_aliasing
tests\GH_000178_uniform_int
tests\GH_000342_filebuf_close
Expand Down
4 changes: 4 additions & 0 deletions tests/std/tests/GH_000140_adl_proof_views/env.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\strict_concepts_20_matrix.lst
Loading