@@ -74,29 +74,42 @@ template <class... _Tp>
74
74
using __extract_last _LIBCPP_NODEBUG = __extract_last_impl<_Tp...>::type;
75
75
# endif
76
76
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 ;
80
79
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
+ };
83
84
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>> && ...) ;
86
87
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>> && ...);
91
90
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>> && ...) ;
94
93
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 ;
98
103
};
99
104
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
+
100
113
template <input_range... _Views>
101
114
requires (view<_Views> && ...) && (sizeof ...(_Views) > 0 ) && __concatable<_Views...>
102
115
class concat_view : public view_interface <concat_view<_Views...>> {
@@ -129,7 +142,7 @@ class concat_view : public view_interface<concat_view<_Views...>> {
129
142
_LIBCPP_HIDE_FROM_ABI constexpr auto end ()
130
143
requires(!(__simple_view<_Views> && ...))
131
144
{
132
- if constexpr (common_range<__maybe_const<false , typename __last_view <_Views...>::type >>) {
145
+ if constexpr (common_range<__maybe_const<false , __extract_last <_Views...>>>) {
133
146
constexpr auto __n = sizeof ...(_Views);
134
147
return __iterator<false >(this , in_place_index<__n - 1 >, ranges::end (std::get<__n - 1 >(__views_)));
135
148
} else {
@@ -140,7 +153,7 @@ class concat_view : public view_interface<concat_view<_Views...>> {
140
153
_LIBCPP_HIDE_FROM_ABI constexpr auto end () const
141
154
requires(range<const _Views> && ...)
142
155
{
143
- if constexpr (common_range<__maybe_const<true , typename __last_view <_Views...>::type >>) {
156
+ if constexpr (common_range<__maybe_const<true , __extract_last <_Views...>>>) {
144
157
constexpr auto __n = sizeof ...(_Views);
145
158
return __iterator<true >(this , in_place_index<__n - 1 >, ranges::end (std::get<__n - 1 >(__views_)));
146
159
} else {
@@ -176,14 +189,14 @@ template <bool _Const, typename... _Views>
176
189
struct __concat_view_iterator_category <_Const, _Views...> {
177
190
private:
178
191
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> && ...) ;
181
194
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> && ...) ;
184
197
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> && ...) ;
187
200
188
201
public:
189
202
using iterator_category =
@@ -573,7 +586,7 @@ class concat_view<_Views...>::__iterator : public __concat_view_iterator_categor
573
586
_LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator -(const __iterator& __x, default_sentinel_t )
574
587
requires (sized_sentinel_for<sentinel_t <__maybe_const<_Const, _Views>>, iterator_t <__maybe_const<_Const, _Views>>> &&
575
588
...) &&
576
- (__apply_drop_first <_Const, _Views...>::value)
589
+ (__all_but_first_model_sized_range <_Const, _Views...>::value)
577
590
{
578
591
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (
579
592
!__x.__it_ .valueless_by_exception (),
@@ -595,7 +608,7 @@ class concat_view<_Views...>::__iterator : public __concat_view_iterator_categor
595
608
_LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator -(default_sentinel_t , const __iterator& __x)
596
609
requires (sized_sentinel_for<sentinel_t <__maybe_const<_Const, _Views>>, iterator_t <__maybe_const<_Const, _Views>>> &&
597
610
...) &&
598
- (__apply_drop_first <_Const, _Views...>::value)
611
+ (__all_but_first_model_sized_range <_Const, _Views...>::value)
599
612
{
600
613
return -(__x - default_sentinel);
601
614
}
0 commit comments