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