xref: /aosp_15_r20/external/libcxx/include/iterator (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===-------------------------- iterator ----------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_ITERATOR
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_ITERATOR
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    iterator synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard Workernamespace std
18*58b9f456SAndroid Build Coastguard Worker{
19*58b9f456SAndroid Build Coastguard Worker
20*58b9f456SAndroid Build Coastguard Workertemplate<class Iterator>
21*58b9f456SAndroid Build Coastguard Workerstruct iterator_traits
22*58b9f456SAndroid Build Coastguard Worker{
23*58b9f456SAndroid Build Coastguard Worker    typedef typename Iterator::difference_type difference_type;
24*58b9f456SAndroid Build Coastguard Worker    typedef typename Iterator::value_type value_type;
25*58b9f456SAndroid Build Coastguard Worker    typedef typename Iterator::pointer pointer;
26*58b9f456SAndroid Build Coastguard Worker    typedef typename Iterator::reference reference;
27*58b9f456SAndroid Build Coastguard Worker    typedef typename Iterator::iterator_category iterator_category;
28*58b9f456SAndroid Build Coastguard Worker};
29*58b9f456SAndroid Build Coastguard Worker
30*58b9f456SAndroid Build Coastguard Workertemplate<class T>
31*58b9f456SAndroid Build Coastguard Workerstruct iterator_traits<T*>
32*58b9f456SAndroid Build Coastguard Worker{
33*58b9f456SAndroid Build Coastguard Worker    typedef ptrdiff_t difference_type;
34*58b9f456SAndroid Build Coastguard Worker    typedef T value_type;
35*58b9f456SAndroid Build Coastguard Worker    typedef T* pointer;
36*58b9f456SAndroid Build Coastguard Worker    typedef T& reference;
37*58b9f456SAndroid Build Coastguard Worker    typedef random_access_iterator_tag iterator_category;
38*58b9f456SAndroid Build Coastguard Worker};
39*58b9f456SAndroid Build Coastguard Worker
40*58b9f456SAndroid Build Coastguard Workertemplate<class Category, class T, class Distance = ptrdiff_t,
41*58b9f456SAndroid Build Coastguard Worker         class Pointer = T*, class Reference = T&>
42*58b9f456SAndroid Build Coastguard Workerstruct iterator
43*58b9f456SAndroid Build Coastguard Worker{
44*58b9f456SAndroid Build Coastguard Worker    typedef T         value_type;
45*58b9f456SAndroid Build Coastguard Worker    typedef Distance  difference_type;
46*58b9f456SAndroid Build Coastguard Worker    typedef Pointer   pointer;
47*58b9f456SAndroid Build Coastguard Worker    typedef Reference reference;
48*58b9f456SAndroid Build Coastguard Worker    typedef Category  iterator_category;
49*58b9f456SAndroid Build Coastguard Worker};
50*58b9f456SAndroid Build Coastguard Worker
51*58b9f456SAndroid Build Coastguard Workerstruct input_iterator_tag  {};
52*58b9f456SAndroid Build Coastguard Workerstruct output_iterator_tag {};
53*58b9f456SAndroid Build Coastguard Workerstruct forward_iterator_tag       : public input_iterator_tag         {};
54*58b9f456SAndroid Build Coastguard Workerstruct bidirectional_iterator_tag : public forward_iterator_tag       {};
55*58b9f456SAndroid Build Coastguard Workerstruct random_access_iterator_tag : public bidirectional_iterator_tag {};
56*58b9f456SAndroid Build Coastguard Worker
57*58b9f456SAndroid Build Coastguard Worker// 27.4.3, iterator operations
58*58b9f456SAndroid Build Coastguard Worker// extension: second argument not conforming to C++03
59*58b9f456SAndroid Build Coastguard Workertemplate <class InputIterator>  // constexpr in C++17
60*58b9f456SAndroid Build Coastguard Worker  constexpr void advance(InputIterator& i,
61*58b9f456SAndroid Build Coastguard Worker             typename iterator_traits<InputIterator>::difference_type n);
62*58b9f456SAndroid Build Coastguard Worker
63*58b9f456SAndroid Build Coastguard Workertemplate <class InputIterator>  // constexpr in C++17
64*58b9f456SAndroid Build Coastguard Worker  constexpr typename iterator_traits<InputIterator>::difference_type
65*58b9f456SAndroid Build Coastguard Worker    distance(InputIterator first, InputIterator last);
66*58b9f456SAndroid Build Coastguard Worker
67*58b9f456SAndroid Build Coastguard Workertemplate <class InputIterator>  // constexpr in C++17
68*58b9f456SAndroid Build Coastguard Worker  constexpr InputIterator next(InputIterator x,
69*58b9f456SAndroid Build Coastguard Workertypename iterator_traits<InputIterator>::difference_type n = 1);
70*58b9f456SAndroid Build Coastguard Worker
71*58b9f456SAndroid Build Coastguard Workertemplate <class BidirectionalIterator>  // constexpr in C++17
72*58b9f456SAndroid Build Coastguard Worker  constexpr BidirectionalIterator prev(BidirectionalIterator x,
73*58b9f456SAndroid Build Coastguard Worker    typename iterator_traits<BidirectionalIterator>::difference_type n = 1);
74*58b9f456SAndroid Build Coastguard Worker
75*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator>
76*58b9f456SAndroid Build Coastguard Workerclass reverse_iterator
77*58b9f456SAndroid Build Coastguard Worker    : public iterator<typename iterator_traits<Iterator>::iterator_category,
78*58b9f456SAndroid Build Coastguard Worker                      typename iterator_traits<Iterator>::value_type,
79*58b9f456SAndroid Build Coastguard Worker                      typename iterator_traits<Iterator>::difference_type,
80*58b9f456SAndroid Build Coastguard Worker                      typename iterator_traits<Iterator>::pointer,
81*58b9f456SAndroid Build Coastguard Worker                      typename iterator_traits<Iterator>::reference>
82*58b9f456SAndroid Build Coastguard Worker{
83*58b9f456SAndroid Build Coastguard Workerprotected:
84*58b9f456SAndroid Build Coastguard Worker    Iterator current;
85*58b9f456SAndroid Build Coastguard Workerpublic:
86*58b9f456SAndroid Build Coastguard Worker    typedef Iterator                                            iterator_type;
87*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<Iterator>::difference_type difference_type;
88*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<Iterator>::reference       reference;
89*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<Iterator>::pointer         pointer;
90*58b9f456SAndroid Build Coastguard Worker
91*58b9f456SAndroid Build Coastguard Worker    constexpr reverse_iterator();
92*58b9f456SAndroid Build Coastguard Worker    constexpr explicit reverse_iterator(Iterator x);
93*58b9f456SAndroid Build Coastguard Worker    template <class U> constexpr reverse_iterator(const reverse_iterator<U>& u);
94*58b9f456SAndroid Build Coastguard Worker    template <class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u);
95*58b9f456SAndroid Build Coastguard Worker    constexpr Iterator base() const;
96*58b9f456SAndroid Build Coastguard Worker    constexpr reference operator*() const;
97*58b9f456SAndroid Build Coastguard Worker    constexpr pointer   operator->() const;
98*58b9f456SAndroid Build Coastguard Worker    constexpr reverse_iterator& operator++();
99*58b9f456SAndroid Build Coastguard Worker    constexpr reverse_iterator  operator++(int);
100*58b9f456SAndroid Build Coastguard Worker    constexpr reverse_iterator& operator--();
101*58b9f456SAndroid Build Coastguard Worker    constexpr reverse_iterator  operator--(int);
102*58b9f456SAndroid Build Coastguard Worker    constexpr reverse_iterator  operator+ (difference_type n) const;
103*58b9f456SAndroid Build Coastguard Worker    constexpr reverse_iterator& operator+=(difference_type n);
104*58b9f456SAndroid Build Coastguard Worker    constexpr reverse_iterator  operator- (difference_type n) const;
105*58b9f456SAndroid Build Coastguard Worker    constexpr reverse_iterator& operator-=(difference_type n);
106*58b9f456SAndroid Build Coastguard Worker    constexpr reference         operator[](difference_type n) const;
107*58b9f456SAndroid Build Coastguard Worker};
108*58b9f456SAndroid Build Coastguard Worker
109*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
110*58b9f456SAndroid Build Coastguard Workerconstexpr bool                          // constexpr in C++17
111*58b9f456SAndroid Build Coastguard Workeroperator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
112*58b9f456SAndroid Build Coastguard Worker
113*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
114*58b9f456SAndroid Build Coastguard Workerconstexpr bool                          // constexpr in C++17
115*58b9f456SAndroid Build Coastguard Workeroperator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
116*58b9f456SAndroid Build Coastguard Worker
117*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
118*58b9f456SAndroid Build Coastguard Workerconstexpr bool                          // constexpr in C++17
119*58b9f456SAndroid Build Coastguard Workeroperator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
120*58b9f456SAndroid Build Coastguard Worker
121*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
122*58b9f456SAndroid Build Coastguard Workerconstexpr bool                          // constexpr in C++17
123*58b9f456SAndroid Build Coastguard Workeroperator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
124*58b9f456SAndroid Build Coastguard Worker
125*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
126*58b9f456SAndroid Build Coastguard Workerconstexpr bool                          // constexpr in C++17
127*58b9f456SAndroid Build Coastguard Workeroperator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
128*58b9f456SAndroid Build Coastguard Worker
129*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
130*58b9f456SAndroid Build Coastguard Workerconstexpr bool                          // constexpr in C++17
131*58b9f456SAndroid Build Coastguard Workeroperator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
132*58b9f456SAndroid Build Coastguard Worker
133*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
134*58b9f456SAndroid Build Coastguard Workerconstexpr auto
135*58b9f456SAndroid Build Coastguard Workeroperator-(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y)
136*58b9f456SAndroid Build Coastguard Worker-> decltype(__y.base() - __x.base());   // constexpr in C++17
137*58b9f456SAndroid Build Coastguard Worker
138*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator>
139*58b9f456SAndroid Build Coastguard Workerconstexpr reverse_iterator<Iterator>
140*58b9f456SAndroid Build Coastguard Workeroperator+(typename reverse_iterator<Iterator>::difference_type n,
141*58b9f456SAndroid Build Coastguard Worker          const reverse_iterator<Iterator>& x);   // constexpr in C++17
142*58b9f456SAndroid Build Coastguard Worker
143*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator>
144*58b9f456SAndroid Build Coastguard Workerconstexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14, constexpr in C++17
145*58b9f456SAndroid Build Coastguard Worker
146*58b9f456SAndroid Build Coastguard Workertemplate <class Container>
147*58b9f456SAndroid Build Coastguard Workerclass back_insert_iterator
148*58b9f456SAndroid Build Coastguard Worker{
149*58b9f456SAndroid Build Coastguard Workerprotected:
150*58b9f456SAndroid Build Coastguard Worker    Container* container;
151*58b9f456SAndroid Build Coastguard Workerpublic:
152*58b9f456SAndroid Build Coastguard Worker    typedef Container                   container_type;
153*58b9f456SAndroid Build Coastguard Worker    typedef void                        value_type;
154*58b9f456SAndroid Build Coastguard Worker    typedef void                        difference_type;
155*58b9f456SAndroid Build Coastguard Worker    typedef void                        reference;
156*58b9f456SAndroid Build Coastguard Worker    typedef void                        pointer;
157*58b9f456SAndroid Build Coastguard Worker
158*58b9f456SAndroid Build Coastguard Worker    explicit back_insert_iterator(Container& x);
159*58b9f456SAndroid Build Coastguard Worker    back_insert_iterator& operator=(const typename Container::value_type& value);
160*58b9f456SAndroid Build Coastguard Worker    back_insert_iterator& operator*();
161*58b9f456SAndroid Build Coastguard Worker    back_insert_iterator& operator++();
162*58b9f456SAndroid Build Coastguard Worker    back_insert_iterator  operator++(int);
163*58b9f456SAndroid Build Coastguard Worker};
164*58b9f456SAndroid Build Coastguard Worker
165*58b9f456SAndroid Build Coastguard Workertemplate <class Container> back_insert_iterator<Container> back_inserter(Container& x);
166*58b9f456SAndroid Build Coastguard Worker
167*58b9f456SAndroid Build Coastguard Workertemplate <class Container>
168*58b9f456SAndroid Build Coastguard Workerclass front_insert_iterator
169*58b9f456SAndroid Build Coastguard Worker{
170*58b9f456SAndroid Build Coastguard Workerprotected:
171*58b9f456SAndroid Build Coastguard Worker    Container* container;
172*58b9f456SAndroid Build Coastguard Workerpublic:
173*58b9f456SAndroid Build Coastguard Worker    typedef Container                    container_type;
174*58b9f456SAndroid Build Coastguard Worker    typedef void                         value_type;
175*58b9f456SAndroid Build Coastguard Worker    typedef void                         difference_type;
176*58b9f456SAndroid Build Coastguard Worker    typedef void                         reference;
177*58b9f456SAndroid Build Coastguard Worker    typedef void                         pointer;
178*58b9f456SAndroid Build Coastguard Worker
179*58b9f456SAndroid Build Coastguard Worker    explicit front_insert_iterator(Container& x);
180*58b9f456SAndroid Build Coastguard Worker    front_insert_iterator& operator=(const typename Container::value_type& value);
181*58b9f456SAndroid Build Coastguard Worker    front_insert_iterator& operator*();
182*58b9f456SAndroid Build Coastguard Worker    front_insert_iterator& operator++();
183*58b9f456SAndroid Build Coastguard Worker    front_insert_iterator  operator++(int);
184*58b9f456SAndroid Build Coastguard Worker};
185*58b9f456SAndroid Build Coastguard Worker
186*58b9f456SAndroid Build Coastguard Workertemplate <class Container> front_insert_iterator<Container> front_inserter(Container& x);
187*58b9f456SAndroid Build Coastguard Worker
188*58b9f456SAndroid Build Coastguard Workertemplate <class Container>
189*58b9f456SAndroid Build Coastguard Workerclass insert_iterator
190*58b9f456SAndroid Build Coastguard Worker{
191*58b9f456SAndroid Build Coastguard Workerprotected:
192*58b9f456SAndroid Build Coastguard Worker    Container* container;
193*58b9f456SAndroid Build Coastguard Worker    typename Container::iterator iter;
194*58b9f456SAndroid Build Coastguard Workerpublic:
195*58b9f456SAndroid Build Coastguard Worker    typedef Container              container_type;
196*58b9f456SAndroid Build Coastguard Worker    typedef void                   value_type;
197*58b9f456SAndroid Build Coastguard Worker    typedef void                   difference_type;
198*58b9f456SAndroid Build Coastguard Worker    typedef void                   reference;
199*58b9f456SAndroid Build Coastguard Worker    typedef void                   pointer;
200*58b9f456SAndroid Build Coastguard Worker
201*58b9f456SAndroid Build Coastguard Worker    insert_iterator(Container& x, typename Container::iterator i);
202*58b9f456SAndroid Build Coastguard Worker    insert_iterator& operator=(const typename Container::value_type& value);
203*58b9f456SAndroid Build Coastguard Worker    insert_iterator& operator*();
204*58b9f456SAndroid Build Coastguard Worker    insert_iterator& operator++();
205*58b9f456SAndroid Build Coastguard Worker    insert_iterator& operator++(int);
206*58b9f456SAndroid Build Coastguard Worker};
207*58b9f456SAndroid Build Coastguard Worker
208*58b9f456SAndroid Build Coastguard Workertemplate <class Container, class Iterator>
209*58b9f456SAndroid Build Coastguard Workerinsert_iterator<Container> inserter(Container& x, Iterator i);
210*58b9f456SAndroid Build Coastguard Worker
211*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator>
212*58b9f456SAndroid Build Coastguard Workerclass move_iterator {
213*58b9f456SAndroid Build Coastguard Workerpublic:
214*58b9f456SAndroid Build Coastguard Worker    typedef Iterator                                              iterator_type;
215*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<Iterator>::difference_type   difference_type;
216*58b9f456SAndroid Build Coastguard Worker    typedef Iterator                                              pointer;
217*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<Iterator>::value_type        value_type;
218*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<Iterator>::iterator_category iterator_category;
219*58b9f456SAndroid Build Coastguard Worker    typedef value_type&&                                          reference;
220*58b9f456SAndroid Build Coastguard Worker
221*58b9f456SAndroid Build Coastguard Worker    constexpr move_iterator();  // all the constexprs are in C++17
222*58b9f456SAndroid Build Coastguard Worker    constexpr explicit move_iterator(Iterator i);
223*58b9f456SAndroid Build Coastguard Worker    template <class U>
224*58b9f456SAndroid Build Coastguard Worker      constexpr move_iterator(const move_iterator<U>& u);
225*58b9f456SAndroid Build Coastguard Worker    template <class U>
226*58b9f456SAndroid Build Coastguard Worker      constexpr move_iterator& operator=(const move_iterator<U>& u);
227*58b9f456SAndroid Build Coastguard Worker    constexpr iterator_type base() const;
228*58b9f456SAndroid Build Coastguard Worker    constexpr reference operator*() const;
229*58b9f456SAndroid Build Coastguard Worker    constexpr pointer operator->() const;
230*58b9f456SAndroid Build Coastguard Worker    constexpr move_iterator& operator++();
231*58b9f456SAndroid Build Coastguard Worker    constexpr move_iterator operator++(int);
232*58b9f456SAndroid Build Coastguard Worker    constexpr move_iterator& operator--();
233*58b9f456SAndroid Build Coastguard Worker    constexpr move_iterator operator--(int);
234*58b9f456SAndroid Build Coastguard Worker    constexpr move_iterator operator+(difference_type n) const;
235*58b9f456SAndroid Build Coastguard Worker    constexpr move_iterator& operator+=(difference_type n);
236*58b9f456SAndroid Build Coastguard Worker    constexpr move_iterator operator-(difference_type n) const;
237*58b9f456SAndroid Build Coastguard Worker    constexpr move_iterator& operator-=(difference_type n);
238*58b9f456SAndroid Build Coastguard Worker    constexpr unspecified operator[](difference_type n) const;
239*58b9f456SAndroid Build Coastguard Workerprivate:
240*58b9f456SAndroid Build Coastguard Worker    Iterator current; // exposition only
241*58b9f456SAndroid Build Coastguard Worker};
242*58b9f456SAndroid Build Coastguard Worker
243*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
244*58b9f456SAndroid Build Coastguard Workerconstexpr bool   // constexpr in C++17
245*58b9f456SAndroid Build Coastguard Workeroperator==(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
246*58b9f456SAndroid Build Coastguard Worker
247*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
248*58b9f456SAndroid Build Coastguard Workerconstexpr bool   // constexpr in C++17
249*58b9f456SAndroid Build Coastguard Workeroperator!=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
250*58b9f456SAndroid Build Coastguard Worker
251*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
252*58b9f456SAndroid Build Coastguard Workerconstexpr bool   // constexpr in C++17
253*58b9f456SAndroid Build Coastguard Workeroperator<(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
254*58b9f456SAndroid Build Coastguard Worker
255*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
256*58b9f456SAndroid Build Coastguard Workerconstexpr bool   // constexpr in C++17
257*58b9f456SAndroid Build Coastguard Workeroperator<=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
258*58b9f456SAndroid Build Coastguard Worker
259*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
260*58b9f456SAndroid Build Coastguard Workerconstexpr bool   // constexpr in C++17
261*58b9f456SAndroid Build Coastguard Workeroperator>(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
262*58b9f456SAndroid Build Coastguard Worker
263*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
264*58b9f456SAndroid Build Coastguard Workerconstexpr bool   // constexpr in C++17
265*58b9f456SAndroid Build Coastguard Workeroperator>=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
266*58b9f456SAndroid Build Coastguard Worker
267*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator1, class Iterator2>
268*58b9f456SAndroid Build Coastguard Workerconstexpr auto   // constexpr in C++17
269*58b9f456SAndroid Build Coastguard Workeroperator-(const move_iterator<Iterator1>& x,
270*58b9f456SAndroid Build Coastguard Worker          const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base());
271*58b9f456SAndroid Build Coastguard Worker
272*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator>
273*58b9f456SAndroid Build Coastguard Workerconstexpr move_iterator<Iterator> operator+(   // constexpr in C++17
274*58b9f456SAndroid Build Coastguard Worker            typename move_iterator<Iterator>::difference_type n,
275*58b9f456SAndroid Build Coastguard Worker            const move_iterator<Iterator>& x);
276*58b9f456SAndroid Build Coastguard Worker
277*58b9f456SAndroid Build Coastguard Workertemplate <class Iterator>   // constexpr in C++17
278*58b9f456SAndroid Build Coastguard Workerconstexpr  move_iterator<Iterator> make_move_iterator(const Iterator& i);
279*58b9f456SAndroid Build Coastguard Worker
280*58b9f456SAndroid Build Coastguard Worker
281*58b9f456SAndroid Build Coastguard Workertemplate <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t>
282*58b9f456SAndroid Build Coastguard Workerclass istream_iterator
283*58b9f456SAndroid Build Coastguard Worker    : public iterator<input_iterator_tag, T, Distance, const T*, const T&>
284*58b9f456SAndroid Build Coastguard Worker{
285*58b9f456SAndroid Build Coastguard Workerpublic:
286*58b9f456SAndroid Build Coastguard Worker    typedef charT char_type;
287*58b9f456SAndroid Build Coastguard Worker    typedef traits traits_type;
288*58b9f456SAndroid Build Coastguard Worker    typedef basic_istream<charT,traits> istream_type;
289*58b9f456SAndroid Build Coastguard Worker
290*58b9f456SAndroid Build Coastguard Worker    constexpr istream_iterator();
291*58b9f456SAndroid Build Coastguard Worker    istream_iterator(istream_type& s);
292*58b9f456SAndroid Build Coastguard Worker    istream_iterator(const istream_iterator& x);
293*58b9f456SAndroid Build Coastguard Worker    ~istream_iterator();
294*58b9f456SAndroid Build Coastguard Worker
295*58b9f456SAndroid Build Coastguard Worker    const T& operator*() const;
296*58b9f456SAndroid Build Coastguard Worker    const T* operator->() const;
297*58b9f456SAndroid Build Coastguard Worker    istream_iterator& operator++();
298*58b9f456SAndroid Build Coastguard Worker    istream_iterator  operator++(int);
299*58b9f456SAndroid Build Coastguard Worker};
300*58b9f456SAndroid Build Coastguard Worker
301*58b9f456SAndroid Build Coastguard Workertemplate <class T, class charT, class traits, class Distance>
302*58b9f456SAndroid Build Coastguard Workerbool operator==(const istream_iterator<T,charT,traits,Distance>& x,
303*58b9f456SAndroid Build Coastguard Worker                const istream_iterator<T,charT,traits,Distance>& y);
304*58b9f456SAndroid Build Coastguard Workertemplate <class T, class charT, class traits, class Distance>
305*58b9f456SAndroid Build Coastguard Workerbool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
306*58b9f456SAndroid Build Coastguard Worker                const istream_iterator<T,charT,traits,Distance>& y);
307*58b9f456SAndroid Build Coastguard Worker
308*58b9f456SAndroid Build Coastguard Workertemplate <class T, class charT = char, class traits = char_traits<charT> >
309*58b9f456SAndroid Build Coastguard Workerclass ostream_iterator
310*58b9f456SAndroid Build Coastguard Worker    : public iterator<output_iterator_tag, void, void, void ,void>
311*58b9f456SAndroid Build Coastguard Worker{
312*58b9f456SAndroid Build Coastguard Workerpublic:
313*58b9f456SAndroid Build Coastguard Worker    typedef charT char_type;
314*58b9f456SAndroid Build Coastguard Worker    typedef traits traits_type;
315*58b9f456SAndroid Build Coastguard Worker    typedef basic_ostream<charT,traits> ostream_type;
316*58b9f456SAndroid Build Coastguard Worker
317*58b9f456SAndroid Build Coastguard Worker    ostream_iterator(ostream_type& s);
318*58b9f456SAndroid Build Coastguard Worker    ostream_iterator(ostream_type& s, const charT* delimiter);
319*58b9f456SAndroid Build Coastguard Worker    ostream_iterator(const ostream_iterator& x);
320*58b9f456SAndroid Build Coastguard Worker    ~ostream_iterator();
321*58b9f456SAndroid Build Coastguard Worker    ostream_iterator& operator=(const T& value);
322*58b9f456SAndroid Build Coastguard Worker
323*58b9f456SAndroid Build Coastguard Worker    ostream_iterator& operator*();
324*58b9f456SAndroid Build Coastguard Worker    ostream_iterator& operator++();
325*58b9f456SAndroid Build Coastguard Worker    ostream_iterator& operator++(int);
326*58b9f456SAndroid Build Coastguard Worker};
327*58b9f456SAndroid Build Coastguard Worker
328*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits = char_traits<charT> >
329*58b9f456SAndroid Build Coastguard Workerclass istreambuf_iterator
330*58b9f456SAndroid Build Coastguard Worker    : public iterator<input_iterator_tag, charT,
331*58b9f456SAndroid Build Coastguard Worker                      typename traits::off_type, unspecified,
332*58b9f456SAndroid Build Coastguard Worker                      charT>
333*58b9f456SAndroid Build Coastguard Worker{
334*58b9f456SAndroid Build Coastguard Workerpublic:
335*58b9f456SAndroid Build Coastguard Worker    typedef charT                         char_type;
336*58b9f456SAndroid Build Coastguard Worker    typedef traits                        traits_type;
337*58b9f456SAndroid Build Coastguard Worker    typedef typename traits::int_type     int_type;
338*58b9f456SAndroid Build Coastguard Worker    typedef basic_streambuf<charT,traits> streambuf_type;
339*58b9f456SAndroid Build Coastguard Worker    typedef basic_istream<charT,traits>   istream_type;
340*58b9f456SAndroid Build Coastguard Worker
341*58b9f456SAndroid Build Coastguard Worker    istreambuf_iterator() noexcept;
342*58b9f456SAndroid Build Coastguard Worker    istreambuf_iterator(istream_type& s) noexcept;
343*58b9f456SAndroid Build Coastguard Worker    istreambuf_iterator(streambuf_type* s) noexcept;
344*58b9f456SAndroid Build Coastguard Worker    istreambuf_iterator(a-private-type) noexcept;
345*58b9f456SAndroid Build Coastguard Worker
346*58b9f456SAndroid Build Coastguard Worker    charT                operator*() const;
347*58b9f456SAndroid Build Coastguard Worker    pointer operator->() const;
348*58b9f456SAndroid Build Coastguard Worker    istreambuf_iterator& operator++();
349*58b9f456SAndroid Build Coastguard Worker    a-private-type       operator++(int);
350*58b9f456SAndroid Build Coastguard Worker
351*58b9f456SAndroid Build Coastguard Worker    bool equal(const istreambuf_iterator& b) const;
352*58b9f456SAndroid Build Coastguard Worker};
353*58b9f456SAndroid Build Coastguard Worker
354*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits>
355*58b9f456SAndroid Build Coastguard Workerbool operator==(const istreambuf_iterator<charT,traits>& a,
356*58b9f456SAndroid Build Coastguard Worker                const istreambuf_iterator<charT,traits>& b);
357*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits>
358*58b9f456SAndroid Build Coastguard Workerbool operator!=(const istreambuf_iterator<charT,traits>& a,
359*58b9f456SAndroid Build Coastguard Worker                const istreambuf_iterator<charT,traits>& b);
360*58b9f456SAndroid Build Coastguard Worker
361*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits = char_traits<charT> >
362*58b9f456SAndroid Build Coastguard Workerclass ostreambuf_iterator
363*58b9f456SAndroid Build Coastguard Worker    : public iterator<output_iterator_tag, void, void, void, void>
364*58b9f456SAndroid Build Coastguard Worker{
365*58b9f456SAndroid Build Coastguard Workerpublic:
366*58b9f456SAndroid Build Coastguard Worker    typedef charT                         char_type;
367*58b9f456SAndroid Build Coastguard Worker    typedef traits                        traits_type;
368*58b9f456SAndroid Build Coastguard Worker    typedef basic_streambuf<charT,traits> streambuf_type;
369*58b9f456SAndroid Build Coastguard Worker    typedef basic_ostream<charT,traits>   ostream_type;
370*58b9f456SAndroid Build Coastguard Worker
371*58b9f456SAndroid Build Coastguard Worker    ostreambuf_iterator(ostream_type& s) noexcept;
372*58b9f456SAndroid Build Coastguard Worker    ostreambuf_iterator(streambuf_type* s) noexcept;
373*58b9f456SAndroid Build Coastguard Worker    ostreambuf_iterator& operator=(charT c);
374*58b9f456SAndroid Build Coastguard Worker    ostreambuf_iterator& operator*();
375*58b9f456SAndroid Build Coastguard Worker    ostreambuf_iterator& operator++();
376*58b9f456SAndroid Build Coastguard Worker    ostreambuf_iterator& operator++(int);
377*58b9f456SAndroid Build Coastguard Worker    bool failed() const noexcept;
378*58b9f456SAndroid Build Coastguard Worker};
379*58b9f456SAndroid Build Coastguard Worker
380*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto begin(C& c) -> decltype(c.begin());
381*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto begin(const C& c) -> decltype(c.begin());
382*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto end(C& c) -> decltype(c.end());
383*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto end(const C& c) -> decltype(c.end());
384*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N> constexpr T* begin(T (&array)[N]);
385*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N> constexpr T* end(T (&array)[N]);
386*58b9f456SAndroid Build Coastguard Worker
387*58b9f456SAndroid Build Coastguard Workertemplate <class C> auto constexpr cbegin(const C& c) -> decltype(std::begin(c));        // C++14
388*58b9f456SAndroid Build Coastguard Workertemplate <class C> auto constexpr cend(const C& c) -> decltype(std::end(c));            // C++14
389*58b9f456SAndroid Build Coastguard Workertemplate <class C> auto constexpr rbegin(C& c) -> decltype(c.rbegin());                 // C++14
390*58b9f456SAndroid Build Coastguard Workertemplate <class C> auto constexpr rbegin(const C& c) -> decltype(c.rbegin());           // C++14
391*58b9f456SAndroid Build Coastguard Workertemplate <class C> auto constexpr rend(C& c) -> decltype(c.rend());                     // C++14
392*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto rend(const C& c) -> decltype(c.rend());               // C++14
393*58b9f456SAndroid Build Coastguard Workertemplate <class E> reverse_iterator<const E*> constexpr rbegin(initializer_list<E> il); // C++14
394*58b9f456SAndroid Build Coastguard Workertemplate <class E> reverse_iterator<const E*> constexpr rend(initializer_list<E> il);   // C++14
395*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N> reverse_iterator<T*> constexpr rbegin(T (&array)[N]);      // C++14
396*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N> reverse_iterator<T*> constexpr rend(T (&array)[N]);        // C++14
397*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c));      // C++14
398*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c));          // C++14
399*58b9f456SAndroid Build Coastguard Worker
400*58b9f456SAndroid Build Coastguard Worker// 24.8, container access:
401*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto size(const C& c) -> decltype(c.size());         // C++17
402*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17
403*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto empty(const C& c) -> decltype(c.empty());       // C++17
404*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept;  // C++17
405*58b9f456SAndroid Build Coastguard Workertemplate <class E> constexpr bool empty(initializer_list<E> il) noexcept;         // C++17
406*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto data(C& c) -> decltype(c.data());               // C++17
407*58b9f456SAndroid Build Coastguard Workertemplate <class C> constexpr auto data(const C& c) -> decltype(c.data());         // C++17
408*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept;           // C++17
409*58b9f456SAndroid Build Coastguard Workertemplate <class E> constexpr const E* data(initializer_list<E> il) noexcept;      // C++17
410*58b9f456SAndroid Build Coastguard Worker
411*58b9f456SAndroid Build Coastguard Worker}  // std
412*58b9f456SAndroid Build Coastguard Worker
413*58b9f456SAndroid Build Coastguard Worker*/
414*58b9f456SAndroid Build Coastguard Worker
415*58b9f456SAndroid Build Coastguard Worker#include <__config>
416*58b9f456SAndroid Build Coastguard Worker#include <iosfwd> // for forward declarations of vector and string.
417*58b9f456SAndroid Build Coastguard Worker#include <__functional_base>
418*58b9f456SAndroid Build Coastguard Worker#include <type_traits>
419*58b9f456SAndroid Build Coastguard Worker#include <cstddef>
420*58b9f456SAndroid Build Coastguard Worker#include <initializer_list>
421*58b9f456SAndroid Build Coastguard Worker#include <version>
422*58b9f456SAndroid Build Coastguard Worker#ifdef __APPLE__
423*58b9f456SAndroid Build Coastguard Worker#include <Availability.h>
424*58b9f456SAndroid Build Coastguard Worker#endif
425*58b9f456SAndroid Build Coastguard Worker
426*58b9f456SAndroid Build Coastguard Worker#include <__debug>
427*58b9f456SAndroid Build Coastguard Worker
428*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
429*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
430*58b9f456SAndroid Build Coastguard Worker#endif
431*58b9f456SAndroid Build Coastguard Worker
432*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
433*58b9f456SAndroid Build Coastguard Worker
434*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS input_iterator_tag {};
435*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS output_iterator_tag {};
436*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS forward_iterator_tag       : public input_iterator_tag {};
437*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {};
438*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {};
439*58b9f456SAndroid Build Coastguard Worker
440*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
441*58b9f456SAndroid Build Coastguard Workerstruct __has_iterator_typedefs
442*58b9f456SAndroid Build Coastguard Worker{
443*58b9f456SAndroid Build Coastguard Workerprivate:
444*58b9f456SAndroid Build Coastguard Worker    struct __two {char __lx; char __lxx;};
445*58b9f456SAndroid Build Coastguard Worker    template <class _Up> static __two __test(...);
446*58b9f456SAndroid Build Coastguard Worker    template <class _Up> static char __test(typename std::__void_t<typename _Up::iterator_category>::type* = 0,
447*58b9f456SAndroid Build Coastguard Worker    										typename std::__void_t<typename _Up::difference_type>::type* = 0,
448*58b9f456SAndroid Build Coastguard Worker    										typename std::__void_t<typename _Up::value_type>::type* = 0,
449*58b9f456SAndroid Build Coastguard Worker    										typename std::__void_t<typename _Up::reference>::type* = 0,
450*58b9f456SAndroid Build Coastguard Worker    										typename std::__void_t<typename _Up::pointer>::type* = 0
451*58b9f456SAndroid Build Coastguard Worker    										);
452*58b9f456SAndroid Build Coastguard Workerpublic:
453*58b9f456SAndroid Build Coastguard Worker    static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1;
454*58b9f456SAndroid Build Coastguard Worker};
455*58b9f456SAndroid Build Coastguard Worker
456*58b9f456SAndroid Build Coastguard Worker
457*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
458*58b9f456SAndroid Build Coastguard Workerstruct __has_iterator_category
459*58b9f456SAndroid Build Coastguard Worker{
460*58b9f456SAndroid Build Coastguard Workerprivate:
461*58b9f456SAndroid Build Coastguard Worker    struct __two {char __lx; char __lxx;};
462*58b9f456SAndroid Build Coastguard Worker    template <class _Up> static __two __test(...);
463*58b9f456SAndroid Build Coastguard Worker    template <class _Up> static char __test(typename _Up::iterator_category* = 0);
464*58b9f456SAndroid Build Coastguard Workerpublic:
465*58b9f456SAndroid Build Coastguard Worker    static const bool value = sizeof(__test<_Tp>(0)) == 1;
466*58b9f456SAndroid Build Coastguard Worker};
467*58b9f456SAndroid Build Coastguard Worker
468*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter, bool> struct __iterator_traits_impl {};
469*58b9f456SAndroid Build Coastguard Worker
470*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
471*58b9f456SAndroid Build Coastguard Workerstruct __iterator_traits_impl<_Iter, true>
472*58b9f456SAndroid Build Coastguard Worker{
473*58b9f456SAndroid Build Coastguard Worker    typedef typename _Iter::difference_type   difference_type;
474*58b9f456SAndroid Build Coastguard Worker    typedef typename _Iter::value_type        value_type;
475*58b9f456SAndroid Build Coastguard Worker    typedef typename _Iter::pointer           pointer;
476*58b9f456SAndroid Build Coastguard Worker    typedef typename _Iter::reference         reference;
477*58b9f456SAndroid Build Coastguard Worker    typedef typename _Iter::iterator_category iterator_category;
478*58b9f456SAndroid Build Coastguard Worker};
479*58b9f456SAndroid Build Coastguard Worker
480*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter, bool> struct __iterator_traits {};
481*58b9f456SAndroid Build Coastguard Worker
482*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
483*58b9f456SAndroid Build Coastguard Workerstruct __iterator_traits<_Iter, true>
484*58b9f456SAndroid Build Coastguard Worker    :  __iterator_traits_impl
485*58b9f456SAndroid Build Coastguard Worker      <
486*58b9f456SAndroid Build Coastguard Worker        _Iter,
487*58b9f456SAndroid Build Coastguard Worker        is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||
488*58b9f456SAndroid Build Coastguard Worker        is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value
489*58b9f456SAndroid Build Coastguard Worker      >
490*58b9f456SAndroid Build Coastguard Worker{};
491*58b9f456SAndroid Build Coastguard Worker
492*58b9f456SAndroid Build Coastguard Worker// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category
493*58b9f456SAndroid Build Coastguard Worker//    exists.  Else iterator_traits<Iterator> will be an empty class.  This is a
494*58b9f456SAndroid Build Coastguard Worker//    conforming extension which allows some programs to compile and behave as
495*58b9f456SAndroid Build Coastguard Worker//    the client expects instead of failing at compile time.
496*58b9f456SAndroid Build Coastguard Worker
497*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
498*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS iterator_traits
499*58b9f456SAndroid Build Coastguard Worker    : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {};
500*58b9f456SAndroid Build Coastguard Worker
501*58b9f456SAndroid Build Coastguard Workertemplate<class _Tp>
502*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
503*58b9f456SAndroid Build Coastguard Worker{
504*58b9f456SAndroid Build Coastguard Worker    typedef ptrdiff_t difference_type;
505*58b9f456SAndroid Build Coastguard Worker    typedef typename remove_cv<_Tp>::type value_type;
506*58b9f456SAndroid Build Coastguard Worker    typedef _Tp* pointer;
507*58b9f456SAndroid Build Coastguard Worker    typedef _Tp& reference;
508*58b9f456SAndroid Build Coastguard Worker    typedef random_access_iterator_tag iterator_category;
509*58b9f456SAndroid Build Coastguard Worker};
510*58b9f456SAndroid Build Coastguard Worker
511*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value>
512*58b9f456SAndroid Build Coastguard Workerstruct __has_iterator_category_convertible_to
513*58b9f456SAndroid Build Coastguard Worker    : public integral_constant<bool, is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up>::value>
514*58b9f456SAndroid Build Coastguard Worker{};
515*58b9f456SAndroid Build Coastguard Worker
516*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Up>
517*58b9f456SAndroid Build Coastguard Workerstruct __has_iterator_category_convertible_to<_Tp, _Up, false> : public false_type {};
518*58b9f456SAndroid Build Coastguard Worker
519*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
520*58b9f456SAndroid Build Coastguard Workerstruct __is_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {};
521*58b9f456SAndroid Build Coastguard Worker
522*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
523*58b9f456SAndroid Build Coastguard Workerstruct __is_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {};
524*58b9f456SAndroid Build Coastguard Worker
525*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
526*58b9f456SAndroid Build Coastguard Workerstruct __is_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {};
527*58b9f456SAndroid Build Coastguard Worker
528*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
529*58b9f456SAndroid Build Coastguard Workerstruct __is_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {};
530*58b9f456SAndroid Build Coastguard Worker
531*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
532*58b9f456SAndroid Build Coastguard Workerstruct __is_exactly_input_iterator
533*58b9f456SAndroid Build Coastguard Worker    : public integral_constant<bool,
534*58b9f456SAndroid Build Coastguard Worker         __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&
535*58b9f456SAndroid Build Coastguard Worker        !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {};
536*58b9f456SAndroid Build Coastguard Worker
537*58b9f456SAndroid Build Coastguard Workertemplate<class _Category, class _Tp, class _Distance = ptrdiff_t,
538*58b9f456SAndroid Build Coastguard Worker         class _Pointer = _Tp*, class _Reference = _Tp&>
539*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS iterator
540*58b9f456SAndroid Build Coastguard Worker{
541*58b9f456SAndroid Build Coastguard Worker    typedef _Tp        value_type;
542*58b9f456SAndroid Build Coastguard Worker    typedef _Distance  difference_type;
543*58b9f456SAndroid Build Coastguard Worker    typedef _Pointer   pointer;
544*58b9f456SAndroid Build Coastguard Worker    typedef _Reference reference;
545*58b9f456SAndroid Build Coastguard Worker    typedef _Category  iterator_category;
546*58b9f456SAndroid Build Coastguard Worker};
547*58b9f456SAndroid Build Coastguard Worker
548*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIter>
549*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
550*58b9f456SAndroid Build Coastguard Workervoid __advance(_InputIter& __i,
551*58b9f456SAndroid Build Coastguard Worker             typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag)
552*58b9f456SAndroid Build Coastguard Worker{
553*58b9f456SAndroid Build Coastguard Worker    for (; __n > 0; --__n)
554*58b9f456SAndroid Build Coastguard Worker        ++__i;
555*58b9f456SAndroid Build Coastguard Worker}
556*58b9f456SAndroid Build Coastguard Worker
557*58b9f456SAndroid Build Coastguard Workertemplate <class _BiDirIter>
558*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
559*58b9f456SAndroid Build Coastguard Workervoid __advance(_BiDirIter& __i,
560*58b9f456SAndroid Build Coastguard Worker             typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag)
561*58b9f456SAndroid Build Coastguard Worker{
562*58b9f456SAndroid Build Coastguard Worker    if (__n >= 0)
563*58b9f456SAndroid Build Coastguard Worker        for (; __n > 0; --__n)
564*58b9f456SAndroid Build Coastguard Worker            ++__i;
565*58b9f456SAndroid Build Coastguard Worker    else
566*58b9f456SAndroid Build Coastguard Worker        for (; __n < 0; ++__n)
567*58b9f456SAndroid Build Coastguard Worker            --__i;
568*58b9f456SAndroid Build Coastguard Worker}
569*58b9f456SAndroid Build Coastguard Worker
570*58b9f456SAndroid Build Coastguard Workertemplate <class _RandIter>
571*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
572*58b9f456SAndroid Build Coastguard Workervoid __advance(_RandIter& __i,
573*58b9f456SAndroid Build Coastguard Worker             typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag)
574*58b9f456SAndroid Build Coastguard Worker{
575*58b9f456SAndroid Build Coastguard Worker   __i += __n;
576*58b9f456SAndroid Build Coastguard Worker}
577*58b9f456SAndroid Build Coastguard Worker
578*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIter>
579*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
580*58b9f456SAndroid Build Coastguard Workervoid advance(_InputIter& __i,
581*58b9f456SAndroid Build Coastguard Worker             typename iterator_traits<_InputIter>::difference_type __n)
582*58b9f456SAndroid Build Coastguard Worker{
583*58b9f456SAndroid Build Coastguard Worker    __advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
584*58b9f456SAndroid Build Coastguard Worker}
585*58b9f456SAndroid Build Coastguard Worker
586*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIter>
587*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
588*58b9f456SAndroid Build Coastguard Workertypename iterator_traits<_InputIter>::difference_type
589*58b9f456SAndroid Build Coastguard Worker__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
590*58b9f456SAndroid Build Coastguard Worker{
591*58b9f456SAndroid Build Coastguard Worker    typename iterator_traits<_InputIter>::difference_type __r(0);
592*58b9f456SAndroid Build Coastguard Worker    for (; __first != __last; ++__first)
593*58b9f456SAndroid Build Coastguard Worker        ++__r;
594*58b9f456SAndroid Build Coastguard Worker    return __r;
595*58b9f456SAndroid Build Coastguard Worker}
596*58b9f456SAndroid Build Coastguard Worker
597*58b9f456SAndroid Build Coastguard Workertemplate <class _RandIter>
598*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
599*58b9f456SAndroid Build Coastguard Workertypename iterator_traits<_RandIter>::difference_type
600*58b9f456SAndroid Build Coastguard Worker__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
601*58b9f456SAndroid Build Coastguard Worker{
602*58b9f456SAndroid Build Coastguard Worker    return __last - __first;
603*58b9f456SAndroid Build Coastguard Worker}
604*58b9f456SAndroid Build Coastguard Worker
605*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIter>
606*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
607*58b9f456SAndroid Build Coastguard Workertypename iterator_traits<_InputIter>::difference_type
608*58b9f456SAndroid Build Coastguard Workerdistance(_InputIter __first, _InputIter __last)
609*58b9f456SAndroid Build Coastguard Worker{
610*58b9f456SAndroid Build Coastguard Worker    return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
611*58b9f456SAndroid Build Coastguard Worker}
612*58b9f456SAndroid Build Coastguard Worker
613*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIter>
614*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
615*58b9f456SAndroid Build Coastguard Workertypename enable_if
616*58b9f456SAndroid Build Coastguard Worker<
617*58b9f456SAndroid Build Coastguard Worker    __is_input_iterator<_InputIter>::value,
618*58b9f456SAndroid Build Coastguard Worker    _InputIter
619*58b9f456SAndroid Build Coastguard Worker>::type
620*58b9f456SAndroid Build Coastguard Workernext(_InputIter __x,
621*58b9f456SAndroid Build Coastguard Worker     typename iterator_traits<_InputIter>::difference_type __n = 1)
622*58b9f456SAndroid Build Coastguard Worker{
623*58b9f456SAndroid Build Coastguard Worker    _VSTD::advance(__x, __n);
624*58b9f456SAndroid Build Coastguard Worker    return __x;
625*58b9f456SAndroid Build Coastguard Worker}
626*58b9f456SAndroid Build Coastguard Worker
627*58b9f456SAndroid Build Coastguard Workertemplate <class _BidirectionalIter>
628*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
629*58b9f456SAndroid Build Coastguard Workertypename enable_if
630*58b9f456SAndroid Build Coastguard Worker<
631*58b9f456SAndroid Build Coastguard Worker    __is_bidirectional_iterator<_BidirectionalIter>::value,
632*58b9f456SAndroid Build Coastguard Worker    _BidirectionalIter
633*58b9f456SAndroid Build Coastguard Worker>::type
634*58b9f456SAndroid Build Coastguard Workerprev(_BidirectionalIter __x,
635*58b9f456SAndroid Build Coastguard Worker     typename iterator_traits<_BidirectionalIter>::difference_type __n = 1)
636*58b9f456SAndroid Build Coastguard Worker{
637*58b9f456SAndroid Build Coastguard Worker    _VSTD::advance(__x, -__n);
638*58b9f456SAndroid Build Coastguard Worker    return __x;
639*58b9f456SAndroid Build Coastguard Worker}
640*58b9f456SAndroid Build Coastguard Worker
641*58b9f456SAndroid Build Coastguard Worker
642*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class = void>
643*58b9f456SAndroid Build Coastguard Workerstruct __is_stashing_iterator : false_type {};
644*58b9f456SAndroid Build Coastguard Worker
645*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
646*58b9f456SAndroid Build Coastguard Workerstruct __is_stashing_iterator<_Tp, typename __void_t<typename _Tp::__stashing_iterator_tag>::type>
647*58b9f456SAndroid Build Coastguard Worker  : true_type {};
648*58b9f456SAndroid Build Coastguard Worker
649*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
650*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS reverse_iterator
651*58b9f456SAndroid Build Coastguard Worker    : public iterator<typename iterator_traits<_Iter>::iterator_category,
652*58b9f456SAndroid Build Coastguard Worker                      typename iterator_traits<_Iter>::value_type,
653*58b9f456SAndroid Build Coastguard Worker                      typename iterator_traits<_Iter>::difference_type,
654*58b9f456SAndroid Build Coastguard Worker                      typename iterator_traits<_Iter>::pointer,
655*58b9f456SAndroid Build Coastguard Worker                      typename iterator_traits<_Iter>::reference>
656*58b9f456SAndroid Build Coastguard Worker{
657*58b9f456SAndroid Build Coastguard Workerprivate:
658*58b9f456SAndroid Build Coastguard Worker    /*mutable*/ _Iter __t;  // no longer used as of LWG #2360, not removed due to ABI break
659*58b9f456SAndroid Build Coastguard Worker
660*58b9f456SAndroid Build Coastguard Worker    static_assert(!__is_stashing_iterator<_Iter>::value,
661*58b9f456SAndroid Build Coastguard Worker      "The specified iterator type cannot be used with reverse_iterator; "
662*58b9f456SAndroid Build Coastguard Worker      "Using stashing iterators with reverse_iterator causes undefined behavior");
663*58b9f456SAndroid Build Coastguard Worker
664*58b9f456SAndroid Build Coastguard Workerprotected:
665*58b9f456SAndroid Build Coastguard Worker    _Iter current;
666*58b9f456SAndroid Build Coastguard Workerpublic:
667*58b9f456SAndroid Build Coastguard Worker    typedef _Iter                                            iterator_type;
668*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<_Iter>::difference_type difference_type;
669*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<_Iter>::reference       reference;
670*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<_Iter>::pointer         pointer;
671*58b9f456SAndroid Build Coastguard Worker
672*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
673*58b9f456SAndroid Build Coastguard Worker    reverse_iterator() : __t(), current() {}
674*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
675*58b9f456SAndroid Build Coastguard Worker    explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {}
676*58b9f456SAndroid Build Coastguard Worker    template <class _Up>
677*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
678*58b9f456SAndroid Build Coastguard Worker        reverse_iterator(const reverse_iterator<_Up>& __u) : __t(__u.base()), current(__u.base()) {}
679*58b9f456SAndroid Build Coastguard Worker    template <class _Up>
680*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
681*58b9f456SAndroid Build Coastguard Worker        reverse_iterator& operator=(const reverse_iterator<_Up>& __u)
682*58b9f456SAndroid Build Coastguard Worker            { __t = current = __u.base(); return *this; }
683*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
684*58b9f456SAndroid Build Coastguard Worker    _Iter base() const {return current;}
685*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
686*58b9f456SAndroid Build Coastguard Worker    reference operator*() const {_Iter __tmp = current; return *--__tmp;}
687*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
688*58b9f456SAndroid Build Coastguard Worker    pointer  operator->() const {return _VSTD::addressof(operator*());}
689*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
690*58b9f456SAndroid Build Coastguard Worker    reverse_iterator& operator++() {--current; return *this;}
691*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
692*58b9f456SAndroid Build Coastguard Worker    reverse_iterator  operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
693*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
694*58b9f456SAndroid Build Coastguard Worker    reverse_iterator& operator--() {++current; return *this;}
695*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
696*58b9f456SAndroid Build Coastguard Worker    reverse_iterator  operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
697*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
698*58b9f456SAndroid Build Coastguard Worker    reverse_iterator  operator+ (difference_type __n) const {return reverse_iterator(current - __n);}
699*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
700*58b9f456SAndroid Build Coastguard Worker    reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}
701*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
702*58b9f456SAndroid Build Coastguard Worker    reverse_iterator  operator- (difference_type __n) const {return reverse_iterator(current + __n);}
703*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
704*58b9f456SAndroid Build Coastguard Worker    reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}
705*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
706*58b9f456SAndroid Build Coastguard Worker    reference         operator[](difference_type __n) const {return *(*this + __n);}
707*58b9f456SAndroid Build Coastguard Worker};
708*58b9f456SAndroid Build Coastguard Worker
709*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
710*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
711*58b9f456SAndroid Build Coastguard Workerbool
712*58b9f456SAndroid Build Coastguard Workeroperator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
713*58b9f456SAndroid Build Coastguard Worker{
714*58b9f456SAndroid Build Coastguard Worker    return __x.base() == __y.base();
715*58b9f456SAndroid Build Coastguard Worker}
716*58b9f456SAndroid Build Coastguard Worker
717*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
718*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
719*58b9f456SAndroid Build Coastguard Workerbool
720*58b9f456SAndroid Build Coastguard Workeroperator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
721*58b9f456SAndroid Build Coastguard Worker{
722*58b9f456SAndroid Build Coastguard Worker    return __x.base() > __y.base();
723*58b9f456SAndroid Build Coastguard Worker}
724*58b9f456SAndroid Build Coastguard Worker
725*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
726*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
727*58b9f456SAndroid Build Coastguard Workerbool
728*58b9f456SAndroid Build Coastguard Workeroperator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
729*58b9f456SAndroid Build Coastguard Worker{
730*58b9f456SAndroid Build Coastguard Worker    return __x.base() != __y.base();
731*58b9f456SAndroid Build Coastguard Worker}
732*58b9f456SAndroid Build Coastguard Worker
733*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
734*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
735*58b9f456SAndroid Build Coastguard Workerbool
736*58b9f456SAndroid Build Coastguard Workeroperator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
737*58b9f456SAndroid Build Coastguard Worker{
738*58b9f456SAndroid Build Coastguard Worker    return __x.base() < __y.base();
739*58b9f456SAndroid Build Coastguard Worker}
740*58b9f456SAndroid Build Coastguard Worker
741*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
742*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
743*58b9f456SAndroid Build Coastguard Workerbool
744*58b9f456SAndroid Build Coastguard Workeroperator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
745*58b9f456SAndroid Build Coastguard Worker{
746*58b9f456SAndroid Build Coastguard Worker    return __x.base() <= __y.base();
747*58b9f456SAndroid Build Coastguard Worker}
748*58b9f456SAndroid Build Coastguard Worker
749*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
750*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
751*58b9f456SAndroid Build Coastguard Workerbool
752*58b9f456SAndroid Build Coastguard Workeroperator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
753*58b9f456SAndroid Build Coastguard Worker{
754*58b9f456SAndroid Build Coastguard Worker    return __x.base() >= __y.base();
755*58b9f456SAndroid Build Coastguard Worker}
756*58b9f456SAndroid Build Coastguard Worker
757*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
758*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
759*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
760*58b9f456SAndroid Build Coastguard Workerauto
761*58b9f456SAndroid Build Coastguard Workeroperator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
762*58b9f456SAndroid Build Coastguard Worker-> decltype(__y.base() - __x.base())
763*58b9f456SAndroid Build Coastguard Worker{
764*58b9f456SAndroid Build Coastguard Worker    return __y.base() - __x.base();
765*58b9f456SAndroid Build Coastguard Worker}
766*58b9f456SAndroid Build Coastguard Worker#else
767*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
768*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
769*58b9f456SAndroid Build Coastguard Workertypename reverse_iterator<_Iter1>::difference_type
770*58b9f456SAndroid Build Coastguard Workeroperator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
771*58b9f456SAndroid Build Coastguard Worker{
772*58b9f456SAndroid Build Coastguard Worker    return __y.base() - __x.base();
773*58b9f456SAndroid Build Coastguard Worker}
774*58b9f456SAndroid Build Coastguard Worker#endif
775*58b9f456SAndroid Build Coastguard Worker
776*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
777*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
778*58b9f456SAndroid Build Coastguard Workerreverse_iterator<_Iter>
779*58b9f456SAndroid Build Coastguard Workeroperator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x)
780*58b9f456SAndroid Build Coastguard Worker{
781*58b9f456SAndroid Build Coastguard Worker    return reverse_iterator<_Iter>(__x.base() - __n);
782*58b9f456SAndroid Build Coastguard Worker}
783*58b9f456SAndroid Build Coastguard Worker
784*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11
785*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
786*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
787*58b9f456SAndroid Build Coastguard Workerreverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
788*58b9f456SAndroid Build Coastguard Worker{
789*58b9f456SAndroid Build Coastguard Worker    return reverse_iterator<_Iter>(__i);
790*58b9f456SAndroid Build Coastguard Worker}
791*58b9f456SAndroid Build Coastguard Worker#endif
792*58b9f456SAndroid Build Coastguard Worker
793*58b9f456SAndroid Build Coastguard Workertemplate <class _Container>
794*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS back_insert_iterator
795*58b9f456SAndroid Build Coastguard Worker    : public iterator<output_iterator_tag,
796*58b9f456SAndroid Build Coastguard Worker                      void,
797*58b9f456SAndroid Build Coastguard Worker                      void,
798*58b9f456SAndroid Build Coastguard Worker                      void,
799*58b9f456SAndroid Build Coastguard Worker                      void>
800*58b9f456SAndroid Build Coastguard Worker{
801*58b9f456SAndroid Build Coastguard Workerprotected:
802*58b9f456SAndroid Build Coastguard Worker    _Container* container;
803*58b9f456SAndroid Build Coastguard Workerpublic:
804*58b9f456SAndroid Build Coastguard Worker    typedef _Container container_type;
805*58b9f456SAndroid Build Coastguard Worker
806*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
807*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_)
808*58b9f456SAndroid Build Coastguard Worker        {container->push_back(__value_); return *this;}
809*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
810*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value_)
811*58b9f456SAndroid Build Coastguard Worker        {container->push_back(_VSTD::move(__value_)); return *this;}
812*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
813*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator*()     {return *this;}
814*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++()    {return *this;}
815*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY back_insert_iterator  operator++(int) {return *this;}
816*58b9f456SAndroid Build Coastguard Worker};
817*58b9f456SAndroid Build Coastguard Worker
818*58b9f456SAndroid Build Coastguard Workertemplate <class _Container>
819*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
820*58b9f456SAndroid Build Coastguard Workerback_insert_iterator<_Container>
821*58b9f456SAndroid Build Coastguard Workerback_inserter(_Container& __x)
822*58b9f456SAndroid Build Coastguard Worker{
823*58b9f456SAndroid Build Coastguard Worker    return back_insert_iterator<_Container>(__x);
824*58b9f456SAndroid Build Coastguard Worker}
825*58b9f456SAndroid Build Coastguard Worker
826*58b9f456SAndroid Build Coastguard Workertemplate <class _Container>
827*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS front_insert_iterator
828*58b9f456SAndroid Build Coastguard Worker    : public iterator<output_iterator_tag,
829*58b9f456SAndroid Build Coastguard Worker                      void,
830*58b9f456SAndroid Build Coastguard Worker                      void,
831*58b9f456SAndroid Build Coastguard Worker                      void,
832*58b9f456SAndroid Build Coastguard Worker                      void>
833*58b9f456SAndroid Build Coastguard Worker{
834*58b9f456SAndroid Build Coastguard Workerprotected:
835*58b9f456SAndroid Build Coastguard Worker    _Container* container;
836*58b9f456SAndroid Build Coastguard Workerpublic:
837*58b9f456SAndroid Build Coastguard Worker    typedef _Container container_type;
838*58b9f456SAndroid Build Coastguard Worker
839*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
840*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_)
841*58b9f456SAndroid Build Coastguard Worker        {container->push_front(__value_); return *this;}
842*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
843*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value_)
844*58b9f456SAndroid Build Coastguard Worker        {container->push_front(_VSTD::move(__value_)); return *this;}
845*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
846*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator*()     {return *this;}
847*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator++()    {return *this;}
848*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY front_insert_iterator  operator++(int) {return *this;}
849*58b9f456SAndroid Build Coastguard Worker};
850*58b9f456SAndroid Build Coastguard Worker
851*58b9f456SAndroid Build Coastguard Workertemplate <class _Container>
852*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
853*58b9f456SAndroid Build Coastguard Workerfront_insert_iterator<_Container>
854*58b9f456SAndroid Build Coastguard Workerfront_inserter(_Container& __x)
855*58b9f456SAndroid Build Coastguard Worker{
856*58b9f456SAndroid Build Coastguard Worker    return front_insert_iterator<_Container>(__x);
857*58b9f456SAndroid Build Coastguard Worker}
858*58b9f456SAndroid Build Coastguard Worker
859*58b9f456SAndroid Build Coastguard Workertemplate <class _Container>
860*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS insert_iterator
861*58b9f456SAndroid Build Coastguard Worker    : public iterator<output_iterator_tag,
862*58b9f456SAndroid Build Coastguard Worker                      void,
863*58b9f456SAndroid Build Coastguard Worker                      void,
864*58b9f456SAndroid Build Coastguard Worker                      void,
865*58b9f456SAndroid Build Coastguard Worker                      void>
866*58b9f456SAndroid Build Coastguard Worker{
867*58b9f456SAndroid Build Coastguard Workerprotected:
868*58b9f456SAndroid Build Coastguard Worker    _Container* container;
869*58b9f456SAndroid Build Coastguard Worker    typename _Container::iterator iter;
870*58b9f456SAndroid Build Coastguard Workerpublic:
871*58b9f456SAndroid Build Coastguard Worker    typedef _Container container_type;
872*58b9f456SAndroid Build Coastguard Worker
873*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i)
874*58b9f456SAndroid Build Coastguard Worker        : container(_VSTD::addressof(__x)), iter(__i) {}
875*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_)
876*58b9f456SAndroid Build Coastguard Worker        {iter = container->insert(iter, __value_); ++iter; return *this;}
877*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
878*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value_)
879*58b9f456SAndroid Build Coastguard Worker        {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;}
880*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
881*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY insert_iterator& operator*()        {return *this;}
882*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++()       {return *this;}
883*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++(int)    {return *this;}
884*58b9f456SAndroid Build Coastguard Worker};
885*58b9f456SAndroid Build Coastguard Worker
886*58b9f456SAndroid Build Coastguard Workertemplate <class _Container>
887*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
888*58b9f456SAndroid Build Coastguard Workerinsert_iterator<_Container>
889*58b9f456SAndroid Build Coastguard Workerinserter(_Container& __x, typename _Container::iterator __i)
890*58b9f456SAndroid Build Coastguard Worker{
891*58b9f456SAndroid Build Coastguard Worker    return insert_iterator<_Container>(__x, __i);
892*58b9f456SAndroid Build Coastguard Worker}
893*58b9f456SAndroid Build Coastguard Worker
894*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _CharT = char,
895*58b9f456SAndroid Build Coastguard Worker          class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>
896*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS istream_iterator
897*58b9f456SAndroid Build Coastguard Worker    : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&>
898*58b9f456SAndroid Build Coastguard Worker{
899*58b9f456SAndroid Build Coastguard Workerpublic:
900*58b9f456SAndroid Build Coastguard Worker    typedef _CharT char_type;
901*58b9f456SAndroid Build Coastguard Worker    typedef _Traits traits_type;
902*58b9f456SAndroid Build Coastguard Worker    typedef basic_istream<_CharT,_Traits> istream_type;
903*58b9f456SAndroid Build Coastguard Workerprivate:
904*58b9f456SAndroid Build Coastguard Worker    istream_type* __in_stream_;
905*58b9f456SAndroid Build Coastguard Worker    _Tp __value_;
906*58b9f456SAndroid Build Coastguard Workerpublic:
907*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {}
908*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))
909*58b9f456SAndroid Build Coastguard Worker        {
910*58b9f456SAndroid Build Coastguard Worker            if (!(*__in_stream_ >> __value_))
911*58b9f456SAndroid Build Coastguard Worker                __in_stream_ = 0;
912*58b9f456SAndroid Build Coastguard Worker        }
913*58b9f456SAndroid Build Coastguard Worker
914*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;}
915*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return _VSTD::addressof((operator*()));}
916*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
917*58b9f456SAndroid Build Coastguard Worker        {
918*58b9f456SAndroid Build Coastguard Worker            if (!(*__in_stream_ >> __value_))
919*58b9f456SAndroid Build Coastguard Worker                __in_stream_ = 0;
920*58b9f456SAndroid Build Coastguard Worker            return *this;
921*58b9f456SAndroid Build Coastguard Worker        }
922*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY istream_iterator  operator++(int)
923*58b9f456SAndroid Build Coastguard Worker        {istream_iterator __t(*this); ++(*this); return __t;}
924*58b9f456SAndroid Build Coastguard Worker
925*58b9f456SAndroid Build Coastguard Worker    template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
926*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
927*58b9f456SAndroid Build Coastguard Worker    bool
928*58b9f456SAndroid Build Coastguard Worker    operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
929*58b9f456SAndroid Build Coastguard Worker               const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
930*58b9f456SAndroid Build Coastguard Worker
931*58b9f456SAndroid Build Coastguard Worker    template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
932*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
933*58b9f456SAndroid Build Coastguard Worker    bool
934*58b9f456SAndroid Build Coastguard Worker    operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
935*58b9f456SAndroid Build Coastguard Worker               const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
936*58b9f456SAndroid Build Coastguard Worker};
937*58b9f456SAndroid Build Coastguard Worker
938*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _CharT, class _Traits, class _Distance>
939*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
940*58b9f456SAndroid Build Coastguard Workerbool
941*58b9f456SAndroid Build Coastguard Workeroperator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
942*58b9f456SAndroid Build Coastguard Worker           const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
943*58b9f456SAndroid Build Coastguard Worker{
944*58b9f456SAndroid Build Coastguard Worker    return __x.__in_stream_ == __y.__in_stream_;
945*58b9f456SAndroid Build Coastguard Worker}
946*58b9f456SAndroid Build Coastguard Worker
947*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _CharT, class _Traits, class _Distance>
948*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
949*58b9f456SAndroid Build Coastguard Workerbool
950*58b9f456SAndroid Build Coastguard Workeroperator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
951*58b9f456SAndroid Build Coastguard Worker           const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
952*58b9f456SAndroid Build Coastguard Worker{
953*58b9f456SAndroid Build Coastguard Worker    return !(__x == __y);
954*58b9f456SAndroid Build Coastguard Worker}
955*58b9f456SAndroid Build Coastguard Worker
956*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
957*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS ostream_iterator
958*58b9f456SAndroid Build Coastguard Worker    : public iterator<output_iterator_tag, void, void, void, void>
959*58b9f456SAndroid Build Coastguard Worker{
960*58b9f456SAndroid Build Coastguard Workerpublic:
961*58b9f456SAndroid Build Coastguard Worker    typedef _CharT char_type;
962*58b9f456SAndroid Build Coastguard Worker    typedef _Traits traits_type;
963*58b9f456SAndroid Build Coastguard Worker    typedef basic_ostream<_CharT,_Traits> ostream_type;
964*58b9f456SAndroid Build Coastguard Workerprivate:
965*58b9f456SAndroid Build Coastguard Worker    ostream_type* __out_stream_;
966*58b9f456SAndroid Build Coastguard Worker    const char_type* __delim_;
967*58b9f456SAndroid Build Coastguard Workerpublic:
968*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT
969*58b9f456SAndroid Build Coastguard Worker        : __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
970*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT
971*58b9f456SAndroid Build Coastguard Worker        : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
972*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
973*58b9f456SAndroid Build Coastguard Worker        {
974*58b9f456SAndroid Build Coastguard Worker            *__out_stream_ << __value_;
975*58b9f456SAndroid Build Coastguard Worker            if (__delim_)
976*58b9f456SAndroid Build Coastguard Worker                *__out_stream_ << __delim_;
977*58b9f456SAndroid Build Coastguard Worker            return *this;
978*58b9f456SAndroid Build Coastguard Worker        }
979*58b9f456SAndroid Build Coastguard Worker
980*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*()     {return *this;}
981*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++()    {return *this;}
982*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;}
983*58b9f456SAndroid Build Coastguard Worker};
984*58b9f456SAndroid Build Coastguard Worker
985*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
986*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS istreambuf_iterator
987*58b9f456SAndroid Build Coastguard Worker    : public iterator<input_iterator_tag, _CharT,
988*58b9f456SAndroid Build Coastguard Worker                      typename _Traits::off_type, _CharT*,
989*58b9f456SAndroid Build Coastguard Worker                      _CharT>
990*58b9f456SAndroid Build Coastguard Worker{
991*58b9f456SAndroid Build Coastguard Workerpublic:
992*58b9f456SAndroid Build Coastguard Worker    typedef _CharT                          char_type;
993*58b9f456SAndroid Build Coastguard Worker    typedef _Traits                         traits_type;
994*58b9f456SAndroid Build Coastguard Worker    typedef typename _Traits::int_type      int_type;
995*58b9f456SAndroid Build Coastguard Worker    typedef basic_streambuf<_CharT,_Traits> streambuf_type;
996*58b9f456SAndroid Build Coastguard Worker    typedef basic_istream<_CharT,_Traits>   istream_type;
997*58b9f456SAndroid Build Coastguard Workerprivate:
998*58b9f456SAndroid Build Coastguard Worker    mutable streambuf_type* __sbuf_;
999*58b9f456SAndroid Build Coastguard Worker
1000*58b9f456SAndroid Build Coastguard Worker    class __proxy
1001*58b9f456SAndroid Build Coastguard Worker    {
1002*58b9f456SAndroid Build Coastguard Worker        char_type __keep_;
1003*58b9f456SAndroid Build Coastguard Worker        streambuf_type* __sbuf_;
1004*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s)
1005*58b9f456SAndroid Build Coastguard Worker            : __keep_(__c), __sbuf_(__s) {}
1006*58b9f456SAndroid Build Coastguard Worker        friend class istreambuf_iterator;
1007*58b9f456SAndroid Build Coastguard Worker    public:
1008*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY char_type operator*() const {return __keep_;}
1009*58b9f456SAndroid Build Coastguard Worker    };
1010*58b9f456SAndroid Build Coastguard Worker
1011*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1012*58b9f456SAndroid Build Coastguard Worker    bool __test_for_eof() const
1013*58b9f456SAndroid Build Coastguard Worker    {
1014*58b9f456SAndroid Build Coastguard Worker        if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof()))
1015*58b9f456SAndroid Build Coastguard Worker            __sbuf_ = 0;
1016*58b9f456SAndroid Build Coastguard Worker        return __sbuf_ == 0;
1017*58b9f456SAndroid Build Coastguard Worker    }
1018*58b9f456SAndroid Build Coastguard Workerpublic:
1019*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(0) {}
1020*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT
1021*58b9f456SAndroid Build Coastguard Worker        : __sbuf_(__s.rdbuf()) {}
1022*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT
1023*58b9f456SAndroid Build Coastguard Worker        : __sbuf_(__s) {}
1024*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT
1025*58b9f456SAndroid Build Coastguard Worker        : __sbuf_(__p.__sbuf_) {}
1026*58b9f456SAndroid Build Coastguard Worker
1027*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY char_type  operator*() const
1028*58b9f456SAndroid Build Coastguard Worker        {return static_cast<char_type>(__sbuf_->sgetc());}
1029*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++()
1030*58b9f456SAndroid Build Coastguard Worker        {
1031*58b9f456SAndroid Build Coastguard Worker            __sbuf_->sbumpc();
1032*58b9f456SAndroid Build Coastguard Worker            return *this;
1033*58b9f456SAndroid Build Coastguard Worker        }
1034*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __proxy              operator++(int)
1035*58b9f456SAndroid Build Coastguard Worker        {
1036*58b9f456SAndroid Build Coastguard Worker            return __proxy(__sbuf_->sbumpc(), __sbuf_);
1037*58b9f456SAndroid Build Coastguard Worker        }
1038*58b9f456SAndroid Build Coastguard Worker
1039*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const
1040*58b9f456SAndroid Build Coastguard Worker        {return __test_for_eof() == __b.__test_for_eof();}
1041*58b9f456SAndroid Build Coastguard Worker};
1042*58b9f456SAndroid Build Coastguard Worker
1043*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1044*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1045*58b9f456SAndroid Build Coastguard Workerbool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,
1046*58b9f456SAndroid Build Coastguard Worker                const istreambuf_iterator<_CharT,_Traits>& __b)
1047*58b9f456SAndroid Build Coastguard Worker                {return __a.equal(__b);}
1048*58b9f456SAndroid Build Coastguard Worker
1049*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1050*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1051*58b9f456SAndroid Build Coastguard Workerbool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a,
1052*58b9f456SAndroid Build Coastguard Worker                const istreambuf_iterator<_CharT,_Traits>& __b)
1053*58b9f456SAndroid Build Coastguard Worker                {return !__a.equal(__b);}
1054*58b9f456SAndroid Build Coastguard Worker
1055*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1056*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS ostreambuf_iterator
1057*58b9f456SAndroid Build Coastguard Worker    : public iterator<output_iterator_tag, void, void, void, void>
1058*58b9f456SAndroid Build Coastguard Worker{
1059*58b9f456SAndroid Build Coastguard Workerpublic:
1060*58b9f456SAndroid Build Coastguard Worker    typedef _CharT                          char_type;
1061*58b9f456SAndroid Build Coastguard Worker    typedef _Traits                         traits_type;
1062*58b9f456SAndroid Build Coastguard Worker    typedef basic_streambuf<_CharT,_Traits> streambuf_type;
1063*58b9f456SAndroid Build Coastguard Worker    typedef basic_ostream<_CharT,_Traits>   ostream_type;
1064*58b9f456SAndroid Build Coastguard Workerprivate:
1065*58b9f456SAndroid Build Coastguard Worker    streambuf_type* __sbuf_;
1066*58b9f456SAndroid Build Coastguard Workerpublic:
1067*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT
1068*58b9f456SAndroid Build Coastguard Worker        : __sbuf_(__s.rdbuf()) {}
1069*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT
1070*58b9f456SAndroid Build Coastguard Worker        : __sbuf_(__s) {}
1071*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c)
1072*58b9f456SAndroid Build Coastguard Worker        {
1073*58b9f456SAndroid Build Coastguard Worker            if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))
1074*58b9f456SAndroid Build Coastguard Worker                __sbuf_ = 0;
1075*58b9f456SAndroid Build Coastguard Worker            return *this;
1076*58b9f456SAndroid Build Coastguard Worker        }
1077*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*()     {return *this;}
1078*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++()    {return *this;}
1079*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;}
1080*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == 0;}
1081*58b9f456SAndroid Build Coastguard Worker
1082*58b9f456SAndroid Build Coastguard Worker#if !defined(__APPLE__) || \
1083*58b9f456SAndroid Build Coastguard Worker    (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_8) || \
1084*58b9f456SAndroid Build Coastguard Worker    (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0)
1085*58b9f456SAndroid Build Coastguard Worker
1086*58b9f456SAndroid Build Coastguard Worker    template <class _Ch, class _Tr>
1087*58b9f456SAndroid Build Coastguard Worker    friend
1088*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_HIDDEN
1089*58b9f456SAndroid Build Coastguard Worker    ostreambuf_iterator<_Ch, _Tr>
1090*58b9f456SAndroid Build Coastguard Worker    __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,
1091*58b9f456SAndroid Build Coastguard Worker                     const _Ch* __ob, const _Ch* __op, const _Ch* __oe,
1092*58b9f456SAndroid Build Coastguard Worker                     ios_base& __iob, _Ch __fl);
1093*58b9f456SAndroid Build Coastguard Worker#endif
1094*58b9f456SAndroid Build Coastguard Worker};
1095*58b9f456SAndroid Build Coastguard Worker
1096*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
1097*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS move_iterator
1098*58b9f456SAndroid Build Coastguard Worker{
1099*58b9f456SAndroid Build Coastguard Workerprivate:
1100*58b9f456SAndroid Build Coastguard Worker    _Iter __i;
1101*58b9f456SAndroid Build Coastguard Workerpublic:
1102*58b9f456SAndroid Build Coastguard Worker    typedef _Iter                                            iterator_type;
1103*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
1104*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<iterator_type>::value_type value_type;
1105*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<iterator_type>::difference_type difference_type;
1106*58b9f456SAndroid Build Coastguard Worker    typedef iterator_type pointer;
1107*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1108*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<iterator_type>::reference __reference;
1109*58b9f456SAndroid Build Coastguard Worker    typedef typename conditional<
1110*58b9f456SAndroid Build Coastguard Worker            is_reference<__reference>::value,
1111*58b9f456SAndroid Build Coastguard Worker            typename remove_reference<__reference>::type&&,
1112*58b9f456SAndroid Build Coastguard Worker            __reference
1113*58b9f456SAndroid Build Coastguard Worker        >::type reference;
1114*58b9f456SAndroid Build Coastguard Worker#else
1115*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<iterator_type>::reference reference;
1116*58b9f456SAndroid Build Coastguard Worker#endif
1117*58b9f456SAndroid Build Coastguard Worker
1118*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1119*58b9f456SAndroid Build Coastguard Worker    move_iterator() : __i() {}
1120*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1121*58b9f456SAndroid Build Coastguard Worker    explicit move_iterator(_Iter __x) : __i(__x) {}
1122*58b9f456SAndroid Build Coastguard Worker    template <class _Up>
1123*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1124*58b9f456SAndroid Build Coastguard Worker      move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {}
1125*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;}
1126*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1127*58b9f456SAndroid Build Coastguard Worker    reference operator*() const { return static_cast<reference>(*__i); }
1128*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1129*58b9f456SAndroid Build Coastguard Worker    pointer  operator->() const { return __i;}
1130*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1131*58b9f456SAndroid Build Coastguard Worker    move_iterator& operator++() {++__i; return *this;}
1132*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1133*58b9f456SAndroid Build Coastguard Worker    move_iterator  operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;}
1134*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1135*58b9f456SAndroid Build Coastguard Worker    move_iterator& operator--() {--__i; return *this;}
1136*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1137*58b9f456SAndroid Build Coastguard Worker    move_iterator  operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;}
1138*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1139*58b9f456SAndroid Build Coastguard Worker    move_iterator  operator+ (difference_type __n) const {return move_iterator(__i + __n);}
1140*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1141*58b9f456SAndroid Build Coastguard Worker    move_iterator& operator+=(difference_type __n) {__i += __n; return *this;}
1142*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1143*58b9f456SAndroid Build Coastguard Worker    move_iterator  operator- (difference_type __n) const {return move_iterator(__i - __n);}
1144*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1145*58b9f456SAndroid Build Coastguard Worker    move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;}
1146*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1147*58b9f456SAndroid Build Coastguard Worker    reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); }
1148*58b9f456SAndroid Build Coastguard Worker};
1149*58b9f456SAndroid Build Coastguard Worker
1150*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1151*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1152*58b9f456SAndroid Build Coastguard Workerbool
1153*58b9f456SAndroid Build Coastguard Workeroperator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1154*58b9f456SAndroid Build Coastguard Worker{
1155*58b9f456SAndroid Build Coastguard Worker    return __x.base() == __y.base();
1156*58b9f456SAndroid Build Coastguard Worker}
1157*58b9f456SAndroid Build Coastguard Worker
1158*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1159*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1160*58b9f456SAndroid Build Coastguard Workerbool
1161*58b9f456SAndroid Build Coastguard Workeroperator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1162*58b9f456SAndroid Build Coastguard Worker{
1163*58b9f456SAndroid Build Coastguard Worker    return __x.base() < __y.base();
1164*58b9f456SAndroid Build Coastguard Worker}
1165*58b9f456SAndroid Build Coastguard Worker
1166*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1167*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1168*58b9f456SAndroid Build Coastguard Workerbool
1169*58b9f456SAndroid Build Coastguard Workeroperator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1170*58b9f456SAndroid Build Coastguard Worker{
1171*58b9f456SAndroid Build Coastguard Worker    return __x.base() != __y.base();
1172*58b9f456SAndroid Build Coastguard Worker}
1173*58b9f456SAndroid Build Coastguard Worker
1174*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1175*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1176*58b9f456SAndroid Build Coastguard Workerbool
1177*58b9f456SAndroid Build Coastguard Workeroperator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1178*58b9f456SAndroid Build Coastguard Worker{
1179*58b9f456SAndroid Build Coastguard Worker    return __x.base() > __y.base();
1180*58b9f456SAndroid Build Coastguard Worker}
1181*58b9f456SAndroid Build Coastguard Worker
1182*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1183*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1184*58b9f456SAndroid Build Coastguard Workerbool
1185*58b9f456SAndroid Build Coastguard Workeroperator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1186*58b9f456SAndroid Build Coastguard Worker{
1187*58b9f456SAndroid Build Coastguard Worker    return __x.base() >= __y.base();
1188*58b9f456SAndroid Build Coastguard Worker}
1189*58b9f456SAndroid Build Coastguard Worker
1190*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1191*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1192*58b9f456SAndroid Build Coastguard Workerbool
1193*58b9f456SAndroid Build Coastguard Workeroperator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1194*58b9f456SAndroid Build Coastguard Worker{
1195*58b9f456SAndroid Build Coastguard Worker    return __x.base() <= __y.base();
1196*58b9f456SAndroid Build Coastguard Worker}
1197*58b9f456SAndroid Build Coastguard Worker
1198*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1199*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1200*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1201*58b9f456SAndroid Build Coastguard Workerauto
1202*58b9f456SAndroid Build Coastguard Workeroperator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1203*58b9f456SAndroid Build Coastguard Worker-> decltype(__x.base() - __y.base())
1204*58b9f456SAndroid Build Coastguard Worker{
1205*58b9f456SAndroid Build Coastguard Worker    return __x.base() - __y.base();
1206*58b9f456SAndroid Build Coastguard Worker}
1207*58b9f456SAndroid Build Coastguard Worker#else
1208*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1209*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1210*58b9f456SAndroid Build Coastguard Workertypename move_iterator<_Iter1>::difference_type
1211*58b9f456SAndroid Build Coastguard Workeroperator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
1212*58b9f456SAndroid Build Coastguard Worker{
1213*58b9f456SAndroid Build Coastguard Worker    return __x.base() - __y.base();
1214*58b9f456SAndroid Build Coastguard Worker}
1215*58b9f456SAndroid Build Coastguard Worker#endif
1216*58b9f456SAndroid Build Coastguard Worker
1217*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
1218*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1219*58b9f456SAndroid Build Coastguard Workermove_iterator<_Iter>
1220*58b9f456SAndroid Build Coastguard Workeroperator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)
1221*58b9f456SAndroid Build Coastguard Worker{
1222*58b9f456SAndroid Build Coastguard Worker    return move_iterator<_Iter>(__x.base() + __n);
1223*58b9f456SAndroid Build Coastguard Worker}
1224*58b9f456SAndroid Build Coastguard Worker
1225*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
1226*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1227*58b9f456SAndroid Build Coastguard Workermove_iterator<_Iter>
1228*58b9f456SAndroid Build Coastguard Workermake_move_iterator(_Iter __i)
1229*58b9f456SAndroid Build Coastguard Worker{
1230*58b9f456SAndroid Build Coastguard Worker    return move_iterator<_Iter>(__i);
1231*58b9f456SAndroid Build Coastguard Worker}
1232*58b9f456SAndroid Build Coastguard Worker
1233*58b9f456SAndroid Build Coastguard Worker// __wrap_iter
1234*58b9f456SAndroid Build Coastguard Worker
1235*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter> class __wrap_iter;
1236*58b9f456SAndroid Build Coastguard Worker
1237*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1238*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1239*58b9f456SAndroid Build Coastguard Workerbool
1240*58b9f456SAndroid Build Coastguard Workeroperator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1241*58b9f456SAndroid Build Coastguard Worker
1242*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1243*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1244*58b9f456SAndroid Build Coastguard Workerbool
1245*58b9f456SAndroid Build Coastguard Workeroperator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1246*58b9f456SAndroid Build Coastguard Worker
1247*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1248*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1249*58b9f456SAndroid Build Coastguard Workerbool
1250*58b9f456SAndroid Build Coastguard Workeroperator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1251*58b9f456SAndroid Build Coastguard Worker
1252*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1253*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1254*58b9f456SAndroid Build Coastguard Workerbool
1255*58b9f456SAndroid Build Coastguard Workeroperator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1256*58b9f456SAndroid Build Coastguard Worker
1257*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1258*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1259*58b9f456SAndroid Build Coastguard Workerbool
1260*58b9f456SAndroid Build Coastguard Workeroperator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1261*58b9f456SAndroid Build Coastguard Worker
1262*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1263*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1264*58b9f456SAndroid Build Coastguard Workerbool
1265*58b9f456SAndroid Build Coastguard Workeroperator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1266*58b9f456SAndroid Build Coastguard Worker
1267*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1268*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1269*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1270*58b9f456SAndroid Build Coastguard Workerauto
1271*58b9f456SAndroid Build Coastguard Workeroperator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1272*58b9f456SAndroid Build Coastguard Worker-> decltype(__x.base() - __y.base());
1273*58b9f456SAndroid Build Coastguard Worker#else
1274*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1275*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
1276*58b9f456SAndroid Build Coastguard Workertypename __wrap_iter<_Iter1>::difference_type
1277*58b9f456SAndroid Build Coastguard Workeroperator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1278*58b9f456SAndroid Build Coastguard Worker#endif
1279*58b9f456SAndroid Build Coastguard Worker
1280*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
1281*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1282*58b9f456SAndroid Build Coastguard Worker__wrap_iter<_Iter>
1283*58b9f456SAndroid Build Coastguard Workeroperator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT_DEBUG;
1284*58b9f456SAndroid Build Coastguard Worker
1285*58b9f456SAndroid Build Coastguard Workertemplate <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY copy(_Ip, _Ip, _Op);
1286*58b9f456SAndroid Build Coastguard Workertemplate <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY copy_backward(_B1, _B1, _B2);
1287*58b9f456SAndroid Build Coastguard Workertemplate <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY move(_Ip, _Ip, _Op);
1288*58b9f456SAndroid Build Coastguard Workertemplate <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY move_backward(_B1, _B1, _B2);
1289*58b9f456SAndroid Build Coastguard Worker
1290*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL < 2
1291*58b9f456SAndroid Build Coastguard Worker
1292*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
1293*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1294*58b9f456SAndroid Build Coastguard Workertypename enable_if
1295*58b9f456SAndroid Build Coastguard Worker<
1296*58b9f456SAndroid Build Coastguard Worker    is_trivially_copy_assignable<_Tp>::value,
1297*58b9f456SAndroid Build Coastguard Worker    _Tp*
1298*58b9f456SAndroid Build Coastguard Worker>::type
1299*58b9f456SAndroid Build Coastguard Worker__unwrap_iter(__wrap_iter<_Tp*>);
1300*58b9f456SAndroid Build Coastguard Worker
1301*58b9f456SAndroid Build Coastguard Worker#else
1302*58b9f456SAndroid Build Coastguard Worker
1303*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
1304*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1305*58b9f456SAndroid Build Coastguard Workertypename enable_if
1306*58b9f456SAndroid Build Coastguard Worker<
1307*58b9f456SAndroid Build Coastguard Worker    is_trivially_copy_assignable<_Tp>::value,
1308*58b9f456SAndroid Build Coastguard Worker    __wrap_iter<_Tp*>
1309*58b9f456SAndroid Build Coastguard Worker>::type
1310*58b9f456SAndroid Build Coastguard Worker__unwrap_iter(__wrap_iter<_Tp*> __i);
1311*58b9f456SAndroid Build Coastguard Worker
1312*58b9f456SAndroid Build Coastguard Worker#endif
1313*58b9f456SAndroid Build Coastguard Worker
1314*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
1315*58b9f456SAndroid Build Coastguard Workerclass __wrap_iter
1316*58b9f456SAndroid Build Coastguard Worker{
1317*58b9f456SAndroid Build Coastguard Workerpublic:
1318*58b9f456SAndroid Build Coastguard Worker    typedef _Iter                                                      iterator_type;
1319*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
1320*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<iterator_type>::value_type        value_type;
1321*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<iterator_type>::difference_type   difference_type;
1322*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<iterator_type>::pointer           pointer;
1323*58b9f456SAndroid Build Coastguard Worker    typedef typename iterator_traits<iterator_type>::reference         reference;
1324*58b9f456SAndroid Build Coastguard Workerprivate:
1325*58b9f456SAndroid Build Coastguard Worker    iterator_type __i;
1326*58b9f456SAndroid Build Coastguard Workerpublic:
1327*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT_DEBUG
1328*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11
1329*58b9f456SAndroid Build Coastguard Worker                : __i{}
1330*58b9f456SAndroid Build Coastguard Worker#endif
1331*58b9f456SAndroid Build Coastguard Worker    {
1332*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1333*58b9f456SAndroid Build Coastguard Worker        __get_db()->__insert_i(this);
1334*58b9f456SAndroid Build Coastguard Worker#endif
1335*58b9f456SAndroid Build Coastguard Worker    }
1336*58b9f456SAndroid Build Coastguard Worker    template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1337*58b9f456SAndroid Build Coastguard Worker        __wrap_iter(const __wrap_iter<_Up>& __u,
1338*58b9f456SAndroid Build Coastguard Worker            typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) _NOEXCEPT_DEBUG
1339*58b9f456SAndroid Build Coastguard Worker            : __i(__u.base())
1340*58b9f456SAndroid Build Coastguard Worker    {
1341*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1342*58b9f456SAndroid Build Coastguard Worker        __get_db()->__iterator_copy(this, &__u);
1343*58b9f456SAndroid Build Coastguard Worker#endif
1344*58b9f456SAndroid Build Coastguard Worker    }
1345*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1346*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1347*58b9f456SAndroid Build Coastguard Worker    __wrap_iter(const __wrap_iter& __x)
1348*58b9f456SAndroid Build Coastguard Worker        : __i(__x.base())
1349*58b9f456SAndroid Build Coastguard Worker    {
1350*58b9f456SAndroid Build Coastguard Worker        __get_db()->__iterator_copy(this, &__x);
1351*58b9f456SAndroid Build Coastguard Worker    }
1352*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1353*58b9f456SAndroid Build Coastguard Worker    __wrap_iter& operator=(const __wrap_iter& __x)
1354*58b9f456SAndroid Build Coastguard Worker    {
1355*58b9f456SAndroid Build Coastguard Worker        if (this != &__x)
1356*58b9f456SAndroid Build Coastguard Worker        {
1357*58b9f456SAndroid Build Coastguard Worker            __get_db()->__iterator_copy(this, &__x);
1358*58b9f456SAndroid Build Coastguard Worker            __i = __x.__i;
1359*58b9f456SAndroid Build Coastguard Worker        }
1360*58b9f456SAndroid Build Coastguard Worker        return *this;
1361*58b9f456SAndroid Build Coastguard Worker    }
1362*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1363*58b9f456SAndroid Build Coastguard Worker    ~__wrap_iter()
1364*58b9f456SAndroid Build Coastguard Worker    {
1365*58b9f456SAndroid Build Coastguard Worker        __get_db()->__erase_i(this);
1366*58b9f456SAndroid Build Coastguard Worker    }
1367*58b9f456SAndroid Build Coastguard Worker#endif
1368*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT_DEBUG
1369*58b9f456SAndroid Build Coastguard Worker    {
1370*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1371*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
1372*58b9f456SAndroid Build Coastguard Worker                       "Attempted to dereference a non-dereferenceable iterator");
1373*58b9f456SAndroid Build Coastguard Worker#endif
1374*58b9f456SAndroid Build Coastguard Worker        return *__i;
1375*58b9f456SAndroid Build Coastguard Worker    }
1376*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer  operator->() const _NOEXCEPT_DEBUG
1377*58b9f456SAndroid Build Coastguard Worker    {
1378*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1379*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
1380*58b9f456SAndroid Build Coastguard Worker                       "Attempted to dereference a non-dereferenceable iterator");
1381*58b9f456SAndroid Build Coastguard Worker#endif
1382*58b9f456SAndroid Build Coastguard Worker        return (pointer)_VSTD::addressof(*__i);
1383*58b9f456SAndroid Build Coastguard Worker    }
1384*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT_DEBUG
1385*58b9f456SAndroid Build Coastguard Worker    {
1386*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1387*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
1388*58b9f456SAndroid Build Coastguard Worker                       "Attempted to increment non-incrementable iterator");
1389*58b9f456SAndroid Build Coastguard Worker#endif
1390*58b9f456SAndroid Build Coastguard Worker        ++__i;
1391*58b9f456SAndroid Build Coastguard Worker        return *this;
1392*58b9f456SAndroid Build Coastguard Worker    }
1393*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter  operator++(int) _NOEXCEPT_DEBUG
1394*58b9f456SAndroid Build Coastguard Worker        {__wrap_iter __tmp(*this); ++(*this); return __tmp;}
1395*58b9f456SAndroid Build Coastguard Worker
1396*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT_DEBUG
1397*58b9f456SAndroid Build Coastguard Worker    {
1398*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1399*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
1400*58b9f456SAndroid Build Coastguard Worker                       "Attempted to decrement non-decrementable iterator");
1401*58b9f456SAndroid Build Coastguard Worker#endif
1402*58b9f456SAndroid Build Coastguard Worker        --__i;
1403*58b9f456SAndroid Build Coastguard Worker        return *this;
1404*58b9f456SAndroid Build Coastguard Worker    }
1405*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter  operator--(int) _NOEXCEPT_DEBUG
1406*58b9f456SAndroid Build Coastguard Worker        {__wrap_iter __tmp(*this); --(*this); return __tmp;}
1407*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter  operator+ (difference_type __n) const _NOEXCEPT_DEBUG
1408*58b9f456SAndroid Build Coastguard Worker        {__wrap_iter __w(*this); __w += __n; return __w;}
1409*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT_DEBUG
1410*58b9f456SAndroid Build Coastguard Worker    {
1411*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1412*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n),
1413*58b9f456SAndroid Build Coastguard Worker                   "Attempted to add/subtract iterator outside of valid range");
1414*58b9f456SAndroid Build Coastguard Worker#endif
1415*58b9f456SAndroid Build Coastguard Worker        __i += __n;
1416*58b9f456SAndroid Build Coastguard Worker        return *this;
1417*58b9f456SAndroid Build Coastguard Worker    }
1418*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter  operator- (difference_type __n) const _NOEXCEPT_DEBUG
1419*58b9f456SAndroid Build Coastguard Worker        {return *this + (-__n);}
1420*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT_DEBUG
1421*58b9f456SAndroid Build Coastguard Worker        {*this += -__n; return *this;}
1422*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference    operator[](difference_type __n) const _NOEXCEPT_DEBUG
1423*58b9f456SAndroid Build Coastguard Worker    {
1424*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1425*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n),
1426*58b9f456SAndroid Build Coastguard Worker                   "Attempted to subscript iterator outside of valid range");
1427*58b9f456SAndroid Build Coastguard Worker#endif
1428*58b9f456SAndroid Build Coastguard Worker        return __i[__n];
1429*58b9f456SAndroid Build Coastguard Worker    }
1430*58b9f456SAndroid Build Coastguard Worker
1431*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT_DEBUG {return __i;}
1432*58b9f456SAndroid Build Coastguard Worker
1433*58b9f456SAndroid Build Coastguard Workerprivate:
1434*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1435*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
1436*58b9f456SAndroid Build Coastguard Worker    {
1437*58b9f456SAndroid Build Coastguard Worker        __get_db()->__insert_ic(this, __p);
1438*58b9f456SAndroid Build Coastguard Worker    }
1439*58b9f456SAndroid Build Coastguard Worker#else
1440*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
1441*58b9f456SAndroid Build Coastguard Worker#endif
1442*58b9f456SAndroid Build Coastguard Worker
1443*58b9f456SAndroid Build Coastguard Worker    template <class _Up> friend class __wrap_iter;
1444*58b9f456SAndroid Build Coastguard Worker    template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
1445*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector;
1446*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, ptrdiff_t> friend class _LIBCPP_TEMPLATE_VIS span;
1447*58b9f456SAndroid Build Coastguard Worker
1448*58b9f456SAndroid Build Coastguard Worker    template <class _Iter1, class _Iter2>
1449*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1450*58b9f456SAndroid Build Coastguard Worker    bool
1451*58b9f456SAndroid Build Coastguard Worker    operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1452*58b9f456SAndroid Build Coastguard Worker
1453*58b9f456SAndroid Build Coastguard Worker    template <class _Iter1, class _Iter2>
1454*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1455*58b9f456SAndroid Build Coastguard Worker    bool
1456*58b9f456SAndroid Build Coastguard Worker    operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1457*58b9f456SAndroid Build Coastguard Worker
1458*58b9f456SAndroid Build Coastguard Worker    template <class _Iter1, class _Iter2>
1459*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1460*58b9f456SAndroid Build Coastguard Worker    bool
1461*58b9f456SAndroid Build Coastguard Worker    operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1462*58b9f456SAndroid Build Coastguard Worker
1463*58b9f456SAndroid Build Coastguard Worker    template <class _Iter1, class _Iter2>
1464*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1465*58b9f456SAndroid Build Coastguard Worker    bool
1466*58b9f456SAndroid Build Coastguard Worker    operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1467*58b9f456SAndroid Build Coastguard Worker
1468*58b9f456SAndroid Build Coastguard Worker    template <class _Iter1, class _Iter2>
1469*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1470*58b9f456SAndroid Build Coastguard Worker    bool
1471*58b9f456SAndroid Build Coastguard Worker    operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1472*58b9f456SAndroid Build Coastguard Worker
1473*58b9f456SAndroid Build Coastguard Worker    template <class _Iter1, class _Iter2>
1474*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1475*58b9f456SAndroid Build Coastguard Worker    bool
1476*58b9f456SAndroid Build Coastguard Worker    operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1477*58b9f456SAndroid Build Coastguard Worker
1478*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1479*58b9f456SAndroid Build Coastguard Worker    template <class _Iter1, class _Iter2>
1480*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1481*58b9f456SAndroid Build Coastguard Worker    auto
1482*58b9f456SAndroid Build Coastguard Worker    operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1483*58b9f456SAndroid Build Coastguard Worker    -> decltype(__x.base() - __y.base());
1484*58b9f456SAndroid Build Coastguard Worker#else
1485*58b9f456SAndroid Build Coastguard Worker    template <class _Iter1, class _Iter2>
1486*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1487*58b9f456SAndroid Build Coastguard Worker    typename __wrap_iter<_Iter1>::difference_type
1488*58b9f456SAndroid Build Coastguard Worker    operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
1489*58b9f456SAndroid Build Coastguard Worker#endif
1490*58b9f456SAndroid Build Coastguard Worker
1491*58b9f456SAndroid Build Coastguard Worker    template <class _Iter1>
1492*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1493*58b9f456SAndroid Build Coastguard Worker    __wrap_iter<_Iter1>
1494*58b9f456SAndroid Build Coastguard Worker    operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT_DEBUG;
1495*58b9f456SAndroid Build Coastguard Worker
1496*58b9f456SAndroid Build Coastguard Worker    template <class _Ip, class _Op> friend _Op copy(_Ip, _Ip, _Op);
1497*58b9f456SAndroid Build Coastguard Worker    template <class _B1, class _B2> friend _B2 copy_backward(_B1, _B1, _B2);
1498*58b9f456SAndroid Build Coastguard Worker    template <class _Ip, class _Op> friend _Op move(_Ip, _Ip, _Op);
1499*58b9f456SAndroid Build Coastguard Worker    template <class _B1, class _B2> friend _B2 move_backward(_B1, _B1, _B2);
1500*58b9f456SAndroid Build Coastguard Worker
1501*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL < 2
1502*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1503*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_IF_NODEBUG friend
1504*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1505*58b9f456SAndroid Build Coastguard Worker    <
1506*58b9f456SAndroid Build Coastguard Worker        is_trivially_copy_assignable<_Tp>::value,
1507*58b9f456SAndroid Build Coastguard Worker        _Tp*
1508*58b9f456SAndroid Build Coastguard Worker    >::type
1509*58b9f456SAndroid Build Coastguard Worker    __unwrap_iter(__wrap_iter<_Tp*>);
1510*58b9f456SAndroid Build Coastguard Worker#else
1511*58b9f456SAndroid Build Coastguard Worker  template <class _Tp>
1512*58b9f456SAndroid Build Coastguard Worker  inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1513*58b9f456SAndroid Build Coastguard Worker  typename enable_if
1514*58b9f456SAndroid Build Coastguard Worker  <
1515*58b9f456SAndroid Build Coastguard Worker      is_trivially_copy_assignable<_Tp>::value,
1516*58b9f456SAndroid Build Coastguard Worker      __wrap_iter<_Tp*>
1517*58b9f456SAndroid Build Coastguard Worker  >::type
1518*58b9f456SAndroid Build Coastguard Worker  __unwrap_iter(__wrap_iter<_Tp*> __i);
1519*58b9f456SAndroid Build Coastguard Worker#endif
1520*58b9f456SAndroid Build Coastguard Worker};
1521*58b9f456SAndroid Build Coastguard Worker
1522*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1523*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1524*58b9f456SAndroid Build Coastguard Workerbool
1525*58b9f456SAndroid Build Coastguard Workeroperator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1526*58b9f456SAndroid Build Coastguard Worker{
1527*58b9f456SAndroid Build Coastguard Worker    return __x.base() == __y.base();
1528*58b9f456SAndroid Build Coastguard Worker}
1529*58b9f456SAndroid Build Coastguard Worker
1530*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1531*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1532*58b9f456SAndroid Build Coastguard Workerbool
1533*58b9f456SAndroid Build Coastguard Workeroperator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1534*58b9f456SAndroid Build Coastguard Worker{
1535*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1536*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
1537*58b9f456SAndroid Build Coastguard Worker                   "Attempted to compare incomparable iterators");
1538*58b9f456SAndroid Build Coastguard Worker#endif
1539*58b9f456SAndroid Build Coastguard Worker    return __x.base() < __y.base();
1540*58b9f456SAndroid Build Coastguard Worker}
1541*58b9f456SAndroid Build Coastguard Worker
1542*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1543*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1544*58b9f456SAndroid Build Coastguard Workerbool
1545*58b9f456SAndroid Build Coastguard Workeroperator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1546*58b9f456SAndroid Build Coastguard Worker{
1547*58b9f456SAndroid Build Coastguard Worker    return !(__x == __y);
1548*58b9f456SAndroid Build Coastguard Worker}
1549*58b9f456SAndroid Build Coastguard Worker
1550*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1551*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1552*58b9f456SAndroid Build Coastguard Workerbool
1553*58b9f456SAndroid Build Coastguard Workeroperator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1554*58b9f456SAndroid Build Coastguard Worker{
1555*58b9f456SAndroid Build Coastguard Worker    return __y < __x;
1556*58b9f456SAndroid Build Coastguard Worker}
1557*58b9f456SAndroid Build Coastguard Worker
1558*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1559*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1560*58b9f456SAndroid Build Coastguard Workerbool
1561*58b9f456SAndroid Build Coastguard Workeroperator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1562*58b9f456SAndroid Build Coastguard Worker{
1563*58b9f456SAndroid Build Coastguard Worker    return !(__x < __y);
1564*58b9f456SAndroid Build Coastguard Worker}
1565*58b9f456SAndroid Build Coastguard Worker
1566*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1567*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1568*58b9f456SAndroid Build Coastguard Workerbool
1569*58b9f456SAndroid Build Coastguard Workeroperator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1570*58b9f456SAndroid Build Coastguard Worker{
1571*58b9f456SAndroid Build Coastguard Worker    return !(__y < __x);
1572*58b9f456SAndroid Build Coastguard Worker}
1573*58b9f456SAndroid Build Coastguard Worker
1574*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1>
1575*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1576*58b9f456SAndroid Build Coastguard Workerbool
1577*58b9f456SAndroid Build Coastguard Workeroperator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
1578*58b9f456SAndroid Build Coastguard Worker{
1579*58b9f456SAndroid Build Coastguard Worker    return !(__x == __y);
1580*58b9f456SAndroid Build Coastguard Worker}
1581*58b9f456SAndroid Build Coastguard Worker
1582*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1>
1583*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1584*58b9f456SAndroid Build Coastguard Workerbool
1585*58b9f456SAndroid Build Coastguard Workeroperator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
1586*58b9f456SAndroid Build Coastguard Worker{
1587*58b9f456SAndroid Build Coastguard Worker    return __y < __x;
1588*58b9f456SAndroid Build Coastguard Worker}
1589*58b9f456SAndroid Build Coastguard Worker
1590*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1>
1591*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1592*58b9f456SAndroid Build Coastguard Workerbool
1593*58b9f456SAndroid Build Coastguard Workeroperator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
1594*58b9f456SAndroid Build Coastguard Worker{
1595*58b9f456SAndroid Build Coastguard Worker    return !(__x < __y);
1596*58b9f456SAndroid Build Coastguard Worker}
1597*58b9f456SAndroid Build Coastguard Worker
1598*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1>
1599*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1600*58b9f456SAndroid Build Coastguard Workerbool
1601*58b9f456SAndroid Build Coastguard Workeroperator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
1602*58b9f456SAndroid Build Coastguard Worker{
1603*58b9f456SAndroid Build Coastguard Worker    return !(__y < __x);
1604*58b9f456SAndroid Build Coastguard Worker}
1605*58b9f456SAndroid Build Coastguard Worker
1606*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1607*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1608*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1609*58b9f456SAndroid Build Coastguard Workerauto
1610*58b9f456SAndroid Build Coastguard Workeroperator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1611*58b9f456SAndroid Build Coastguard Worker-> decltype(__x.base() - __y.base())
1612*58b9f456SAndroid Build Coastguard Worker{
1613*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1614*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
1615*58b9f456SAndroid Build Coastguard Worker                   "Attempted to subtract incompatible iterators");
1616*58b9f456SAndroid Build Coastguard Worker#endif
1617*58b9f456SAndroid Build Coastguard Worker    return __x.base() - __y.base();
1618*58b9f456SAndroid Build Coastguard Worker}
1619*58b9f456SAndroid Build Coastguard Worker#else
1620*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter1, class _Iter2>
1621*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1622*58b9f456SAndroid Build Coastguard Workertypename __wrap_iter<_Iter1>::difference_type
1623*58b9f456SAndroid Build Coastguard Workeroperator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
1624*58b9f456SAndroid Build Coastguard Worker{
1625*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1626*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
1627*58b9f456SAndroid Build Coastguard Worker                   "Attempted to subtract incompatible iterators");
1628*58b9f456SAndroid Build Coastguard Worker#endif
1629*58b9f456SAndroid Build Coastguard Worker    return __x.base() - __y.base();
1630*58b9f456SAndroid Build Coastguard Worker}
1631*58b9f456SAndroid Build Coastguard Worker#endif
1632*58b9f456SAndroid Build Coastguard Worker
1633*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
1634*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
1635*58b9f456SAndroid Build Coastguard Worker__wrap_iter<_Iter>
1636*58b9f456SAndroid Build Coastguard Workeroperator+(typename __wrap_iter<_Iter>::difference_type __n,
1637*58b9f456SAndroid Build Coastguard Worker          __wrap_iter<_Iter> __x) _NOEXCEPT_DEBUG
1638*58b9f456SAndroid Build Coastguard Worker{
1639*58b9f456SAndroid Build Coastguard Worker    __x += __n;
1640*58b9f456SAndroid Build Coastguard Worker    return __x;
1641*58b9f456SAndroid Build Coastguard Worker}
1642*58b9f456SAndroid Build Coastguard Worker
1643*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
1644*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_is_trivial_iterator
1645*58b9f456SAndroid Build Coastguard Worker    : public _LIBCPP_BOOL_CONSTANT(is_pointer<_Iter>::value) {};
1646*58b9f456SAndroid Build Coastguard Worker
1647*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
1648*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_is_trivial_iterator<move_iterator<_Iter> >
1649*58b9f456SAndroid Build Coastguard Worker    : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
1650*58b9f456SAndroid Build Coastguard Worker
1651*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
1652*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_is_trivial_iterator<reverse_iterator<_Iter> >
1653*58b9f456SAndroid Build Coastguard Worker    : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
1654*58b9f456SAndroid Build Coastguard Worker
1655*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
1656*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> >
1657*58b9f456SAndroid Build Coastguard Worker    : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
1658*58b9f456SAndroid Build Coastguard Worker
1659*58b9f456SAndroid Build Coastguard Worker
1660*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Np>
1661*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1662*58b9f456SAndroid Build Coastguard Worker_Tp*
1663*58b9f456SAndroid Build Coastguard Workerbegin(_Tp (&__array)[_Np])
1664*58b9f456SAndroid Build Coastguard Worker{
1665*58b9f456SAndroid Build Coastguard Worker    return __array;
1666*58b9f456SAndroid Build Coastguard Worker}
1667*58b9f456SAndroid Build Coastguard Worker
1668*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Np>
1669*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1670*58b9f456SAndroid Build Coastguard Worker_Tp*
1671*58b9f456SAndroid Build Coastguard Workerend(_Tp (&__array)[_Np])
1672*58b9f456SAndroid Build Coastguard Worker{
1673*58b9f456SAndroid Build Coastguard Worker    return __array + _Np;
1674*58b9f456SAndroid Build Coastguard Worker}
1675*58b9f456SAndroid Build Coastguard Worker
1676*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_CXX03_LANG)
1677*58b9f456SAndroid Build Coastguard Worker
1678*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1679*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1680*58b9f456SAndroid Build Coastguard Workerauto
1681*58b9f456SAndroid Build Coastguard Workerbegin(_Cp& __c) -> decltype(__c.begin())
1682*58b9f456SAndroid Build Coastguard Worker{
1683*58b9f456SAndroid Build Coastguard Worker    return __c.begin();
1684*58b9f456SAndroid Build Coastguard Worker}
1685*58b9f456SAndroid Build Coastguard Worker
1686*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1687*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1688*58b9f456SAndroid Build Coastguard Workerauto
1689*58b9f456SAndroid Build Coastguard Workerbegin(const _Cp& __c) -> decltype(__c.begin())
1690*58b9f456SAndroid Build Coastguard Worker{
1691*58b9f456SAndroid Build Coastguard Worker    return __c.begin();
1692*58b9f456SAndroid Build Coastguard Worker}
1693*58b9f456SAndroid Build Coastguard Worker
1694*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1695*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1696*58b9f456SAndroid Build Coastguard Workerauto
1697*58b9f456SAndroid Build Coastguard Workerend(_Cp& __c) -> decltype(__c.end())
1698*58b9f456SAndroid Build Coastguard Worker{
1699*58b9f456SAndroid Build Coastguard Worker    return __c.end();
1700*58b9f456SAndroid Build Coastguard Worker}
1701*58b9f456SAndroid Build Coastguard Worker
1702*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1703*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1704*58b9f456SAndroid Build Coastguard Workerauto
1705*58b9f456SAndroid Build Coastguard Workerend(const _Cp& __c) -> decltype(__c.end())
1706*58b9f456SAndroid Build Coastguard Worker{
1707*58b9f456SAndroid Build Coastguard Worker    return __c.end();
1708*58b9f456SAndroid Build Coastguard Worker}
1709*58b9f456SAndroid Build Coastguard Worker
1710*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11
1711*58b9f456SAndroid Build Coastguard Worker
1712*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Np>
1713*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1714*58b9f456SAndroid Build Coastguard Workerreverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
1715*58b9f456SAndroid Build Coastguard Worker{
1716*58b9f456SAndroid Build Coastguard Worker    return reverse_iterator<_Tp*>(__array + _Np);
1717*58b9f456SAndroid Build Coastguard Worker}
1718*58b9f456SAndroid Build Coastguard Worker
1719*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Np>
1720*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1721*58b9f456SAndroid Build Coastguard Workerreverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
1722*58b9f456SAndroid Build Coastguard Worker{
1723*58b9f456SAndroid Build Coastguard Worker    return reverse_iterator<_Tp*>(__array);
1724*58b9f456SAndroid Build Coastguard Worker}
1725*58b9f456SAndroid Build Coastguard Worker
1726*58b9f456SAndroid Build Coastguard Workertemplate <class _Ep>
1727*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1728*58b9f456SAndroid Build Coastguard Workerreverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
1729*58b9f456SAndroid Build Coastguard Worker{
1730*58b9f456SAndroid Build Coastguard Worker    return reverse_iterator<const _Ep*>(__il.end());
1731*58b9f456SAndroid Build Coastguard Worker}
1732*58b9f456SAndroid Build Coastguard Worker
1733*58b9f456SAndroid Build Coastguard Workertemplate <class _Ep>
1734*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1735*58b9f456SAndroid Build Coastguard Workerreverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
1736*58b9f456SAndroid Build Coastguard Worker{
1737*58b9f456SAndroid Build Coastguard Worker    return reverse_iterator<const _Ep*>(__il.begin());
1738*58b9f456SAndroid Build Coastguard Worker}
1739*58b9f456SAndroid Build Coastguard Worker
1740*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1741*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1742*58b9f456SAndroid Build Coastguard Workerauto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))
1743*58b9f456SAndroid Build Coastguard Worker{
1744*58b9f456SAndroid Build Coastguard Worker    return _VSTD::begin(__c);
1745*58b9f456SAndroid Build Coastguard Worker}
1746*58b9f456SAndroid Build Coastguard Worker
1747*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1748*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1749*58b9f456SAndroid Build Coastguard Workerauto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
1750*58b9f456SAndroid Build Coastguard Worker{
1751*58b9f456SAndroid Build Coastguard Worker    return _VSTD::end(__c);
1752*58b9f456SAndroid Build Coastguard Worker}
1753*58b9f456SAndroid Build Coastguard Worker
1754*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1755*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1756*58b9f456SAndroid Build Coastguard Workerauto rbegin(_Cp& __c) -> decltype(__c.rbegin())
1757*58b9f456SAndroid Build Coastguard Worker{
1758*58b9f456SAndroid Build Coastguard Worker    return __c.rbegin();
1759*58b9f456SAndroid Build Coastguard Worker}
1760*58b9f456SAndroid Build Coastguard Worker
1761*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1762*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1763*58b9f456SAndroid Build Coastguard Workerauto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
1764*58b9f456SAndroid Build Coastguard Worker{
1765*58b9f456SAndroid Build Coastguard Worker    return __c.rbegin();
1766*58b9f456SAndroid Build Coastguard Worker}
1767*58b9f456SAndroid Build Coastguard Worker
1768*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1769*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1770*58b9f456SAndroid Build Coastguard Workerauto rend(_Cp& __c) -> decltype(__c.rend())
1771*58b9f456SAndroid Build Coastguard Worker{
1772*58b9f456SAndroid Build Coastguard Worker    return __c.rend();
1773*58b9f456SAndroid Build Coastguard Worker}
1774*58b9f456SAndroid Build Coastguard Worker
1775*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1776*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1777*58b9f456SAndroid Build Coastguard Workerauto rend(const _Cp& __c) -> decltype(__c.rend())
1778*58b9f456SAndroid Build Coastguard Worker{
1779*58b9f456SAndroid Build Coastguard Worker    return __c.rend();
1780*58b9f456SAndroid Build Coastguard Worker}
1781*58b9f456SAndroid Build Coastguard Worker
1782*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1783*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1784*58b9f456SAndroid Build Coastguard Workerauto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
1785*58b9f456SAndroid Build Coastguard Worker{
1786*58b9f456SAndroid Build Coastguard Worker    return _VSTD::rbegin(__c);
1787*58b9f456SAndroid Build Coastguard Worker}
1788*58b9f456SAndroid Build Coastguard Worker
1789*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1790*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
1791*58b9f456SAndroid Build Coastguard Workerauto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
1792*58b9f456SAndroid Build Coastguard Worker{
1793*58b9f456SAndroid Build Coastguard Worker    return _VSTD::rend(__c);
1794*58b9f456SAndroid Build Coastguard Worker}
1795*58b9f456SAndroid Build Coastguard Worker
1796*58b9f456SAndroid Build Coastguard Worker#endif
1797*58b9f456SAndroid Build Coastguard Worker
1798*58b9f456SAndroid Build Coastguard Worker
1799*58b9f456SAndroid Build Coastguard Worker#else  // defined(_LIBCPP_CXX03_LANG)
1800*58b9f456SAndroid Build Coastguard Worker
1801*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1802*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1803*58b9f456SAndroid Build Coastguard Workertypename _Cp::iterator
1804*58b9f456SAndroid Build Coastguard Workerbegin(_Cp& __c)
1805*58b9f456SAndroid Build Coastguard Worker{
1806*58b9f456SAndroid Build Coastguard Worker    return __c.begin();
1807*58b9f456SAndroid Build Coastguard Worker}
1808*58b9f456SAndroid Build Coastguard Worker
1809*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1810*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1811*58b9f456SAndroid Build Coastguard Workertypename _Cp::const_iterator
1812*58b9f456SAndroid Build Coastguard Workerbegin(const _Cp& __c)
1813*58b9f456SAndroid Build Coastguard Worker{
1814*58b9f456SAndroid Build Coastguard Worker    return __c.begin();
1815*58b9f456SAndroid Build Coastguard Worker}
1816*58b9f456SAndroid Build Coastguard Worker
1817*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1818*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1819*58b9f456SAndroid Build Coastguard Workertypename _Cp::iterator
1820*58b9f456SAndroid Build Coastguard Workerend(_Cp& __c)
1821*58b9f456SAndroid Build Coastguard Worker{
1822*58b9f456SAndroid Build Coastguard Worker    return __c.end();
1823*58b9f456SAndroid Build Coastguard Worker}
1824*58b9f456SAndroid Build Coastguard Worker
1825*58b9f456SAndroid Build Coastguard Workertemplate <class _Cp>
1826*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1827*58b9f456SAndroid Build Coastguard Workertypename _Cp::const_iterator
1828*58b9f456SAndroid Build Coastguard Workerend(const _Cp& __c)
1829*58b9f456SAndroid Build Coastguard Worker{
1830*58b9f456SAndroid Build Coastguard Worker    return __c.end();
1831*58b9f456SAndroid Build Coastguard Worker}
1832*58b9f456SAndroid Build Coastguard Worker
1833*58b9f456SAndroid Build Coastguard Worker#endif  // !defined(_LIBCPP_CXX03_LANG)
1834*58b9f456SAndroid Build Coastguard Worker
1835*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1836*58b9f456SAndroid Build Coastguard Worker
1837*58b9f456SAndroid Build Coastguard Worker// #if _LIBCPP_STD_VER > 11
1838*58b9f456SAndroid Build Coastguard Worker// template <>
1839*58b9f456SAndroid Build Coastguard Worker// struct _LIBCPP_TEMPLATE_VIS plus<void>
1840*58b9f456SAndroid Build Coastguard Worker// {
1841*58b9f456SAndroid Build Coastguard Worker//     template <class _T1, class _T2>
1842*58b9f456SAndroid Build Coastguard Worker//     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1843*58b9f456SAndroid Build Coastguard Worker//     auto operator()(_T1&& __t, _T2&& __u) const
1844*58b9f456SAndroid Build Coastguard Worker//     _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
1845*58b9f456SAndroid Build Coastguard Worker//     -> decltype        (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
1846*58b9f456SAndroid Build Coastguard Worker//         { return        _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
1847*58b9f456SAndroid Build Coastguard Worker//     typedef void is_transparent;
1848*58b9f456SAndroid Build Coastguard Worker// };
1849*58b9f456SAndroid Build Coastguard Worker// #endif
1850*58b9f456SAndroid Build Coastguard Worker
1851*58b9f456SAndroid Build Coastguard Workertemplate <class _Cont>
1852*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1853*58b9f456SAndroid Build Coastguard Workerconstexpr auto size(const _Cont& __c)
1854*58b9f456SAndroid Build Coastguard Worker_NOEXCEPT_(noexcept(__c.size()))
1855*58b9f456SAndroid Build Coastguard Worker-> decltype        (__c.size())
1856*58b9f456SAndroid Build Coastguard Worker{ return            __c.size(); }
1857*58b9f456SAndroid Build Coastguard Worker
1858*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Sz>
1859*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1860*58b9f456SAndroid Build Coastguard Workerconstexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; }
1861*58b9f456SAndroid Build Coastguard Worker
1862*58b9f456SAndroid Build Coastguard Workertemplate <class _Cont>
1863*58b9f456SAndroid Build Coastguard Worker_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
1864*58b9f456SAndroid Build Coastguard Workerconstexpr auto empty(const _Cont& __c)
1865*58b9f456SAndroid Build Coastguard Worker_NOEXCEPT_(noexcept(__c.empty()))
1866*58b9f456SAndroid Build Coastguard Worker-> decltype        (__c.empty())
1867*58b9f456SAndroid Build Coastguard Worker{ return            __c.empty(); }
1868*58b9f456SAndroid Build Coastguard Worker
1869*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Sz>
1870*58b9f456SAndroid Build Coastguard Worker_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
1871*58b9f456SAndroid Build Coastguard Workerconstexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; }
1872*58b9f456SAndroid Build Coastguard Worker
1873*58b9f456SAndroid Build Coastguard Workertemplate <class _Ep>
1874*58b9f456SAndroid Build Coastguard Worker_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
1875*58b9f456SAndroid Build Coastguard Workerconstexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; }
1876*58b9f456SAndroid Build Coastguard Worker
1877*58b9f456SAndroid Build Coastguard Workertemplate <class _Cont> constexpr
1878*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1879*58b9f456SAndroid Build Coastguard Workerauto data(_Cont& __c)
1880*58b9f456SAndroid Build Coastguard Worker_NOEXCEPT_(noexcept(__c.data()))
1881*58b9f456SAndroid Build Coastguard Worker-> decltype        (__c.data())
1882*58b9f456SAndroid Build Coastguard Worker{ return            __c.data(); }
1883*58b9f456SAndroid Build Coastguard Worker
1884*58b9f456SAndroid Build Coastguard Workertemplate <class _Cont> constexpr
1885*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1886*58b9f456SAndroid Build Coastguard Workerauto data(const _Cont& __c)
1887*58b9f456SAndroid Build Coastguard Worker_NOEXCEPT_(noexcept(__c.data()))
1888*58b9f456SAndroid Build Coastguard Worker-> decltype        (__c.data())
1889*58b9f456SAndroid Build Coastguard Worker{ return            __c.data(); }
1890*58b9f456SAndroid Build Coastguard Worker
1891*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Sz>
1892*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1893*58b9f456SAndroid Build Coastguard Workerconstexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; }
1894*58b9f456SAndroid Build Coastguard Worker
1895*58b9f456SAndroid Build Coastguard Workertemplate <class _Ep>
1896*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1897*58b9f456SAndroid Build Coastguard Workerconstexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); }
1898*58b9f456SAndroid Build Coastguard Worker#endif
1899*58b9f456SAndroid Build Coastguard Worker
1900*58b9f456SAndroid Build Coastguard Worker
1901*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
1902*58b9f456SAndroid Build Coastguard Worker
1903*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_ITERATOR
1904