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
30 changes: 13 additions & 17 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -2576,16 +2576,19 @@ namespace ranges {
public:
using _Not_quite_object::_Not_quite_object;

template <class _It, sentinel_for<decay_t<_It>> _Se>
_NODISCARD constexpr iter_difference_t<decay_t<_It>> operator()(_It&& _Raw_first, _Se _Last) const
noexcept(_Nothrow_dist<_It, _Se>) /* strengthened */ {
if constexpr (sized_sentinel_for<_Se, decay_t<_It>>) {
return _Last - static_cast<const decay_t<_It>&>(_Raw_first); // Per LWG-3664
} else {
auto _First = _STD forward<_It>(_Raw_first);
_Adl_verify_range(_First, _Last);
return _Distance_unchecked(_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)));
}
template <class _It, sentinel_for<_It> _Se>
requires(!sized_sentinel_for<_Se, _It>)
_NODISCARD constexpr iter_difference_t<_It> operator()(_It _First, _Se _Last) const
Comment thread
StephanTLavavej marked this conversation as resolved.
noexcept(noexcept(_Distance_unchecked(_Get_unwrapped(_STD move(_First)),
_Get_unwrapped(_STD move(_Last))))) /* strengthened */ { // Per LWG-3664
_Adl_verify_range(_First, _Last);
return _Distance_unchecked(_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)));
}

template <class _It, sized_sentinel_for<decay_t<_It>> _Se>
_NODISCARD constexpr iter_difference_t<decay_t<_It>> operator()(_It&& _First, const _Se _Last) const
noexcept(noexcept(_Last - static_cast<const decay_t<_It>&>(_First))) /* strengthened */ { // Per LWG-3664
return _Last - static_cast<const decay_t<_It>&>(_First);
}

template <range _Rng>
Expand All @@ -2599,13 +2602,6 @@ namespace ranges {
}

private:
template <class _It, class _Se>
static constexpr bool _Nothrow_dist = false;

template <class _It, sized_sentinel_for<decay_t<_It>> _Se>
static constexpr bool _Nothrow_dist<_It, _Se> = noexcept(
_STD declval<_Se&>() - _STD declval<const decay_t<_It>&>());

template <class _It, class _Se>
_NODISCARD static constexpr iter_difference_t<_It> _Distance_unchecked(_It _First, const _Se _Last) noexcept(
noexcept(++_First != _Last)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2959,7 +2959,7 @@ namespace iter_ops {
trace t{};
I first{t};
same_as<iter_difference_t<I>> auto const result = distance(move(first), default_sentinel);
STATIC_ASSERT(!noexcept(distance(move(first), default_sentinel))); // No conditional noexcept
STATIC_ASSERT(noexcept(distance(move(first), default_sentinel)));
assert(result == sentinel_position);
assert((t == trace{.compares_ = sentinel_position + 1, .increments_ = sentinel_position}));
}
Expand Down