@@ -74,29 +74,42 @@ template <class... _Tp>
7474using __extract_last _LIBCPP_NODEBUG = __extract_last_impl<_Tp...>::type;
7575# endif
7676
77- template <class _Tp , class ... _Tail>
78- constexpr bool __derived_from_pack =
79- __derived_from_pack<_Tp, __extract_last<_Tail...>> && __derived_from_pack<_Tail...>;
77+ template <bool _Const, class ... _Tp>
78+ struct __all_but_first_model_sized_range ;
8079
81- template <class _Tp , class _IterCategory >
82- constexpr bool __derived_from_pack<_Tp, _IterCategory> = derived_from<_Tp, _IterCategory>;
80+ template <bool _Const, class _Head , class ... _Tail>
81+ struct __all_but_first_model_sized_range <_Const, _Head, _Tail...> {
82+ static constexpr bool value = (sized_range<__maybe_const<_Const, _Tail>> && ...);
83+ };
8384
84- template <class _View , class ... _Views>
85- struct __last_view : __last_view< _Views...> {} ;
85+ template <bool _Const , class ... _Views>
86+ concept __all_random_access = (random_access_range<__maybe_const<_Const, _Views>> && ...) ;
8687
87- template <class _View >
88- struct __last_view <_View> {
89- using type _LIBCPP_NODEBUG = _View;
90- };
88+ template <bool _Const, class ... _Views>
89+ concept __all_bidirectional = (bidirectional_range<__maybe_const<_Const, _Views>> && ...);
9190
92- template <bool _Const, class ... _Tp >
93- struct __apply_drop_first ;
91+ template <bool _Const, class ... _Views >
92+ concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...) ;
9493
95- template <bool _Const, class _Head , class ... _Tail>
96- struct __apply_drop_first <_Const, _Head, _Tail...> {
97- static constexpr bool value = (sized_range<__maybe_const<_Const, _Tail>> && ...);
94+ template <bool _Const, class _First , class ... _Tail>
95+ struct __all_common_ignore_last {
96+ static constexpr bool value =
97+ common_range<__maybe_const<_Const, _First>> && __all_common_ignore_last<_Const, _Tail...>::value;
98+ };
99+
100+ template <bool _Const, class _Tail >
101+ struct __all_common_ignore_last <_Const, _Tail> {
102+ static constexpr bool value = true ;
98103};
99104
105+ template <bool _Const, class ... _Rs>
106+ concept __concat_is_random_access =
107+ (__all_random_access<_Const, _Rs...>) && (__all_common_ignore_last<_Const, _Rs...>::value);
108+
109+ template <bool _Const, class ... _Rs>
110+ concept __concat_is_bidirectional =
111+ (__all_bidirectional<_Const, _Rs...>) && (__all_common_ignore_last<_Const, _Rs...>::value);
112+
100113template <input_range... _Views>
101114 requires (view<_Views> && ...) && (sizeof ...(_Views) > 0 ) && __concatable<_Views...>
102115class concat_view : public view_interface <concat_view<_Views...>> {
@@ -129,7 +142,7 @@ class concat_view : public view_interface<concat_view<_Views...>> {
129142 _LIBCPP_HIDE_FROM_ABI constexpr auto end ()
130143 requires(!(__simple_view<_Views> && ...))
131144 {
132- if constexpr (common_range<__maybe_const<false , typename __last_view <_Views...>::type >>) {
145+ if constexpr (common_range<__maybe_const<false , __extract_last <_Views...>>>) {
133146 constexpr auto __n = sizeof ...(_Views);
134147 return __iterator<false >(this , in_place_index<__n - 1 >, ranges::end (std::get<__n - 1 >(__views_)));
135148 } else {
@@ -140,7 +153,7 @@ class concat_view : public view_interface<concat_view<_Views...>> {
140153 _LIBCPP_HIDE_FROM_ABI constexpr auto end () const
141154 requires(range<const _Views> && ...)
142155 {
143- if constexpr (common_range<__maybe_const<true , typename __last_view <_Views...>::type >>) {
156+ if constexpr (common_range<__maybe_const<true , __extract_last <_Views...>>>) {
144157 constexpr auto __n = sizeof ...(_Views);
145158 return __iterator<true >(this , in_place_index<__n - 1 >, ranges::end (std::get<__n - 1 >(__views_)));
146159 } else {
@@ -176,14 +189,14 @@ template <bool _Const, typename... _Views>
176189struct __concat_view_iterator_category <_Const, _Views...> {
177190private:
178191 constexpr static bool __derive_pack_random_iterator =
179- __derived_from_pack <typename iterator_traits<iterator_t <__maybe_const<_Const, _Views>>>::iterator_category... ,
180- random_access_iterator_tag>;
192+ (derived_from <typename iterator_traits<iterator_t <__maybe_const<_Const, _Views>>>::iterator_category,
193+ random_access_iterator_tag> && ...) ;
181194 constexpr static bool __derive_pack_bidirectional_iterator =
182- __derived_from_pack <typename iterator_traits<iterator_t <__maybe_const<_Const, _Views>>>::iterator_category... ,
183- bidirectional_iterator_tag>;
195+ (derived_from <typename iterator_traits<iterator_t <__maybe_const<_Const, _Views>>>::iterator_category,
196+ bidirectional_iterator_tag> && ...) ;
184197 constexpr static bool __derive_pack_forward_iterator =
185- __derived_from_pack <typename iterator_traits< iterator_t <__maybe_const<_Const, _Views>>>::iterator_category... ,
186- forward_iterator_tag>;
198+ (derived_from <typename iterator_traits< iterator_t <__maybe_const<_Const, _Views>>>::iterator_category,
199+ forward_iterator_tag> && ...) ;
187200
188201public:
189202 using iterator_category =
@@ -573,7 +586,7 @@ class concat_view<_Views...>::__iterator : public __concat_view_iterator_categor
573586 _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator -(const __iterator& __x, default_sentinel_t )
574587 requires (sized_sentinel_for<sentinel_t <__maybe_const<_Const, _Views>>, iterator_t <__maybe_const<_Const, _Views>>> &&
575588 ...) &&
576- (__apply_drop_first <_Const, _Views...>::value)
589+ (__all_but_first_model_sized_range <_Const, _Views...>::value)
577590 {
578591 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (
579592 !__x.__it_ .valueless_by_exception (),
@@ -595,7 +608,7 @@ class concat_view<_Views...>::__iterator : public __concat_view_iterator_categor
595608 _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator -(default_sentinel_t , const __iterator& __x)
596609 requires (sized_sentinel_for<sentinel_t <__maybe_const<_Const, _Views>>, iterator_t <__maybe_const<_Const, _Views>>> &&
597610 ...) &&
598- (__apply_drop_first <_Const, _Views...>::value)
611+ (__all_but_first_model_sized_range <_Const, _Views...>::value)
599612 {
600613 return -(__x - default_sentinel);
601614 }
0 commit comments