2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
11 #define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
13 #include <__algorithm/unwrap_iter.h>
14 #include <__compare/compare_three_way_result.h>
15 #include <__compare/three_way_comparable.h>
16 #include <__concepts/convertible_to.h>
18 #include <__iterator/advance.h>
19 #include <__iterator/concepts.h>
20 #include <__iterator/incrementable_traits.h>
21 #include <__iterator/iter_move.h>
22 #include <__iterator/iter_swap.h>
23 #include <__iterator/iterator.h>
24 #include <__iterator/iterator_traits.h>
25 #include <__iterator/next.h>
26 #include <__iterator/prev.h>
27 #include <__iterator/readable_traits.h>
28 #include <__iterator/segmented_iterator.h>
29 #include <__memory/addressof.h>
30 #include <__ranges/access.h>
31 #include <__ranges/concepts.h>
32 #include <__ranges/subrange.h>
33 #include <__type_traits/conditional.h>
34 #include <__type_traits/enable_if.h>
35 #include <__type_traits/is_assignable.h>
36 #include <__type_traits/is_convertible.h>
37 #include <__type_traits/is_nothrow_copy_constructible.h>
38 #include <__type_traits/is_pointer.h>
39 #include <__type_traits/is_same.h>
40 #include <__utility/declval.h>
41 #include <__utility/move.h>
43 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
44 # pragma GCC system_header
47 _LIBCPP_BEGIN_NAMESPACE_STD
49 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
50 template <class _Iter
>
51 class _LIBCPP_TEMPLATE_VIS reverse_iterator
52 #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
53 : public iterator
<typename iterator_traits
<_Iter
>::iterator_category
,
54 typename iterator_traits
<_Iter
>::value_type
,
55 typename iterator_traits
<_Iter
>::difference_type
,
56 typename iterator_traits
<_Iter
>::pointer
,
57 typename iterator_traits
<_Iter
>::reference
>
60 _LIBCPP_SUPPRESS_DEPRECATED_POP
62 #ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
63 _Iter __t_
; // no longer used as of LWG #2360, not removed due to ABI break
66 #if _LIBCPP_STD_VER >= 20
67 static_assert(__has_bidirectional_iterator_category
<_Iter
>::value
|| bidirectional_iterator
<_Iter
>,
68 "reverse_iterator<It> requires It to be a bidirectional iterator.");
69 #endif // _LIBCPP_STD_VER >= 20
74 using iterator_type
= _Iter
;
76 using iterator_category
= _If
<__has_random_access_iterator_category
<_Iter
>::value
,
77 random_access_iterator_tag
,
78 typename iterator_traits
<_Iter
>::iterator_category
>;
79 using pointer
= typename iterator_traits
<_Iter
>::pointer
;
80 #if _LIBCPP_STD_VER >= 20
81 using iterator_concept
= _If
<random_access_iterator
<_Iter
>, random_access_iterator_tag
, bidirectional_iterator_tag
>;
82 using value_type
= iter_value_t
<_Iter
>;
83 using difference_type
= iter_difference_t
<_Iter
>;
84 using reference
= iter_reference_t
<_Iter
>;
86 using value_type
= typename iterator_traits
<_Iter
>::value_type
;
87 using difference_type
= typename iterator_traits
<_Iter
>::difference_type
;
88 using reference
= typename iterator_traits
<_Iter
>::reference
;
91 #ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
92 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
93 reverse_iterator() : __t_(), current() {}
95 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
96 explicit reverse_iterator(_Iter __x
) : __t_(__x
), current(__x
) {}
98 template <class _Up
, class = __enable_if_t
<
99 !is_same
<_Up
, _Iter
>::value
&& is_convertible
<_Up
const&, _Iter
>::value
101 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
102 reverse_iterator(const reverse_iterator
<_Up
>& __u
)
103 : __t_(__u
.base()), current(__u
.base())
106 template <class _Up
, class = __enable_if_t
<
107 !is_same
<_Up
, _Iter
>::value
&&
108 is_convertible
<_Up
const&, _Iter
>::value
&&
109 is_assignable
<_Iter
&, _Up
const&>::value
111 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
112 reverse_iterator
& operator=(const reverse_iterator
<_Up
>& __u
) {
113 __t_
= current
= __u
.base();
117 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
118 reverse_iterator() : current() {}
120 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
121 explicit reverse_iterator(_Iter __x
) : current(__x
) {}
123 template <class _Up
, class = __enable_if_t
<
124 !is_same
<_Up
, _Iter
>::value
&& is_convertible
<_Up
const&, _Iter
>::value
126 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
127 reverse_iterator(const reverse_iterator
<_Up
>& __u
)
128 : current(__u
.base())
131 template <class _Up
, class = __enable_if_t
<
132 !is_same
<_Up
, _Iter
>::value
&&
133 is_convertible
<_Up
const&, _Iter
>::value
&&
134 is_assignable
<_Iter
&, _Up
const&>::value
136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
137 reverse_iterator
& operator=(const reverse_iterator
<_Up
>& __u
) {
138 current
= __u
.base();
142 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
143 _Iter
base() const {return current
;}
144 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
145 reference
operator*() const {_Iter __tmp
= current
; return *--__tmp
;}
147 #if _LIBCPP_STD_VER >= 20
148 _LIBCPP_INLINE_VISIBILITY
149 constexpr pointer
operator->() const
150 requires is_pointer_v
<_Iter
> || requires(const _Iter __i
) { __i
.operator->(); }
152 if constexpr (is_pointer_v
<_Iter
>) {
153 return std::prev(current
);
155 return std::prev(current
).operator->();
159 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
160 pointer
operator->() const {
161 return std::addressof(operator*());
163 #endif // _LIBCPP_STD_VER >= 20
165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
166 reverse_iterator
& operator++() {--current
; return *this;}
167 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
168 reverse_iterator
operator++(int) {reverse_iterator
__tmp(*this); --current
; return __tmp
;}
169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
170 reverse_iterator
& operator--() {++current
; return *this;}
171 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
172 reverse_iterator
operator--(int) {reverse_iterator
__tmp(*this); ++current
; return __tmp
;}
173 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
174 reverse_iterator
operator+(difference_type __n
) const {return reverse_iterator(current
- __n
);}
175 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
176 reverse_iterator
& operator+=(difference_type __n
) {current
-= __n
; return *this;}
177 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
178 reverse_iterator
operator-(difference_type __n
) const {return reverse_iterator(current
+ __n
);}
179 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
180 reverse_iterator
& operator-=(difference_type __n
) {current
+= __n
; return *this;}
181 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
182 reference
operator[](difference_type __n
) const {return *(*this + __n
);}
184 #if _LIBCPP_STD_VER >= 20
185 _LIBCPP_HIDE_FROM_ABI
friend constexpr
186 iter_rvalue_reference_t
<_Iter
> iter_move(const reverse_iterator
& __i
)
187 noexcept(is_nothrow_copy_constructible_v
<_Iter
> &&
188 noexcept(ranges::iter_move(--std::declval
<_Iter
&>()))) {
189 auto __tmp
= __i
.base();
190 return ranges::iter_move(--__tmp
);
193 template <indirectly_swappable
<_Iter
> _Iter2
>
194 _LIBCPP_HIDE_FROM_ABI
friend constexpr
195 void iter_swap(const reverse_iterator
& __x
, const reverse_iterator
<_Iter2
>& __y
)
196 noexcept(is_nothrow_copy_constructible_v
<_Iter
> &&
197 is_nothrow_copy_constructible_v
<_Iter2
> &&
198 noexcept(ranges::iter_swap(--std::declval
<_Iter
&>(), --std::declval
<_Iter2
&>()))) {
199 auto __xtmp
= __x
.base();
200 auto __ytmp
= __y
.base();
201 ranges::iter_swap(--__xtmp
, --__ytmp
);
203 #endif // _LIBCPP_STD_VER >= 20
206 template <class _Iter1
, class _Iter2
>
207 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
209 operator==(const reverse_iterator
<_Iter1
>& __x
, const reverse_iterator
<_Iter2
>& __y
)
210 #if _LIBCPP_STD_VER >= 20
212 { __x
.base() == __y
.base() } -> convertible_to
<bool>;
214 #endif // _LIBCPP_STD_VER >= 20
216 return __x
.base() == __y
.base();
219 template <class _Iter1
, class _Iter2
>
220 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
222 operator<(const reverse_iterator
<_Iter1
>& __x
, const reverse_iterator
<_Iter2
>& __y
)
223 #if _LIBCPP_STD_VER >= 20
225 { __x
.base() > __y
.base() } -> convertible_to
<bool>;
227 #endif // _LIBCPP_STD_VER >= 20
229 return __x
.base() > __y
.base();
232 template <class _Iter1
, class _Iter2
>
233 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
235 operator!=(const reverse_iterator
<_Iter1
>& __x
, const reverse_iterator
<_Iter2
>& __y
)
236 #if _LIBCPP_STD_VER >= 20
238 { __x
.base() != __y
.base() } -> convertible_to
<bool>;
240 #endif // _LIBCPP_STD_VER >= 20
242 return __x
.base() != __y
.base();
245 template <class _Iter1
, class _Iter2
>
246 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
248 operator>(const reverse_iterator
<_Iter1
>& __x
, const reverse_iterator
<_Iter2
>& __y
)
249 #if _LIBCPP_STD_VER >= 20
251 { __x
.base() < __y
.base() } -> convertible_to
<bool>;
253 #endif // _LIBCPP_STD_VER >= 20
255 return __x
.base() < __y
.base();
258 template <class _Iter1
, class _Iter2
>
259 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
261 operator>=(const reverse_iterator
<_Iter1
>& __x
, const reverse_iterator
<_Iter2
>& __y
)
262 #if _LIBCPP_STD_VER >= 20
264 { __x
.base() <= __y
.base() } -> convertible_to
<bool>;
266 #endif // _LIBCPP_STD_VER >= 20
268 return __x
.base() <= __y
.base();
271 template <class _Iter1
, class _Iter2
>
272 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
274 operator<=(const reverse_iterator
<_Iter1
>& __x
, const reverse_iterator
<_Iter2
>& __y
)
275 #if _LIBCPP_STD_VER >= 20
277 { __x
.base() >= __y
.base() } -> convertible_to
<bool>;
279 #endif // _LIBCPP_STD_VER >= 20
281 return __x
.base() >= __y
.base();
284 #if _LIBCPP_STD_VER >= 20
285 template <class _Iter1
, three_way_comparable_with
<_Iter1
> _Iter2
>
286 _LIBCPP_HIDE_FROM_ABI
constexpr
287 compare_three_way_result_t
<_Iter1
, _Iter2
>
288 operator<=>(const reverse_iterator
<_Iter1
>& __x
, const reverse_iterator
<_Iter2
>& __y
)
290 return __y
.base() <=> __x
.base();
292 #endif // _LIBCPP_STD_VER >= 20
294 #ifndef _LIBCPP_CXX03_LANG
295 template <class _Iter1
, class _Iter2
>
296 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
298 operator-(const reverse_iterator
<_Iter1
>& __x
, const reverse_iterator
<_Iter2
>& __y
)
299 -> decltype(__y
.base() - __x
.base())
301 return __y
.base() - __x
.base();
304 template <class _Iter1
, class _Iter2
>
305 inline _LIBCPP_INLINE_VISIBILITY
306 typename reverse_iterator
<_Iter1
>::difference_type
307 operator-(const reverse_iterator
<_Iter1
>& __x
, const reverse_iterator
<_Iter2
>& __y
)
309 return __y
.base() - __x
.base();
313 template <class _Iter
>
314 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
315 reverse_iterator
<_Iter
>
316 operator+(typename reverse_iterator
<_Iter
>::difference_type __n
, const reverse_iterator
<_Iter
>& __x
)
318 return reverse_iterator
<_Iter
>(__x
.base() - __n
);
321 #if _LIBCPP_STD_VER >= 20
322 template <class _Iter1
, class _Iter2
>
323 requires (!sized_sentinel_for
<_Iter1
, _Iter2
>)
324 inline constexpr bool disable_sized_sentinel_for
<reverse_iterator
<_Iter1
>, reverse_iterator
<_Iter2
>> = true;
325 #endif // _LIBCPP_STD_VER >= 20
327 #if _LIBCPP_STD_VER >= 14
328 template <class _Iter
>
329 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
330 reverse_iterator
<_Iter
> make_reverse_iterator(_Iter __i
)
332 return reverse_iterator
<_Iter
>(__i
);
336 #if _LIBCPP_STD_VER <= 17
337 template <class _Iter
>
338 using __unconstrained_reverse_iterator
= reverse_iterator
<_Iter
>;
341 // __unconstrained_reverse_iterator allows us to use reverse iterators in the implementation of algorithms by working
342 // around a language issue in C++20.
343 // In C++20, when a reverse iterator wraps certain C++20-hostile iterators, calling comparison operators on it will
344 // result in a compilation error. However, calling comparison operators on the pristine hostile iterator is not
345 // an error. Thus, we cannot use reverse_iterators in the implementation of an algorithm that accepts a
346 // C++20-hostile iterator. This class is an internal workaround -- it is a copy of reverse_iterator with
347 // tweaks to make it support hostile iterators.
349 // A C++20-hostile iterator is one that defines a comparison operator where one of the arguments is an exact match
350 // and the other requires an implicit conversion, for example:
351 // friend bool operator==(const BaseIter&, const DerivedIter&);
353 // C++20 rules for rewriting equality operators create another overload of this function with parameters reversed:
354 // friend bool operator==(const DerivedIter&, const BaseIter&);
356 // This creates an ambiguity in overload resolution.
358 // Clang treats this ambiguity differently in different contexts. When operator== is actually called in the function
359 // body, the code is accepted with a warning. When a concept requires operator== to be a valid expression, however,
360 // it evaluates to false. Thus, the implementation of reverse_iterator::operator== can actually call operator== on its
361 // base iterators, but the constraints on reverse_iterator::operator== prevent it from being considered during overload
362 // resolution. This class simply removes the problematic constraints from comparison functions.
363 template <class _Iter
>
364 class __unconstrained_reverse_iterator
{
368 static_assert(__has_bidirectional_iterator_category
<_Iter
>::value
|| bidirectional_iterator
<_Iter
>);
370 using iterator_type
= _Iter
;
371 using iterator_category
=
372 _If
<__has_random_access_iterator_category
<_Iter
>::value
, random_access_iterator_tag
, __iterator_category_type
<_Iter
>>;
373 using pointer
= __iterator_pointer_type
<_Iter
>;
374 using value_type
= iter_value_t
<_Iter
>;
375 using difference_type
= iter_difference_t
<_Iter
>;
376 using reference
= iter_reference_t
<_Iter
>;
378 _LIBCPP_HIDE_FROM_ABI
constexpr __unconstrained_reverse_iterator() = default;
379 _LIBCPP_HIDE_FROM_ABI
constexpr __unconstrained_reverse_iterator(const __unconstrained_reverse_iterator
&) = default;
380 _LIBCPP_HIDE_FROM_ABI
constexpr explicit __unconstrained_reverse_iterator(_Iter __iter
) : __iter_(__iter
) {}
382 _LIBCPP_HIDE_FROM_ABI
constexpr _Iter
base() const { return __iter_
; }
383 _LIBCPP_HIDE_FROM_ABI
constexpr reference
operator*() const {
384 auto __tmp
= __iter_
;
388 _LIBCPP_HIDE_FROM_ABI
constexpr pointer
operator->() const {
389 if constexpr (is_pointer_v
<_Iter
>) {
390 return std::prev(__iter_
);
392 return std::prev(__iter_
).operator->();
396 _LIBCPP_HIDE_FROM_ABI
friend constexpr
397 iter_rvalue_reference_t
<_Iter
> iter_move(const __unconstrained_reverse_iterator
& __i
)
398 noexcept(is_nothrow_copy_constructible_v
<_Iter
> &&
399 noexcept(ranges::iter_move(--std::declval
<_Iter
&>()))) {
400 auto __tmp
= __i
.base();
401 return ranges::iter_move(--__tmp
);
404 _LIBCPP_HIDE_FROM_ABI
constexpr __unconstrained_reverse_iterator
& operator++() {
409 _LIBCPP_HIDE_FROM_ABI
constexpr __unconstrained_reverse_iterator
operator++(int) {
415 _LIBCPP_HIDE_FROM_ABI
constexpr __unconstrained_reverse_iterator
& operator--() {
420 _LIBCPP_HIDE_FROM_ABI
constexpr __unconstrained_reverse_iterator
operator--(int) {
426 _LIBCPP_HIDE_FROM_ABI
constexpr __unconstrained_reverse_iterator
& operator+=(difference_type __n
) {
431 _LIBCPP_HIDE_FROM_ABI
constexpr __unconstrained_reverse_iterator
& operator-=(difference_type __n
) {
436 _LIBCPP_HIDE_FROM_ABI
constexpr __unconstrained_reverse_iterator
operator+(difference_type __n
) const {
437 return __unconstrained_reverse_iterator(__iter_
- __n
);
440 _LIBCPP_HIDE_FROM_ABI
constexpr __unconstrained_reverse_iterator
operator-(difference_type __n
) const {
441 return __unconstrained_reverse_iterator(__iter_
+ __n
);
444 _LIBCPP_HIDE_FROM_ABI
constexpr difference_type
operator-(const __unconstrained_reverse_iterator
& __other
) const {
445 return __other
.__iter_
- __iter_
;
448 _LIBCPP_HIDE_FROM_ABI
constexpr auto operator[](difference_type __n
) const { return *(*this + __n
); }
450 // Deliberately unconstrained unlike the comparison functions in `reverse_iterator` -- see the class comment for the
452 _LIBCPP_HIDE_FROM_ABI
friend constexpr bool
453 operator==(const __unconstrained_reverse_iterator
& __lhs
, const __unconstrained_reverse_iterator
& __rhs
) {
454 return __lhs
.base() == __rhs
.base();
457 _LIBCPP_HIDE_FROM_ABI
friend constexpr bool
458 operator!=(const __unconstrained_reverse_iterator
& __lhs
, const __unconstrained_reverse_iterator
& __rhs
) {
459 return __lhs
.base() != __rhs
.base();
462 _LIBCPP_HIDE_FROM_ABI
friend constexpr bool
463 operator<(const __unconstrained_reverse_iterator
& __lhs
, const __unconstrained_reverse_iterator
& __rhs
) {
464 return __lhs
.base() > __rhs
.base();
467 _LIBCPP_HIDE_FROM_ABI
friend constexpr bool
468 operator>(const __unconstrained_reverse_iterator
& __lhs
, const __unconstrained_reverse_iterator
& __rhs
) {
469 return __lhs
.base() < __rhs
.base();
472 _LIBCPP_HIDE_FROM_ABI
friend constexpr bool
473 operator<=(const __unconstrained_reverse_iterator
& __lhs
, const __unconstrained_reverse_iterator
& __rhs
) {
474 return __lhs
.base() >= __rhs
.base();
477 _LIBCPP_HIDE_FROM_ABI
friend constexpr bool
478 operator>=(const __unconstrained_reverse_iterator
& __lhs
, const __unconstrained_reverse_iterator
& __rhs
) {
479 return __lhs
.base() <= __rhs
.base();
483 #endif // _LIBCPP_STD_VER <= 17
485 template <template <class> class _RevIter1
, template <class> class _RevIter2
, class _Iter
>
486 struct __unwrap_reverse_iter_impl
{
487 using _UnwrappedIter
= decltype(__unwrap_iter_impl
<_Iter
>::__unwrap(std::declval
<_Iter
>()));
488 using _ReverseWrapper
= _RevIter1
<_RevIter2
<_Iter
> >;
490 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper
491 __rewrap(_ReverseWrapper __orig_iter
, _UnwrappedIter __unwrapped_iter
) {
492 return _ReverseWrapper(
493 _RevIter2
<_Iter
>(__unwrap_iter_impl
<_Iter
>::__rewrap(__orig_iter
.base().base(), __unwrapped_iter
)));
496 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _UnwrappedIter
__unwrap(_ReverseWrapper __i
) _NOEXCEPT
{
497 return __unwrap_iter_impl
<_Iter
>::__unwrap(__i
.base().base());
501 #if _LIBCPP_STD_VER >= 20
502 template <ranges::bidirectional_range _Range
>
503 _LIBCPP_HIDE_FROM_ABI
constexpr ranges::
504 subrange
<reverse_iterator
<ranges::iterator_t
<_Range
>>, reverse_iterator
<ranges::iterator_t
<_Range
>>>
505 __reverse_range(_Range
&& __range
) {
506 auto __first
= ranges::begin(__range
);
507 return {std::make_reverse_iterator(ranges::next(__first
, ranges::end(__range
))), std::make_reverse_iterator(__first
)};
511 template <class _Iter
, bool __b
>
512 struct __unwrap_iter_impl
<reverse_iterator
<reverse_iterator
<_Iter
> >, __b
>
513 : __unwrap_reverse_iter_impl
<reverse_iterator
, reverse_iterator
, _Iter
> {};
515 #if _LIBCPP_STD_VER >= 20
517 template <class _Iter
, bool __b
>
518 struct __unwrap_iter_impl
<reverse_iterator
<__unconstrained_reverse_iterator
<_Iter
>>, __b
>
519 : __unwrap_reverse_iter_impl
<reverse_iterator
, __unconstrained_reverse_iterator
, _Iter
> {};
521 template <class _Iter
, bool __b
>
522 struct __unwrap_iter_impl
<__unconstrained_reverse_iterator
<reverse_iterator
<_Iter
>>, __b
>
523 : __unwrap_reverse_iter_impl
<__unconstrained_reverse_iterator
, reverse_iterator
, _Iter
> {};
525 template <class _Iter
, bool __b
>
526 struct __unwrap_iter_impl
<__unconstrained_reverse_iterator
<__unconstrained_reverse_iterator
<_Iter
>>, __b
>
527 : __unwrap_reverse_iter_impl
<__unconstrained_reverse_iterator
, __unconstrained_reverse_iterator
, _Iter
> {};
529 #endif // _LIBCPP_STD_VER >= 20
531 _LIBCPP_END_NAMESPACE_STD
533 #endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H