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