Skip to content
Closed
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
15 changes: 11 additions & 4 deletions stl/inc/filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -1455,8 +1455,10 @@ namespace filesystem {
_Path_iterator(const _Base_iter& _Position_, const path* _Mypath_) noexcept
: _Position(_Position_), _Element(), _Mypath(_Mypath_) {}

_Path_iterator(const _Base_iter& _Position_, wstring_view _Element_text, const path* _Mypath_)
: _Position(_Position_), _Element(_Element_text), _Mypath(_Mypath_) {}
_Path_iterator(const _Base_iter& _Position_, const path& _Element_, const path* _Mypath_)
: _Position(_Position_), _Element(_Element_), _Mypath(_Mypath_) {}
_Path_iterator(const _Base_iter& _Position_, path&& _Element_, const path* _Mypath_)
: _Position(_Position_), _Element(_STD move(_Element_)), _Mypath(_Mypath_) {}

_Path_iterator(const _Path_iterator&) = default;
_Path_iterator(_Path_iterator&&) = default;
Expand Down Expand Up @@ -1600,8 +1602,13 @@ namespace filesystem {
using _Prevent_inheriting_unwrap = _Path_iterator;

template <class _Iter2 = _Base_iter, enable_if_t<_Unwrappable_v<const _Iter2&>, int> = 0>
_NODISCARD _Path_iterator<_Unwrapped_t<const _Iter2&>> _Unwrapped() const {
return {_Position._Unwrapped(), _Element.native(), _Mypath};
_NODISCARD _Path_iterator<_Unwrapped_t<const _Iter2&>> _Unwrapped() const& noexcept(false) {
return {_Position._Unwrapped(), _Element, _Mypath};
}
template <class _Iter2 = _Base_iter, enable_if_t<_Unwrappable_v<_Iter2>, int> = 0>
_NODISCARD _Path_iterator<_Unwrapped_t<_Iter2>> _Unwrapped() && noexcept {
_STL_INTERNAL_STATIC_ASSERT(noexcept(_Is_nothrow_unwrappable_v<_Iter2>));
return {_Position._Unwrapped(), _STD move(_Element), _Mypath};
}

static constexpr bool _Unwrap_when_unverified = _Do_unwrap_when_unverified_v<_Base_iter>;
Expand Down
13 changes: 10 additions & 3 deletions stl/inc/iterator
Original file line number Diff line number Diff line change
Expand Up @@ -1371,12 +1371,19 @@ public:

using _Prevent_inheriting_unwrap = counted_iterator;

_NODISCARD constexpr counted_iterator<_Unwrapped_t<const _Iter&>>
_Unwrapped() const& requires _Unwrappable_v<const _Iter&> {
// clang-format off
_NODISCARD constexpr counted_iterator<_Unwrapped_t<const _Iter&>> _Unwrapped() const&
noexcept(noexcept(counted_iterator<_Unwrapped_t<const _Iter&>>{_Current._Unwrapped(), _Length}))
requires _Unwrappable_v<const _Iter&> {
// clang-format on
return counted_iterator<_Unwrapped_t<const _Iter&>>{_Current._Unwrapped(), _Length};
}

_NODISCARD constexpr counted_iterator<_Unwrapped_t<_Iter>> _Unwrapped() && requires _Unwrappable_v<_Iter> {
// clang-format off
_NODISCARD constexpr counted_iterator<_Unwrapped_t<_Iter>> _Unwrapped() &&
noexcept(noexcept(counted_iterator<_Unwrapped_t<_Iter>>{_STD move(_Current)._Unwrapped(), _Length}))
requires _Unwrappable_v<_Iter> {
// clang-format on
return counted_iterator<_Unwrapped_t<_Iter>>{_STD move(_Current)._Unwrapped(), _Length};
}

Expand Down
115 changes: 78 additions & 37 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -1917,24 +1917,26 @@ namespace ranges {
input_iterator_tag>;
};

template <bool _Const>
template <bool _Const, bool _Is_unwrapped = false>
class _Iterator : public _Category_base<_Const> {
private:
template <bool>
template <bool, bool>
friend class _Iterator;
template <bool>
friend class _Sentinel;

using _Parent_t = _Maybe_const<_Const, transform_view>;
using _Base = _Maybe_const<_Const, _Vw>;
using _Parent_t = _Maybe_const<_Const, transform_view>;
using _Base = _Maybe_const<_Const, _Vw>;
using _Base_iter = _Maybe_unwrapped_iterator_t<_Base, _Is_unwrapped>;

iterator_t<_Base> _Current{};
_Base_iter _Current{};
_Parent_t* _Parent{};

#if _ITERATOR_DEBUG_LEVEL != 0
constexpr void _Check_dereference() const noexcept {
_STL_VERIFY(_Parent != nullptr, "cannot dereference value-initialized transform_view iterator");
_STL_VERIFY(_Current != _RANGES end(_Parent->_Range), "cannot dereference end transform_view iterator");
_STL_VERIFY(_Current != _Get_maybe_unwrapped<_Is_unwrapped>(_RANGES end(_Parent->_Range)),
"cannot dereference end transform_view iterator");
}
#endif // _ITERATOR_DEBUG_LEVEL != 0

Expand All @@ -1952,32 +1954,33 @@ namespace ranges {
using difference_type = range_difference_t<_Base>;

// clang-format off
_Iterator() requires default_initializable<iterator_t<_Base>> = default;
_Iterator() requires default_initializable<_Base_iter> = default;
// clang-format on

constexpr _Iterator(_Parent_t& _Parent_, iterator_t<_Base> _Current_) noexcept(
is_nothrow_move_constructible_v<iterator_t<_Base>>) // strengthened
constexpr _Iterator(_Parent_t& _Parent_, _Base_iter _Current_) noexcept(
is_nothrow_move_constructible_v<_Base_iter>) // strengthened
: _Current{_STD move(_Current_)}, _Parent{_STD addressof(_Parent_)} {
#if _ITERATOR_DEBUG_LEVEL != 0
_Adl_verify_range(_Current, _RANGES end(_Parent_._Range));
_Adl_verify_range(_Current, _Get_maybe_unwrapped<_Is_unwrapped>(_RANGES end(_Parent_._Range)));
if constexpr (forward_range<_Base>) {
_Adl_verify_range(_RANGES begin(_Parent_._Range), _Current);
_Adl_verify_range(_Get_maybe_unwrapped<_Is_unwrapped>(_RANGES begin(_Parent_._Range)), _Current);
}
#endif // _ITERATOR_DEBUG_LEVEL != 0
}

// clang-format off
constexpr _Iterator(_Iterator<!_Const> _It)
noexcept(is_nothrow_constructible_v<iterator_t<_Base>, iterator_t<_Vw>>) // strengthened
requires _Const && convertible_to<iterator_t<_Vw>, iterator_t<_Base>>
constexpr _Iterator(_Iterator<!_Const, _Is_unwrapped> _It)
noexcept(is_nothrow_constructible_v<_Base_iter, _Base_iter>) // strengthened
requires _Const
&& convertible_to<_Maybe_unwrapped_iterator_t<_Vw, _Is_unwrapped>, _Base_iter>
: _Current{_STD move(_It._Current)}, _Parent{_It._Parent} {}
// clang-format on

_NODISCARD constexpr const iterator_t<_Base>& base() const& noexcept {
_NODISCARD constexpr const _Base_iter& base() const& noexcept {
return _Current;
}
_NODISCARD constexpr iterator_t<_Base> base() && noexcept(
is_nothrow_move_constructible_v<iterator_t<_Base>>) /* strengthened */ {
_NODISCARD constexpr _Base_iter base() && noexcept(
is_nothrow_move_constructible_v<_Base_iter>) /* strengthened */ {
return _STD move(_Current);
}

Expand All @@ -1994,16 +1997,16 @@ namespace ranges {
constexpr _Iterator& operator++() noexcept(noexcept(++_Current)) /* strengthened */ {
#if _ITERATOR_DEBUG_LEVEL != 0
_STL_VERIFY(_Parent != nullptr, "Cannot increment value-initialized transform_view iterator");
_STL_VERIFY(
_Current != _RANGES end(_Parent->_Range), "Cannot increment transform_view iterator past end");
_STL_VERIFY(_Current != _Get_maybe_unwrapped<_Is_unwrapped>(_RANGES end(_Parent->_Range)),
"Cannot increment transform_view iterator past end");
#endif // _ITERATOR_DEBUG_LEVEL != 0
++_Current;
return *this;
}

constexpr decltype(auto) operator++(int) noexcept(
noexcept(++_Current)
&& (!forward_range<_Base> || is_nothrow_copy_constructible_v<iterator_t<_Base>>) ) /* strengthened */ {
&& (!forward_range<_Base> || is_nothrow_copy_constructible_v<_Base_iter>) ) /* strengthened */ {
if constexpr (forward_range<_Base>) {
auto _Tmp = *this;
++*this;
Expand All @@ -2018,15 +2021,15 @@ namespace ranges {
#if _ITERATOR_DEBUG_LEVEL != 0
_STL_VERIFY(_Parent != nullptr, "Cannot decrement value-initialized transform_view iterator");
if constexpr (forward_range<_Vw>) {
_STL_VERIFY(_Current != _RANGES begin(_Parent->_Range),
_STL_VERIFY(_Current != _Get_maybe_unwrapped<_Is_unwrapped>(_RANGES begin(_Parent->_Range)),
"Cannot decrement transform_view iterator before begin");
}
#endif // _ITERATOR_DEBUG_LEVEL != 0
--_Current;
return *this;
}
constexpr _Iterator operator--(int) noexcept(
noexcept(--_Current) && is_nothrow_copy_constructible_v<iterator_t<_Base>>) /* strengthened */
noexcept(--_Current) && is_nothrow_copy_constructible_v<_Base_iter>) /* strengthened */
requires bidirectional_range<_Base> {
auto _Tmp = *this;
--*this;
Expand All @@ -2039,23 +2042,26 @@ namespace ranges {
#else // ^^^ _ITERATOR_DEBUG_LEVEL == 0 / _ITERATOR_DEBUG_LEVEL != 0 vvv
_STL_VERIFY(_Off == 0 || _Parent, "cannot seek value-initialized transform_view iterator");

if constexpr (_Offset_verifiable_v<iterator_t<_Base>>) {
if constexpr (_Offset_verifiable_v<_Base_iter>) {
_Current._Verify_offset(_Off);
} else {
if (_Off < 0) {
if constexpr (sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>) {
_STL_VERIFY(_Off >= _RANGES begin(_Parent->_Range) - _Current,
if constexpr (sized_sentinel_for<_Base_iter, _Base_iter>) {
_STL_VERIFY(
_Off >= _Get_maybe_unwrapped<_Is_unwrapped>(_RANGES begin(_Parent->_Range)) - _Current,
"cannot seek transform_view iterator before begin");
}
} else if (_Off > 0) {
if constexpr (sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base>>) {
_STL_VERIFY(_Off <= _RANGES end(_Parent->_Range) - _Current,
if constexpr (sized_sentinel_for<sentinel_t<_Base>, _Base_iter>) {
_STL_VERIFY(
_Off <= _Get_maybe_unwrapped<_Is_unwrapped>(_RANGES end(_Parent->_Range)) - _Current,
"cannot seek transform_view iterator after end");
} else if constexpr (sized_sentinel_for<iterator_t<_Base>,
iterator_t<_Base>> && sized_range<_Base>) {
} else if constexpr (sized_sentinel_for<_Base_iter, _Base_iter> && sized_range<_Base>) {
const auto _Size = _RANGES distance(_Parent->_Range);
_STL_VERIFY(_Off <= _Size - (_Current - _RANGES begin(_Parent->_Range)),
"cannot seek transform_view iterator after end");
const auto _Distance_to_begin =
_Current - _Get_maybe_unwrapped<_Is_unwrapped>(_RANGES begin(_Parent->_Range));

_STL_VERIFY(_Off <= _Size - _Distance_to_begin), "cannot seek transform_view iterator after end");
}
}
}
Expand Down Expand Up @@ -2091,8 +2097,8 @@ namespace ranges {
}

_NODISCARD_FRIEND constexpr bool operator==(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Left._Current
== _Right._Current)) /* strengthened */ requires equality_comparable<iterator_t<_Base>> {
noexcept(
_Left._Current == _Right._Current)) /* strengthened */ requires equality_comparable<_Base_iter> {
#if _ITERATOR_DEBUG_LEVEL != 0
_Left._Same_range(_Right);
#endif // _ITERATOR_DEBUG_LEVEL != 0
Expand Down Expand Up @@ -2121,7 +2127,7 @@ namespace ranges {
// clang-format off
_NODISCARD_FRIEND constexpr auto operator<=>(const _Iterator& _Left, const _Iterator& _Right) noexcept(
noexcept(_Left._Current <=> _Right._Current)) /* strengthened */
requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>> {
requires random_access_range<_Base> && three_way_comparable<_Base_iter> {
// clang-format on
#if _ITERATOR_DEBUG_LEVEL != 0
_Left._Same_range(_Right);
Expand Down Expand Up @@ -2157,12 +2163,41 @@ namespace ranges {

_NODISCARD_FRIEND constexpr difference_type operator-(const _Iterator& _Left,
const _Iterator& _Right) noexcept(noexcept(_Left._Current - _Right._Current)) /* strengthened */
requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>> {
requires sized_sentinel_for<_Base_iter, _Base_iter> {
#if _ITERATOR_DEBUG_LEVEL != 0
_Left._Same_range(_Right);
#endif // _ITERATOR_DEBUG_LEVEL != 0
return _Left._Current - _Right._Current;
}

using _Prevent_inheriting_unwrap =
conditional_t<!_Is_unwrapped && _Unwrappable_v<_Base_iter>, _Iterator, void>;

// clang-format off
constexpr _Iterator<_Const, true> _Unwrapped() const&
noexcept(noexcept(_Iterator<_Const, true>{*_Parent, _Current._Unwrapped()}))
requires _Unwrappable_v<const _Base_iter&>
{
// clang-format on
return _Iterator<_Const, true>{*_Parent, _Current._Unwrapped()};
}
// clang-format off
constexpr _Iterator<_Const, true> _Unwrapped() &&
noexcept(noexcept(_Iterator<_Const, true>{*_Parent, _STD move(_Current)._Unwrapped()}))
requires _Unwrappable_v<_Base_iter>
{
// clang-format on
return _Iterator<_Const, true>{*_Parent, _STD move(_Current)._Unwrapped()};
}

// clang-format off
constexpr void _Seek_to(_Iterator<_Const, true> _Other)
noexcept(noexcept(_Current._Seek_to(_Other._Current)))
requires _Unwrappable_v<_Base_iter>
{
// clang-format on
_Current._Seek_to(_Other._Current);
}
};

template <bool _Const>
Expand Down Expand Up @@ -2390,12 +2425,15 @@ namespace ranges {

// clang-format off
_NODISCARD constexpr auto _Unwrapped() const&
noexcept(noexcept(_Sentinel<_Const, false>{_Get_unwrapped(_Last)}))
requires _Wrapped && _Unwrappable_v<const iterator_t<_Base_t>&> {
// clang-format on
return _Sentinel<_Const, false>{_Get_unwrapped(_Last)};
}
// clang-format off
_NODISCARD constexpr auto _Unwrapped() && requires _Wrapped && _Unwrappable_v<iterator_t<_Base_t>> {
_NODISCARD constexpr auto _Unwrapped() &&
noexcept(noexcept(_Sentinel<_Const, false>{_Get_unwrapped(_STD move(_Last))}))
requires _Wrapped && _Unwrappable_v<iterator_t<_Base_t>> {
// clang-format on
return _Sentinel<_Const, false>{_Get_unwrapped(_STD move(_Last))};
}
Expand Down Expand Up @@ -2646,12 +2684,15 @@ namespace ranges {

// clang-format off
_NODISCARD constexpr auto _Unwrapped() const&
noexcept(noexcept(_Sentinel<_Const, false>{_Get_unwrapped(_Last), _Pred}))
requires _Wrapped && _Unwrappable_v<const iterator_t<_Base_t>&> {
// clang-format on
return _Sentinel<_Const, false>{_Get_unwrapped(_Last), _Pred};
}
// clang-format off
_NODISCARD constexpr auto _Unwrapped() && requires _Wrapped && _Unwrappable_v<iterator_t<_Base_t>> {
_NODISCARD constexpr auto _Unwrapped() &&
noexcept(noexcept(_Sentinel<_Const, false>{_Get_unwrapped(_STD move(_Last)), _Pred}))
requires _Wrapped && _Unwrappable_v<iterator_t<_Base_t>> {
// clang-format on
return _Sentinel<_Const, false>{_Get_unwrapped(_STD move(_Last)), _Pred};
}
Expand Down
Loading