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