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

Implement views::all and views::reverse #1229

Merged
merged 11 commits into from
Sep 1, 2020
3 changes: 2 additions & 1 deletion stl/inc/concepts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ namespace ranges {
};
} // namespace _Swap

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Swap::_Cpo swap;
}
using namespace _Cpos;
} // namespace ranges

// CONCEPT swappable
Expand Down
390 changes: 388 additions & 2 deletions stl/inc/ranges

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions stl/inc/xstring
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ public:
constexpr _String_view_iterator& operator+=(const difference_type _Off) noexcept {
#if _ITERATOR_DEBUG_LEVEL >= 1
_Verify_offset(_Off);
_Myoff += _Off;
_Myoff += static_cast<size_t>(_Off);
#else // ^^^ _ITERATOR_DEBUG_LEVEL >= 1 ^^^ // vvv _ITERATOR_DEBUG_LEVEL == 0 vvv
_Myptr += _Off;
#endif // _ITERATOR_DEBUG_LEVEL
Expand Down Expand Up @@ -1077,7 +1077,7 @@ public:
"cannot seek string_view iterator after end");
}

_Myoff -= _Off;
_Myoff -= static_cast<size_t>(_Off);
#else // ^^^ _ITERATOR_DEBUG_LEVEL >= 1 ^^^ // vvv _ITERATOR_DEBUG_LEVEL == 0 vvv
_Myptr -= _Off;
#endif // _ITERATOR_DEBUG_LEVEL
Expand Down
63 changes: 42 additions & 21 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ struct iterator_traits<_Ty*> {
};
// clang-format on

// CUSTOMIZATION POINT OBJECT iter_move
// CUSTOMIZATION POINT OBJECT ranges::iter_move
namespace ranges {
// STRUCT TEMPLATE _Choice_t
template <class _Ty>
Expand Down Expand Up @@ -707,9 +707,10 @@ namespace ranges {
// clang-format on
} // namespace _Iter_move

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Iter_move::_Cpo iter_move;
}
using namespace _Cpos;
} // namespace ranges

// iter_swap defined below since it depends on indirectly_movable_storable
Expand Down Expand Up @@ -1017,7 +1018,7 @@ concept indirectly_copyable_storable = indirectly_copyable<_In, _Out>
&& assignable_from<iter_value_t<_In>&, iter_reference_t<_In>>;
// clang-format on

// CUSTOMIZATION POINT OBJECT iter_swap
// CUSTOMIZATION POINT OBJECT ranges::iter_swap
namespace ranges {
namespace _Iter_swap {
template <class _Ty1, class _Ty2>
Expand Down Expand Up @@ -1091,9 +1092,10 @@ namespace ranges {
};
} // namespace _Iter_swap

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Iter_swap::_Cpo iter_swap;
}
using namespace _Cpos;
} // namespace ranges

// clang-format off
Expand Down Expand Up @@ -2408,9 +2410,10 @@ namespace ranges {
};
} // namespace _Begin

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Begin::_Cpo begin;
}
using namespace _Cpos;

// ALIAS TEMPLATE ranges::iterator_t
template <class _Ty>
Expand Down Expand Up @@ -2468,9 +2471,10 @@ namespace ranges {
};
} // namespace _Unchecked_begin

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Unchecked_begin::_Cpo _Ubegin;
}
using namespace _Cpos;

// CUSTOMIZATION POINT OBJECT ranges::end
namespace _End {
Expand Down Expand Up @@ -2542,9 +2546,10 @@ namespace ranges {
};
} // namespace _End

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _End::_Cpo end;
}
using namespace _Cpos;

// CUSTOMIZATION POINT OBJECT ranges::_Uend
namespace _Unchecked_end {
Expand Down Expand Up @@ -2599,9 +2604,10 @@ namespace ranges {
};
} // namespace _Unchecked_end

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Unchecked_end::_Cpo _Uend;
}
using namespace _Cpos;

// CONCEPT ranges::range
template <class _Rng>
Expand Down Expand Up @@ -2648,9 +2654,10 @@ namespace ranges {
// clang-format on
};

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Cbegin_fn cbegin;
}
using namespace _Cpos;

// CUSTOMIZATION POINT OBJECT ranges::cend
struct _Cend_fn {
Expand All @@ -2664,9 +2671,10 @@ namespace ranges {
// clang-format on
};

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Cend_fn cend;
}
using namespace _Cpos;

// CUSTOMIZATION POINT OBJECT ranges::rbegin
namespace _Rbegin {
Expand Down Expand Up @@ -2733,9 +2741,10 @@ namespace ranges {
};
} // namespace _Rbegin

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Rbegin::_Cpo rbegin;
}
using namespace _Cpos;

// CUSTOMIZATION POINT OBJECT ranges::rend
namespace _Rend {
Expand Down Expand Up @@ -2803,9 +2812,10 @@ namespace ranges {
};
} // namespace _Rend

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Rend::_Cpo rend;
}
using namespace _Cpos;

// CUSTOMIZATION POINT OBJECT ranges::crbegin
struct _Crbegin_fn {
Expand All @@ -2819,9 +2829,10 @@ namespace ranges {
// clang-format on
};

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Crbegin_fn crbegin;
}
using namespace _Cpos;

// CUSTOMIZATION POINT OBJECT ranges::crend
struct _Crend_fn {
Expand All @@ -2835,9 +2846,10 @@ namespace ranges {
// clang-format on
};

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Crend_fn crend;
}
using namespace _Cpos;

// VARIABLE TEMPLATE ranges::disable_sized_range
template <class>
Expand Down Expand Up @@ -2921,9 +2933,10 @@ namespace ranges {
};
} // namespace _Size

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Size::_Cpo size;
}
using namespace _Cpos;

// CUSTOMIZATION POINT OBJECT ranges::empty
namespace _Empty {
Expand Down Expand Up @@ -2989,9 +3002,10 @@ namespace ranges {
};
} // namespace _Empty

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Empty::_Cpo empty;
}
using namespace _Cpos;

// CUSTOMIZATION POINT OBJECT ranges::data
namespace _Data {
Expand Down Expand Up @@ -3046,9 +3060,10 @@ namespace ranges {
};
} // namespace _Data

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Data::_Cpo data;
}
using namespace _Cpos;

// CUSTOMIZATION POINT OBJECT ranges::cdata
struct _Cdata_fn {
Expand All @@ -3062,9 +3077,10 @@ namespace ranges {
// clang-format on
};

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Cdata_fn cdata;
}
using namespace _Cpos;

// clang-format off
// CONCEPT ranges::sized_range
Expand Down Expand Up @@ -3289,9 +3305,10 @@ namespace ranges {
// clang-format on
};

inline namespace _Cpos {
namespace _Cpos {
inline constexpr _Ssize_fn ssize;
}
using namespace _Cpos;

// VARIABLE ranges::next
class _Next_fn : private _Not_quite_object {
Expand Down Expand Up @@ -3584,7 +3601,9 @@ namespace ranges {
auto& _Self = _Cast();
#if _CONTAINER_DEBUG_LEVEL > 0
if constexpr (sized_range<_Derived>) {
_STL_VERIFY(_Idx < _RANGES size(_Self), "index out of range for view_interface");
using _U_diff = _Make_unsigned_like_t<range_difference_t<_Rng>>;
_STL_VERIFY(static_cast<_U_diff>(_Idx) < static_cast<_U_diff>(_RANGES size(_Self)),
"index out of range for view_interface");
}
#endif // _CONTAINER_DEBUG_LEVEL > 0
return _RANGES begin(_Self)[_Idx];
Expand All @@ -3595,7 +3614,9 @@ namespace ranges {
auto& _Self = _Cast();
#if _CONTAINER_DEBUG_LEVEL > 0
if constexpr (sized_range<_Derived>) {
_STL_VERIFY(_Idx < _RANGES size(_Self), "index out of range for view_interface");
using _U_diff = _Make_unsigned_like_t<range_difference_t<_Rng>>;
_STL_VERIFY(static_cast<_U_diff>(_Idx) < static_cast<_U_diff>(_RANGES size(_Self)),
"index out of range for view_interface");
}
#endif // _CONTAINER_DEBUG_LEVEL > 0
return _RANGES begin(_Self)[_Idx];
Expand Down
Loading