2 //===-------------------------- iterator ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_ITERATOR
12 #define _LIBCPP_ITERATOR
20 template<class Iterator>
21 struct iterator_traits
23 typedef typename Iterator::difference_type difference_type;
24 typedef typename Iterator::value_type value_type;
25 typedef typename Iterator::pointer pointer;
26 typedef typename Iterator::reference reference;
27 typedef typename Iterator::iterator_category iterator_category;
31 struct iterator_traits<T*>
33 typedef ptrdiff_t difference_type;
37 typedef random_access_iterator_tag iterator_category;
40 template<class Category, class T, class Distance = ptrdiff_t,
41 class Pointer = T*, class Reference = T&>
45 typedef Distance difference_type;
46 typedef Pointer pointer;
47 typedef Reference reference;
48 typedef Category iterator_category;
51 struct input_iterator_tag {};
52 struct output_iterator_tag {};
53 struct forward_iterator_tag : public input_iterator_tag {};
54 struct bidirectional_iterator_tag : public forward_iterator_tag {};
55 struct random_access_iterator_tag : public bidirectional_iterator_tag {};
57 // 27.4.3, iterator operations
58 // extension: second argument not conforming to C++03
59 template <class InputIterator> // constexpr in C++17
60 constexpr void advance(InputIterator& i,
61 typename iterator_traits<InputIterator>::difference_type n);
63 template <class InputIterator> // constexpr in C++17
64 constexpr typename iterator_traits<InputIterator>::difference_type
65 distance(InputIterator first, InputIterator last);
67 template <class InputIterator> // constexpr in C++17
68 constexpr InputIterator next(InputIterator x,
69 typename iterator_traits<InputIterator>::difference_type n = 1);
71 template <class BidirectionalIterator> // constexpr in C++17
72 constexpr BidirectionalIterator prev(BidirectionalIterator x,
73 typename iterator_traits<BidirectionalIterator>::difference_type n = 1);
75 template <class Iterator>
76 class reverse_iterator
77 : public iterator<typename iterator_traits<Iterator>::iterator_category,
78 typename iterator_traits<Iterator>::value_type,
79 typename iterator_traits<Iterator>::difference_type,
80 typename iterator_traits<Iterator>::pointer,
81 typename iterator_traits<Iterator>::reference>
86 typedef Iterator iterator_type;
87 typedef typename iterator_traits<Iterator>::difference_type difference_type;
88 typedef typename iterator_traits<Iterator>::reference reference;
89 typedef typename iterator_traits<Iterator>::pointer pointer;
91 constexpr reverse_iterator();
92 constexpr explicit reverse_iterator(Iterator x);
93 template <class U> constexpr reverse_iterator(const reverse_iterator<U>& u);
94 template <class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u);
95 constexpr Iterator base() const;
96 constexpr reference operator*() const;
97 constexpr pointer operator->() const;
98 constexpr reverse_iterator& operator++();
99 constexpr reverse_iterator operator++(int);
100 constexpr reverse_iterator& operator--();
101 constexpr reverse_iterator operator--(int);
102 constexpr reverse_iterator operator+ (difference_type n) const;
103 constexpr reverse_iterator& operator+=(difference_type n);
104 constexpr reverse_iterator operator- (difference_type n) const;
105 constexpr reverse_iterator& operator-=(difference_type n);
106 constexpr reference operator[](difference_type n) const;
109 template <class Iterator1, class Iterator2>
110 constexpr bool // constexpr in C++17
111 operator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
113 template <class Iterator1, class Iterator2>
114 constexpr bool // constexpr in C++17
115 operator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
117 template <class Iterator1, class Iterator2>
118 constexpr bool // constexpr in C++17
119 operator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
121 template <class Iterator1, class Iterator2>
122 constexpr bool // constexpr in C++17
123 operator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
125 template <class Iterator1, class Iterator2>
126 constexpr bool // constexpr in C++17
127 operator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
129 template <class Iterator1, class Iterator2>
130 constexpr bool // constexpr in C++17
131 operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
133 template <class Iterator1, class Iterator2>
135 operator-(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y)
136 -> decltype(__y.base() - __x.base()); // constexpr in C++17
138 template <class Iterator>
139 constexpr reverse_iterator<Iterator>
140 operator+(typename reverse_iterator<Iterator>::difference_type n,
141 const reverse_iterator<Iterator>& x); // constexpr in C++17
143 template <class Iterator>
144 constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14, constexpr in C++17
146 template <class Container>
147 class back_insert_iterator
150 Container* container;
152 typedef Container container_type;
153 typedef void value_type;
154 typedef void difference_type;
155 typedef void reference;
156 typedef void pointer;
158 explicit back_insert_iterator(Container& x);
159 back_insert_iterator& operator=(const typename Container::value_type& value);
160 back_insert_iterator& operator*();
161 back_insert_iterator& operator++();
162 back_insert_iterator operator++(int);
165 template <class Container> back_insert_iterator<Container> back_inserter(Container& x);
167 template <class Container>
168 class front_insert_iterator
171 Container* container;
173 typedef Container container_type;
174 typedef void value_type;
175 typedef void difference_type;
176 typedef void reference;
177 typedef void pointer;
179 explicit front_insert_iterator(Container& x);
180 front_insert_iterator& operator=(const typename Container::value_type& value);
181 front_insert_iterator& operator*();
182 front_insert_iterator& operator++();
183 front_insert_iterator operator++(int);
186 template <class Container> front_insert_iterator<Container> front_inserter(Container& x);
188 template <class Container>
189 class insert_iterator
192 Container* container;
193 typename Container::iterator iter;
195 typedef Container container_type;
196 typedef void value_type;
197 typedef void difference_type;
198 typedef void reference;
199 typedef void pointer;
201 insert_iterator(Container& x, typename Container::iterator i);
202 insert_iterator& operator=(const typename Container::value_type& value);
203 insert_iterator& operator*();
204 insert_iterator& operator++();
205 insert_iterator& operator++(int);
208 template <class Container, class Iterator>
209 insert_iterator<Container> inserter(Container& x, Iterator i);
211 template <class Iterator>
212 class move_iterator {
214 typedef Iterator iterator_type;
215 typedef typename iterator_traits<Iterator>::difference_type difference_type;
216 typedef Iterator pointer;
217 typedef typename iterator_traits<Iterator>::value_type value_type;
218 typedef typename iterator_traits<Iterator>::iterator_category iterator_category;
219 typedef value_type&& reference;
221 constexpr move_iterator(); // all the constexprs are in C++17
222 constexpr explicit move_iterator(Iterator i);
224 constexpr move_iterator(const move_iterator<U>& u);
226 constexpr move_iterator& operator=(const move_iterator<U>& u);
227 constexpr iterator_type base() const;
228 constexpr reference operator*() const;
229 constexpr pointer operator->() const;
230 constexpr move_iterator& operator++();
231 constexpr move_iterator operator++(int);
232 constexpr move_iterator& operator--();
233 constexpr move_iterator operator--(int);
234 constexpr move_iterator operator+(difference_type n) const;
235 constexpr move_iterator& operator+=(difference_type n);
236 constexpr move_iterator operator-(difference_type n) const;
237 constexpr move_iterator& operator-=(difference_type n);
238 constexpr unspecified operator[](difference_type n) const;
240 Iterator current; // exposition only
243 template <class Iterator1, class Iterator2>
244 constexpr bool // constexpr in C++17
245 operator==(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
247 template <class Iterator1, class Iterator2>
248 constexpr bool // constexpr in C++17
249 operator!=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
251 template <class Iterator1, class Iterator2>
252 constexpr bool // constexpr in C++17
253 operator<(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
255 template <class Iterator1, class Iterator2>
256 constexpr bool // constexpr in C++17
257 operator<=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
259 template <class Iterator1, class Iterator2>
260 constexpr bool // constexpr in C++17
261 operator>(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
263 template <class Iterator1, class Iterator2>
264 constexpr bool // constexpr in C++17
265 operator>=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
267 template <class Iterator1, class Iterator2>
268 constexpr auto // constexpr in C++17
269 operator-(const move_iterator<Iterator1>& x,
270 const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base());
272 template <class Iterator>
273 constexpr move_iterator<Iterator> operator+( // constexpr in C++17
274 typename move_iterator<Iterator>::difference_type n,
275 const move_iterator<Iterator>& x);
277 template <class Iterator> // constexpr in C++17
278 constexpr move_iterator<Iterator> make_move_iterator(const Iterator& i);
281 template <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t>
282 class istream_iterator
283 : public iterator<input_iterator_tag, T, Distance, const T*, const T&>
286 typedef charT char_type;
287 typedef traits traits_type;
288 typedef basic_istream<charT,traits> istream_type;
290 constexpr istream_iterator();
291 istream_iterator(istream_type& s);
292 istream_iterator(const istream_iterator& x);
295 const T& operator*() const;
296 const T* operator->() const;
297 istream_iterator& operator++();
298 istream_iterator operator++(int);
301 template <class T, class charT, class traits, class Distance>
302 bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
303 const istream_iterator<T,charT,traits,Distance>& y);
304 template <class T, class charT, class traits, class Distance>
305 bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
306 const istream_iterator<T,charT,traits,Distance>& y);
308 template <class T, class charT = char, class traits = char_traits<charT> >
309 class ostream_iterator
310 : public iterator<output_iterator_tag, void, void, void ,void>
313 typedef charT char_type;
314 typedef traits traits_type;
315 typedef basic_ostream<charT,traits> ostream_type;
317 ostream_iterator(ostream_type& s);
318 ostream_iterator(ostream_type& s, const charT* delimiter);
319 ostream_iterator(const ostream_iterator& x);
321 ostream_iterator& operator=(const T& value);
323 ostream_iterator& operator*();
324 ostream_iterator& operator++();
325 ostream_iterator& operator++(int);
328 template<class charT, class traits = char_traits<charT> >
329 class istreambuf_iterator
330 : public iterator<input_iterator_tag, charT,
331 typename traits::off_type, unspecified,
335 typedef charT char_type;
336 typedef traits traits_type;
337 typedef typename traits::int_type int_type;
338 typedef basic_streambuf<charT,traits> streambuf_type;
339 typedef basic_istream<charT,traits> istream_type;
341 istreambuf_iterator() noexcept;
342 istreambuf_iterator(istream_type& s) noexcept;
343 istreambuf_iterator(streambuf_type* s) noexcept;
344 istreambuf_iterator(a-private-type) noexcept;
346 charT operator*() const;
347 pointer operator->() const;
348 istreambuf_iterator& operator++();
349 a-private-type operator++(int);
351 bool equal(const istreambuf_iterator& b) const;
354 template <class charT, class traits>
355 bool operator==(const istreambuf_iterator<charT,traits>& a,
356 const istreambuf_iterator<charT,traits>& b);
357 template <class charT, class traits>
358 bool operator!=(const istreambuf_iterator<charT,traits>& a,
359 const istreambuf_iterator<charT,traits>& b);
361 template <class charT, class traits = char_traits<charT> >
362 class ostreambuf_iterator
363 : public iterator<output_iterator_tag, void, void, void, void>
366 typedef charT char_type;
367 typedef traits traits_type;
368 typedef basic_streambuf<charT,traits> streambuf_type;
369 typedef basic_ostream<charT,traits> ostream_type;
371 ostreambuf_iterator(ostream_type& s) noexcept;
372 ostreambuf_iterator(streambuf_type* s) noexcept;
373 ostreambuf_iterator& operator=(charT c);
374 ostreambuf_iterator& operator*();
375 ostreambuf_iterator& operator++();
376 ostreambuf_iterator& operator++(int);
377 bool failed() const noexcept;
380 template <class C> constexpr auto begin(C& c) -> decltype(c.begin());
381 template <class C> constexpr auto begin(const C& c) -> decltype(c.begin());
382 template <class C> constexpr auto end(C& c) -> decltype(c.end());
383 template <class C> constexpr auto end(const C& c) -> decltype(c.end());
384 template <class T, size_t N> constexpr T* begin(T (&array)[N]);
385 template <class T, size_t N> constexpr T* end(T (&array)[N]);
387 template <class C> auto constexpr cbegin(const C& c) -> decltype(std::begin(c)); // C++14
388 template <class C> auto constexpr cend(const C& c) -> decltype(std::end(c)); // C++14
389 template <class C> auto constexpr rbegin(C& c) -> decltype(c.rbegin()); // C++14
390 template <class C> auto constexpr rbegin(const C& c) -> decltype(c.rbegin()); // C++14
391 template <class C> auto constexpr rend(C& c) -> decltype(c.rend()); // C++14
392 template <class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // C++14
393 template <class E> reverse_iterator<const E*> constexpr rbegin(initializer_list<E> il); // C++14
394 template <class E> reverse_iterator<const E*> constexpr rend(initializer_list<E> il); // C++14
395 template <class T, size_t N> reverse_iterator<T*> constexpr rbegin(T (&array)[N]); // C++14
396 template <class T, size_t N> reverse_iterator<T*> constexpr rend(T (&array)[N]); // C++14
397 template <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14
398 template <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); // C++14
400 // 24.8, container access:
401 template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17
402 template <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17
403 template <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17
404 template <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17
405 template <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17
406 template <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17
407 template <class C> constexpr auto data(const C& c) -> decltype(c.data()); // C++17
408 template <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // C++17
409 template <class E> constexpr const E* data(initializer_list<E> il) noexcept; // C++17
416 #include <iosfwd> // for forward declarations of vector and string.
417 #include <__functional_base>
418 #include <type_traits>
420 #include <initializer_list>
423 #include <Availability.h>
428 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
429 #pragma GCC system_header
432 _LIBCPP_BEGIN_NAMESPACE_STD
434 struct _LIBCPP_TEMPLATE_VIS input_iterator_tag {};
435 struct _LIBCPP_TEMPLATE_VIS output_iterator_tag {};
436 struct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {};
437 struct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {};
438 struct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {};
441 struct __has_iterator_typedefs
444 struct __two {char __lx; char __lxx;};
445 template <class _Up> static __two __test(...);
446 template <class _Up> static char __test(typename std::__void_t<typename _Up::iterator_category>::type* = 0,
447 typename std::__void_t<typename _Up::difference_type>::type* = 0,
448 typename std::__void_t<typename _Up::value_type>::type* = 0,
449 typename std::__void_t<typename _Up::reference>::type* = 0,
450 typename std::__void_t<typename _Up::pointer>::type* = 0
453 static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1;
458 struct __has_iterator_category
461 struct __two {char __lx; char __lxx;};
462 template <class _Up> static __two __test(...);
463 template <class _Up> static char __test(typename _Up::iterator_category* = 0);
465 static const bool value = sizeof(__test<_Tp>(0)) == 1;
468 template <class _Iter, bool> struct __iterator_traits_impl {};
470 template <class _Iter>
471 struct __iterator_traits_impl<_Iter, true>
473 typedef typename _Iter::difference_type difference_type;
474 typedef typename _Iter::value_type value_type;
475 typedef typename _Iter::pointer pointer;
476 typedef typename _Iter::reference reference;
477 typedef typename _Iter::iterator_category iterator_category;
480 template <class _Iter, bool> struct __iterator_traits {};
482 template <class _Iter>
483 struct __iterator_traits<_Iter, true>
484 : __iterator_traits_impl
487 is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||
488 is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value
492 // iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category
493 // exists. Else iterator_traits<Iterator> will be an empty class. This is a
494 // conforming extension which allows some programs to compile and behave as
495 // the client expects instead of failing at compile time.
497 template <class _Iter>
498 struct _LIBCPP_TEMPLATE_VIS iterator_traits
499 : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {};
502 struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
504 typedef ptrdiff_t difference_type;
505 typedef typename remove_cv<_Tp>::type value_type;
506 typedef _Tp* pointer;
507 typedef _Tp& reference;
508 typedef random_access_iterator_tag iterator_category;
511 template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value>
512 struct __has_iterator_category_convertible_to
513 : public integral_constant<bool, is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up>::value>
516 template <class _Tp, class _Up>
517 struct __has_iterator_category_convertible_to<_Tp, _Up, false> : public false_type {};
520 struct __is_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {};
523 struct __is_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {};
526 struct __is_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {};
529 struct __is_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {};
532 struct __is_exactly_input_iterator
533 : public integral_constant<bool,
534 __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&
535 !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {};
537 template<class _Category, class _Tp, class _Distance = ptrdiff_t,
538 class _Pointer = _Tp*, class _Reference = _Tp&>
539 struct _LIBCPP_TEMPLATE_VIS iterator
541 typedef _Tp value_type;
542 typedef _Distance difference_type;
543 typedef _Pointer pointer;
544 typedef _Reference reference;
545 typedef _Category iterator_category;
548 template <class _InputIter>
549 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
550 void __advance(_InputIter& __i,
551 typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag)
553 for (; __n > 0; --__n)
557 template <class _BiDirIter>
558 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
559 void __advance(_BiDirIter& __i,
560 typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag)
563 for (; __n > 0; --__n)
566 for (; __n < 0; ++__n)
570 template <class _RandIter>
571 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
572 void __advance(_RandIter& __i,
573 typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag)
578 template <class _InputIter>
579 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
580 void advance(_InputIter& __i,
581 typename iterator_traits<_InputIter>::difference_type __n)
583 __advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
586 template <class _InputIter>
587 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
588 typename iterator_traits<_InputIter>::difference_type
589 __distance(_InputIter __first, _InputIter __last, input_iterator_tag)
591 typename iterator_traits<_InputIter>::difference_type __r(0);
592 for (; __first != __last; ++__first)
597 template <class _RandIter>
598 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
599 typename iterator_traits<_RandIter>::difference_type
600 __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
602 return __last - __first;
605 template <class _InputIter>
606 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
607 typename iterator_traits<_InputIter>::difference_type
608 distance(_InputIter __first, _InputIter __last)
610 return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
613 template <class _InputIter>
614 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
617 __is_input_iterator<_InputIter>::value,
621 typename iterator_traits<_InputIter>::difference_type __n = 1)
623 _VSTD::advance(__x, __n);
627 template <class _BidirectionalIter>
628 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
631 __is_bidirectional_iterator<_BidirectionalIter>::value,
634 prev(_BidirectionalIter __x,
635 typename iterator_traits<_BidirectionalIter>::difference_type __n = 1)
637 _VSTD::advance(__x, -__n);
642 template <class _Tp, class = void>
643 struct __is_stashing_iterator : false_type {};
646 struct __is_stashing_iterator<_Tp, typename __void_t<typename _Tp::__stashing_iterator_tag>::type>
649 template <class _Iter>
650 class _LIBCPP_TEMPLATE_VIS reverse_iterator
651 : public iterator<typename iterator_traits<_Iter>::iterator_category,
652 typename iterator_traits<_Iter>::value_type,
653 typename iterator_traits<_Iter>::difference_type,
654 typename iterator_traits<_Iter>::pointer,
655 typename iterator_traits<_Iter>::reference>
658 /*mutable*/ _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break
660 static_assert(!__is_stashing_iterator<_Iter>::value,
661 "The specified iterator type cannot be used with reverse_iterator; "
662 "Using stashing iterators with reverse_iterator causes undefined behavior");
667 typedef _Iter iterator_type;
668 typedef typename iterator_traits<_Iter>::difference_type difference_type;
669 typedef typename iterator_traits<_Iter>::reference reference;
670 typedef typename iterator_traits<_Iter>::pointer pointer;
672 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
673 reverse_iterator() : __t(), current() {}
674 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
675 explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {}
677 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
678 reverse_iterator(const reverse_iterator<_Up>& __u) : __t(__u.base()), current(__u.base()) {}
680 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
681 reverse_iterator& operator=(const reverse_iterator<_Up>& __u)
682 { __t = current = __u.base(); return *this; }
683 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
684 _Iter base() const {return current;}
685 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
686 reference operator*() const {_Iter __tmp = current; return *--__tmp;}
687 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
688 pointer operator->() const {return _VSTD::addressof(operator*());}
689 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
690 reverse_iterator& operator++() {--current; return *this;}
691 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
692 reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
693 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
694 reverse_iterator& operator--() {++current; return *this;}
695 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
696 reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
697 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
698 reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);}
699 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
700 reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}
701 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
702 reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);}
703 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
704 reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}
705 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
706 reference operator[](difference_type __n) const {return *(*this + __n);}
709 template <class _Iter1, class _Iter2>
710 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
712 operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
714 return __x.base() == __y.base();
717 template <class _Iter1, class _Iter2>
718 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
720 operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
722 return __x.base() > __y.base();
725 template <class _Iter1, class _Iter2>
726 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
728 operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
730 return __x.base() != __y.base();
733 template <class _Iter1, class _Iter2>
734 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
736 operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
738 return __x.base() < __y.base();
741 template <class _Iter1, class _Iter2>
742 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
744 operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
746 return __x.base() <= __y.base();
749 template <class _Iter1, class _Iter2>
750 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
752 operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
754 return __x.base() >= __y.base();
757 #ifndef _LIBCPP_CXX03_LANG
758 template <class _Iter1, class _Iter2>
759 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
761 operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
762 -> decltype(__y.base() - __x.base())
764 return __y.base() - __x.base();
767 template <class _Iter1, class _Iter2>
768 inline _LIBCPP_INLINE_VISIBILITY
769 typename reverse_iterator<_Iter1>::difference_type
770 operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
772 return __y.base() - __x.base();
776 template <class _Iter>
777 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
778 reverse_iterator<_Iter>
779 operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x)
781 return reverse_iterator<_Iter>(__x.base() - __n);
784 #if _LIBCPP_STD_VER > 11
785 template <class _Iter>
786 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
787 reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
789 return reverse_iterator<_Iter>(__i);
793 template <class _Container>
794 class _LIBCPP_TEMPLATE_VIS back_insert_iterator
795 : public iterator<output_iterator_tag,
802 _Container* container;
804 typedef _Container container_type;
806 _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
807 _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_)
808 {container->push_back(__value_); return *this;}
809 #ifndef _LIBCPP_CXX03_LANG
810 _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value_)
811 {container->push_back(_VSTD::move(__value_)); return *this;}
812 #endif // _LIBCPP_CXX03_LANG
813 _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator*() {return *this;}
814 _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++() {return *this;}
815 _LIBCPP_INLINE_VISIBILITY back_insert_iterator operator++(int) {return *this;}
818 template <class _Container>
819 inline _LIBCPP_INLINE_VISIBILITY
820 back_insert_iterator<_Container>
821 back_inserter(_Container& __x)
823 return back_insert_iterator<_Container>(__x);
826 template <class _Container>
827 class _LIBCPP_TEMPLATE_VIS front_insert_iterator
828 : public iterator<output_iterator_tag,
835 _Container* container;
837 typedef _Container container_type;
839 _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
840 _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_)
841 {container->push_front(__value_); return *this;}
842 #ifndef _LIBCPP_CXX03_LANG
843 _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value_)
844 {container->push_front(_VSTD::move(__value_)); return *this;}
845 #endif // _LIBCPP_CXX03_LANG
846 _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator*() {return *this;}
847 _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator++() {return *this;}
848 _LIBCPP_INLINE_VISIBILITY front_insert_iterator operator++(int) {return *this;}
851 template <class _Container>
852 inline _LIBCPP_INLINE_VISIBILITY
853 front_insert_iterator<_Container>
854 front_inserter(_Container& __x)
856 return front_insert_iterator<_Container>(__x);
859 template <class _Container>
860 class _LIBCPP_TEMPLATE_VIS insert_iterator
861 : public iterator<output_iterator_tag,
868 _Container* container;
869 typename _Container::iterator iter;
871 typedef _Container container_type;
873 _LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i)
874 : container(_VSTD::addressof(__x)), iter(__i) {}
875 _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_)
876 {iter = container->insert(iter, __value_); ++iter; return *this;}
877 #ifndef _LIBCPP_CXX03_LANG
878 _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value_)
879 {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;}
880 #endif // _LIBCPP_CXX03_LANG
881 _LIBCPP_INLINE_VISIBILITY insert_iterator& operator*() {return *this;}
882 _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++() {return *this;}
883 _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++(int) {return *this;}
886 template <class _Container>
887 inline _LIBCPP_INLINE_VISIBILITY
888 insert_iterator<_Container>
889 inserter(_Container& __x, typename _Container::iterator __i)
891 return insert_iterator<_Container>(__x, __i);
894 template <class _Tp, class _CharT = char,
895 class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>
896 class _LIBCPP_TEMPLATE_VIS istream_iterator
897 : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&>
900 typedef _CharT char_type;
901 typedef _Traits traits_type;
902 typedef basic_istream<_CharT,_Traits> istream_type;
904 istream_type* __in_stream_;
907 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {}
908 _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))
910 if (!(*__in_stream_ >> __value_))
914 _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;}
915 _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return _VSTD::addressof((operator*()));}
916 _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
918 if (!(*__in_stream_ >> __value_))
922 _LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int)
923 {istream_iterator __t(*this); ++(*this); return __t;}
925 template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
926 friend _LIBCPP_INLINE_VISIBILITY
928 operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
929 const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
931 template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
932 friend _LIBCPP_INLINE_VISIBILITY
934 operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
935 const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
938 template <class _Tp, class _CharT, class _Traits, class _Distance>
939 inline _LIBCPP_INLINE_VISIBILITY
941 operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
942 const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
944 return __x.__in_stream_ == __y.__in_stream_;
947 template <class _Tp, class _CharT, class _Traits, class _Distance>
948 inline _LIBCPP_INLINE_VISIBILITY
950 operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
951 const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
953 return !(__x == __y);
956 template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
957 class _LIBCPP_TEMPLATE_VIS ostream_iterator
958 : public iterator<output_iterator_tag, void, void, void, void>
961 typedef _CharT char_type;
962 typedef _Traits traits_type;
963 typedef basic_ostream<_CharT,_Traits> ostream_type;
965 ostream_type* __out_stream_;
966 const char_type* __delim_;
968 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT
969 : __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
970 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT
971 : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
972 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
974 *__out_stream_ << __value_;
976 *__out_stream_ << __delim_;
980 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*() {return *this;}
981 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++() {return *this;}
982 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;}
985 template<class _CharT, class _Traits>
986 class _LIBCPP_TEMPLATE_VIS istreambuf_iterator
987 : public iterator<input_iterator_tag, _CharT,
988 typename _Traits::off_type, _CharT*,
992 typedef _CharT char_type;
993 typedef _Traits traits_type;
994 typedef typename _Traits::int_type int_type;
995 typedef basic_streambuf<_CharT,_Traits> streambuf_type;
996 typedef basic_istream<_CharT,_Traits> istream_type;
998 mutable streambuf_type* __sbuf_;
1003 streambuf_type* __sbuf_;
1004 _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s)
1005 : __keep_(__c), __sbuf_(__s) {}
1006 friend class istreambuf_iterator;
1008 _LIBCPP_INLINE_VISIBILITY char_type operator*() const {return __keep_;}
1011 _LIBCPP_INLINE_VISIBILITY
1012 bool __test_for_eof() const
1014 if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof()))
1016 return __sbuf_ == 0;
1019 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(0) {}
1020 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT
1021 : __sbuf_(__s.rdbuf()) {}
1022 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT
1024 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT
1025 : __sbuf_(__p.__sbuf_) {}
1027 _LIBCPP_INLINE_VISIBILITY char_type operator*() const
1028 {return static_cast<char_type>(__sbuf_->sgetc());}
1029 _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++()
1034 _LIBCPP_INLINE_VISIBILITY __proxy operator++(int)
1036 return __proxy(__sbuf_->sbumpc(), __sbuf_);
1039 _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const
1040 {return __test_for_eof() == __b.__test_for_eof();}
1043 template <class _CharT, class _Traits>
1044 inline _LIBCPP_INLINE_VISIBILITY
1045 bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,
1046 const istreambuf_iterator<_CharT,_Traits>& __b)
1047 {return __a.equal(__b);}
1049 template <class _CharT, class _Traits>
1050 inline _LIBCPP_INLINE_VISIBILITY
1051 bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a,
1052 const istreambuf_iterator<_CharT,_Traits>& __b)
1053 {return !__a.equal(__b);}
1055 template <class _CharT, class _Traits>
1056 class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator
1057 : public iterator<output_iterator_tag, void, void, void, void>
1060 typedef _CharT char_type;
1061 typedef _Traits traits_type;
1062 typedef basic_streambuf<_CharT,_Traits> streambuf_type;
1063 typedef basic_ostream<_CharT,_Traits> ostream_type;
1065 streambuf_type* __sbuf_;
1067 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT
1068 : __sbuf_(__s.rdbuf()) {}
1069 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT
1071 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c)
1073 if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))
1077 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;}
1078 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;}
1079 _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;}
1080 _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == 0;}
1082 #if !defined(__APPLE__) || \
1083 (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_8) || \
1084 (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0)
1086 template <class _Ch, class _Tr>
1089 ostreambuf_iterator<_Ch, _Tr>
1090 __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,
1091 const _Ch* __ob, const _Ch* __op, const _Ch* __oe,
1092 ios_base& __iob, _Ch __fl);
1096 template <class _Iter>
1097 class _LIBCPP_TEMPLATE_VIS move_iterator
1102 typedef _Iter iterator_type;
1103 typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
1104 typedef typename iterator_traits<iterator_type>::value_type value_type;
1105 typedef typename iterator_traits<iterator_type>::difference_type difference_type;
1106 typedef iterator_type pointer;
1107 #ifndef _LIBCPP_CXX03_LANG
1108 typedef typename iterator_traits<iterator_type>::reference __reference;
1109 typedef typename conditional<
1110 is_reference<__reference>::value,
1111 typename remove_reference<__reference>::type&&,
1115 typedef typename iterator_traits<iterator_type>::reference reference;
1118 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1119 move_iterator() : __i() {}
1120 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1121 explicit move_iterator(_Iter __x) : __i(__x) {}
1122 template <class _Up>
1123 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1124 move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {}
1125 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;}
1126 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1127 reference operator*() const { return static_cast<reference>(*__i); }
1128 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1129 pointer operator->() const { return __i;}
1130 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1131 move_iterator& operator++() {++__i; return *this;}
1132 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1133 move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;}
1134 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1135 move_iterator& operator--() {--__i; return *this;}
1136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1137 move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;}
1138 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1139 move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);}
1140 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1141 move_iterator& operator+=(difference_type __n) {__i += __n; return *this;}
1142 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1143 move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);}
1144 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1145 move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;}
1146 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1147 reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); }
1150 template <class _Iter1, class _Iter2>
1151 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1153 operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1155 return __x.base() == __y.base();
1158 template <class _Iter1, class _Iter2>
1159 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1161 operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1163 return __x.base() < __y.base();
1166 template <class _Iter1, class _Iter2>
1167 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1169 operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1171 return __x.base() != __y.base();
1174 template <class _Iter1, class _Iter2>
1175 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1177 operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1179 return __x.base() > __y.base();
1182 template <class _Iter1, class _Iter2>
1183 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1185 operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1187 return __x.base() >= __y.base();
1190 template <class _Iter1, class _Iter2>
1191 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1193 operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1195 return __x.base() <= __y.base();
1198 #ifndef _LIBCPP_CXX03_LANG
1199 template <class _Iter1, class _Iter2>
1200 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1202 operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1203 -> decltype(__x.base() - __y.base())
1205 return __x.base() - __y.base();
1208 template <class _Iter1, class _Iter2>
1209 inline _LIBCPP_INLINE_VISIBILITY
1210 typename move_iterator<_Iter1>::difference_type
1211 operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1213 return __x.base() - __y.base();
1217 template <class _Iter>
1218 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1219 move_iterator<_Iter>
1220 operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)
1222 return move_iterator<_Iter>(__x.base() + __n);
1225 template <class _Iter>
1226 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1227 move_iterator<_Iter>
1228 make_move_iterator(_Iter __i)
1230 return move_iterator<_Iter>(__i);
1235 template <class _Iter> class __wrap_iter;
1237 template <class _Iter1, class _Iter2>
1238 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1240 operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1242 template <class _Iter1, class _Iter2>
1243 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1245 operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1247 template <class _Iter1, class _Iter2>
1248 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1250 operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1252 template <class _Iter1, class _Iter2>
1253 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1255 operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1257 template <class _Iter1, class _Iter2>
1258 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1260 operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1262 template <class _Iter1, class _Iter2>
1263 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1265 operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1267 #ifndef _LIBCPP_CXX03_LANG
1268 template <class _Iter1, class _Iter2>
1269 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1271 operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1272 -> decltype(__x.base() - __y.base());
1274 template <class _Iter1, class _Iter2>
1275 _LIBCPP_INLINE_VISIBILITY
1276 typename __wrap_iter<_Iter1>::difference_type
1277 operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1280 template <class _Iter>
1281 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1283 operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT_DEBUG;
1285 template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY copy(_Ip, _Ip, _Op);
1286 template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY copy_backward(_B1, _B1, _B2);
1287 template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY move(_Ip, _Ip, _Op);
1288 template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY move_backward(_B1, _B1, _B2);
1290 #if _LIBCPP_DEBUG_LEVEL < 2
1292 template <class _Tp>
1293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1296 is_trivially_copy_assignable<_Tp>::value,
1299 __unwrap_iter(__wrap_iter<_Tp*>);
1303 template <class _Tp>
1304 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1307 is_trivially_copy_assignable<_Tp>::value,
1310 __unwrap_iter(__wrap_iter<_Tp*> __i);
1314 template <class _Iter>
1318 typedef _Iter iterator_type;
1319 typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
1320 typedef typename iterator_traits<iterator_type>::value_type value_type;
1321 typedef typename iterator_traits<iterator_type>::difference_type difference_type;
1322 typedef typename iterator_traits<iterator_type>::pointer pointer;
1323 typedef typename iterator_traits<iterator_type>::reference reference;
1327 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT_DEBUG
1328 #if _LIBCPP_STD_VER > 11
1332 #if _LIBCPP_DEBUG_LEVEL >= 2
1333 __get_db()->__insert_i(this);
1336 template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1337 __wrap_iter(const __wrap_iter<_Up>& __u,
1338 typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) _NOEXCEPT_DEBUG
1341 #if _LIBCPP_DEBUG_LEVEL >= 2
1342 __get_db()->__iterator_copy(this, &__u);
1345 #if _LIBCPP_DEBUG_LEVEL >= 2
1346 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1347 __wrap_iter(const __wrap_iter& __x)
1350 __get_db()->__iterator_copy(this, &__x);
1352 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1353 __wrap_iter& operator=(const __wrap_iter& __x)
1357 __get_db()->__iterator_copy(this, &__x);
1362 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1365 __get_db()->__erase_i(this);
1368 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT_DEBUG
1370 #if _LIBCPP_DEBUG_LEVEL >= 2
1371 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
1372 "Attempted to dereference a non-dereferenceable iterator");
1376 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT_DEBUG
1378 #if _LIBCPP_DEBUG_LEVEL >= 2
1379 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
1380 "Attempted to dereference a non-dereferenceable iterator");
1382 return (pointer)_VSTD::addressof(*__i);
1384 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT_DEBUG
1386 #if _LIBCPP_DEBUG_LEVEL >= 2
1387 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
1388 "Attempted to increment non-incrementable iterator");
1393 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT_DEBUG
1394 {__wrap_iter __tmp(*this); ++(*this); return __tmp;}
1396 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT_DEBUG
1398 #if _LIBCPP_DEBUG_LEVEL >= 2
1399 _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
1400 "Attempted to decrement non-decrementable iterator");
1405 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT_DEBUG
1406 {__wrap_iter __tmp(*this); --(*this); return __tmp;}
1407 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT_DEBUG
1408 {__wrap_iter __w(*this); __w += __n; return __w;}
1409 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT_DEBUG
1411 #if _LIBCPP_DEBUG_LEVEL >= 2
1412 _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n),
1413 "Attempted to add/subtract iterator outside of valid range");
1418 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT_DEBUG
1419 {return *this + (-__n);}
1420 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT_DEBUG
1421 {*this += -__n; return *this;}
1422 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT_DEBUG
1424 #if _LIBCPP_DEBUG_LEVEL >= 2
1425 _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n),
1426 "Attempted to subscript iterator outside of valid range");
1431 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT_DEBUG {return __i;}
1434 #if _LIBCPP_DEBUG_LEVEL >= 2
1435 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
1437 __get_db()->__insert_ic(this, __p);
1440 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
1443 template <class _Up> friend class __wrap_iter;
1444 template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
1445 template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector;
1446 template <class _Tp, ptrdiff_t> friend class _LIBCPP_TEMPLATE_VIS span;
1448 template <class _Iter1, class _Iter2>
1449 _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1451 operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1453 template <class _Iter1, class _Iter2>
1454 _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1456 operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1458 template <class _Iter1, class _Iter2>
1459 _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1461 operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1463 template <class _Iter1, class _Iter2>
1464 _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1466 operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1468 template <class _Iter1, class _Iter2>
1469 _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1471 operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1473 template <class _Iter1, class _Iter2>
1474 _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1476 operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1478 #ifndef _LIBCPP_CXX03_LANG
1479 template <class _Iter1, class _Iter2>
1480 _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1482 operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1483 -> decltype(__x.base() - __y.base());
1485 template <class _Iter1, class _Iter2>
1486 _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1487 typename __wrap_iter<_Iter1>::difference_type
1488 operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1491 template <class _Iter1>
1492 _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1494 operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT_DEBUG;
1496 template <class _Ip, class _Op> friend _Op copy(_Ip, _Ip, _Op);
1497 template <class _B1, class _B2> friend _B2 copy_backward(_B1, _B1, _B2);
1498 template <class _Ip, class _Op> friend _Op move(_Ip, _Ip, _Op);
1499 template <class _B1, class _B2> friend _B2 move_backward(_B1, _B1, _B2);
1501 #if _LIBCPP_DEBUG_LEVEL < 2
1502 template <class _Tp>
1503 _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1506 is_trivially_copy_assignable<_Tp>::value,
1509 __unwrap_iter(__wrap_iter<_Tp*>);
1511 template <class _Tp>
1512 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1515 is_trivially_copy_assignable<_Tp>::value,
1518 __unwrap_iter(__wrap_iter<_Tp*> __i);
1522 template <class _Iter1, class _Iter2>
1523 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1525 operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1527 return __x.base() == __y.base();
1530 template <class _Iter1, class _Iter2>
1531 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1533 operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1535 #if _LIBCPP_DEBUG_LEVEL >= 2
1536 _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
1537 "Attempted to compare incomparable iterators");
1539 return __x.base() < __y.base();
1542 template <class _Iter1, class _Iter2>
1543 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1545 operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1547 return !(__x == __y);
1550 template <class _Iter1, class _Iter2>
1551 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1553 operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1558 template <class _Iter1, class _Iter2>
1559 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1561 operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1563 return !(__x < __y);
1566 template <class _Iter1, class _Iter2>
1567 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1569 operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1571 return !(__y < __x);
1574 template <class _Iter1>
1575 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1577 operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
1579 return !(__x == __y);
1582 template <class _Iter1>
1583 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1585 operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
1590 template <class _Iter1>
1591 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1593 operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
1595 return !(__x < __y);
1598 template <class _Iter1>
1599 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1601 operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
1603 return !(__y < __x);
1606 #ifndef _LIBCPP_CXX03_LANG
1607 template <class _Iter1, class _Iter2>
1608 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1610 operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1611 -> decltype(__x.base() - __y.base())
1613 #if _LIBCPP_DEBUG_LEVEL >= 2
1614 _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
1615 "Attempted to subtract incompatible iterators");
1617 return __x.base() - __y.base();
1620 template <class _Iter1, class _Iter2>
1621 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1622 typename __wrap_iter<_Iter1>::difference_type
1623 operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1625 #if _LIBCPP_DEBUG_LEVEL >= 2
1626 _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
1627 "Attempted to subtract incompatible iterators");
1629 return __x.base() - __y.base();
1633 template <class _Iter>
1634 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1636 operator+(typename __wrap_iter<_Iter>::difference_type __n,
1637 __wrap_iter<_Iter> __x) _NOEXCEPT_DEBUG
1643 template <class _Iter>
1644 struct __libcpp_is_trivial_iterator
1645 : public _LIBCPP_BOOL_CONSTANT(is_pointer<_Iter>::value) {};
1647 template <class _Iter>
1648 struct __libcpp_is_trivial_iterator<move_iterator<_Iter> >
1649 : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
1651 template <class _Iter>
1652 struct __libcpp_is_trivial_iterator<reverse_iterator<_Iter> >
1653 : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
1655 template <class _Iter>
1656 struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> >
1657 : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
1660 template <class _Tp, size_t _Np>
1661 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1663 begin(_Tp (&__array)[_Np])
1668 template <class _Tp, size_t _Np>
1669 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1671 end(_Tp (&__array)[_Np])
1673 return __array + _Np;
1676 #if !defined(_LIBCPP_CXX03_LANG)
1678 template <class _Cp>
1679 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1681 begin(_Cp& __c) -> decltype(__c.begin())
1686 template <class _Cp>
1687 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1689 begin(const _Cp& __c) -> decltype(__c.begin())
1694 template <class _Cp>
1695 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1697 end(_Cp& __c) -> decltype(__c.end())
1702 template <class _Cp>
1703 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1705 end(const _Cp& __c) -> decltype(__c.end())
1710 #if _LIBCPP_STD_VER > 11
1712 template <class _Tp, size_t _Np>
1713 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1714 reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
1716 return reverse_iterator<_Tp*>(__array + _Np);
1719 template <class _Tp, size_t _Np>
1720 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1721 reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
1723 return reverse_iterator<_Tp*>(__array);
1726 template <class _Ep>
1727 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1728 reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
1730 return reverse_iterator<const _Ep*>(__il.end());
1733 template <class _Ep>
1734 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1735 reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
1737 return reverse_iterator<const _Ep*>(__il.begin());
1740 template <class _Cp>
1741 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1742 auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))
1744 return _VSTD::begin(__c);
1747 template <class _Cp>
1748 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1749 auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
1751 return _VSTD::end(__c);
1754 template <class _Cp>
1755 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1756 auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
1758 return __c.rbegin();
1761 template <class _Cp>
1762 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1763 auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
1765 return __c.rbegin();
1768 template <class _Cp>
1769 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1770 auto rend(_Cp& __c) -> decltype(__c.rend())
1775 template <class _Cp>
1776 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1777 auto rend(const _Cp& __c) -> decltype(__c.rend())
1782 template <class _Cp>
1783 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1784 auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
1786 return _VSTD::rbegin(__c);
1789 template <class _Cp>
1790 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1791 auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
1793 return _VSTD::rend(__c);
1799 #else // defined(_LIBCPP_CXX03_LANG)
1801 template <class _Cp>
1802 inline _LIBCPP_INLINE_VISIBILITY
1803 typename _Cp::iterator
1809 template <class _Cp>
1810 inline _LIBCPP_INLINE_VISIBILITY
1811 typename _Cp::const_iterator
1812 begin(const _Cp& __c)
1817 template <class _Cp>
1818 inline _LIBCPP_INLINE_VISIBILITY
1819 typename _Cp::iterator
1825 template <class _Cp>
1826 inline _LIBCPP_INLINE_VISIBILITY
1827 typename _Cp::const_iterator
1833 #endif // !defined(_LIBCPP_CXX03_LANG)
1835 #if _LIBCPP_STD_VER > 14
1837 // #if _LIBCPP_STD_VER > 11
1839 // struct _LIBCPP_TEMPLATE_VIS plus<void>
1841 // template <class _T1, class _T2>
1842 // _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1843 // auto operator()(_T1&& __t, _T2&& __u) const
1844 // _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
1845 // -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
1846 // { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
1847 // typedef void is_transparent;
1851 template <class _Cont>
1852 inline _LIBCPP_INLINE_VISIBILITY
1853 constexpr auto size(const _Cont& __c)
1854 _NOEXCEPT_(noexcept(__c.size()))
1855 -> decltype (__c.size())
1856 { return __c.size(); }
1858 template <class _Tp, size_t _Sz>
1859 inline _LIBCPP_INLINE_VISIBILITY
1860 constexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; }
1862 template <class _Cont>
1863 _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
1864 constexpr auto empty(const _Cont& __c)
1865 _NOEXCEPT_(noexcept(__c.empty()))
1866 -> decltype (__c.empty())
1867 { return __c.empty(); }
1869 template <class _Tp, size_t _Sz>
1870 _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
1871 constexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; }
1873 template <class _Ep>
1874 _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
1875 constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; }
1877 template <class _Cont> constexpr
1878 inline _LIBCPP_INLINE_VISIBILITY
1879 auto data(_Cont& __c)
1880 _NOEXCEPT_(noexcept(__c.data()))
1881 -> decltype (__c.data())
1882 { return __c.data(); }
1884 template <class _Cont> constexpr
1885 inline _LIBCPP_INLINE_VISIBILITY
1886 auto data(const _Cont& __c)
1887 _NOEXCEPT_(noexcept(__c.data()))
1888 -> decltype (__c.data())
1889 { return __c.data(); }
1891 template <class _Tp, size_t _Sz>
1892 inline _LIBCPP_INLINE_VISIBILITY
1893 constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; }
1895 template <class _Ep>
1896 inline _LIBCPP_INLINE_VISIBILITY
1897 constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); }
1901 _LIBCPP_END_NAMESPACE_STD
1903 #endif // _LIBCPP_ITERATOR