13e519524SHoward Hinnant// -*- C++ -*- 23e519524SHoward Hinnant//===-------------------------- iterator ----------------------------------===// 33e519524SHoward Hinnant// 457b08b09SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 557b08b09SChandler Carruth// See https://llvm.org/LICENSE.txt for license information. 657b08b09SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 73e519524SHoward Hinnant// 83e519524SHoward Hinnant//===----------------------------------------------------------------------===// 93e519524SHoward Hinnant 103e519524SHoward Hinnant#ifndef _LIBCPP_ITERATOR 113e519524SHoward Hinnant#define _LIBCPP_ITERATOR 123e519524SHoward Hinnant 133e519524SHoward Hinnant/* 143e519524SHoward Hinnant iterator synopsis 153e519524SHoward Hinnant 16fe31f11cSChristopher Di Bella#include <concepts> 17fe31f11cSChristopher Di Bella 183e519524SHoward Hinnantnamespace std 193e519524SHoward Hinnant{ 20fe31f11cSChristopher Di Bellatemplate<class> struct incrementable_traits; // since C++20 219816d43cSChristopher Di Bellatemplate<class T> 229816d43cSChristopher Di Bella using iter_difference_t = see below; // since C++20 239816d43cSChristopher Di Bella 24f280505aSChristopher Di Bellatemplate<class> struct indirectly_readable_traits; // since C++20 259816d43cSChristopher Di Bellatemplate<class T> 269816d43cSChristopher Di Bella using iter_value_t = see below; // since C++20 273e519524SHoward Hinnant 283e519524SHoward Hinnanttemplate<class Iterator> 299f01ac3bSzoecarverstruct iterator_traits; 303e519524SHoward Hinnant 313e519524SHoward Hinnanttemplate<class T> 329f01ac3bSzoecarver requires is_object_v<T> // since C++20 339f01ac3bSzoecarverstruct iterator_traits<T*>; 343e519524SHoward Hinnant 350148b653SChristopher Di Bellatemplate<dereferenceable T> 360148b653SChristopher Di Bella using iter_reference_t = decltype(*declval<T&>()); 370148b653SChristopher Di Bella 3897e383aaSLouis Dionnenamespace ranges::inline unspecified { 3997e383aaSLouis Dionne inline constexpr unspecified iter_move = unspecified; // since C++20, nodiscard as an extension 4097e383aaSLouis Dionne}} 4197e383aaSLouis Dionne 4297e383aaSLouis Dionnetemplate<dereferenceable T> 4397e383aaSLouis Dionne requires ... 4497e383aaSLouis Dionneusing iter_rvalue_reference_t = decltype(ranges::iter_move(declval<T&>())); // since C++20 4597e383aaSLouis Dionne 4657ebf3d0SLouis Dionne// [iterator.concepts], iterator concepts 4757ebf3d0SLouis Dionne// [iterator.concept.readable], concept indirectly_readable 4857ebf3d0SLouis Dionnetemplate<class In> 4957ebf3d0SLouis Dionne concept indirectly_readable = see below; // since C++20 5057ebf3d0SLouis Dionne 5158b29a4eSLouis Dionnetemplate<indirectly_readable T> 5258b29a4eSLouis Dionne using iter_common_reference_t = 5358b29a4eSLouis Dionne common_reference_t<iter_reference_t<T>, iter_value_t<T>&>; // since C++20 5458b29a4eSLouis Dionne 5557ebf3d0SLouis Dionne// [iterator.concept.writable], concept indirectly_writable 5657ebf3d0SLouis Dionnetemplate<class Out, class T> 5757ebf3d0SLouis Dionne concept indirectly_writable = see below; // since C++20 5857ebf3d0SLouis Dionne 5918b03b00SMark de Wever// [iterator.concept.winc], concept weakly_incrementable 6022052860SChristopher Di Bellatemplate<class I> 6122052860SChristopher Di Bella concept weakly_incrementable = see below; // since C++20 6222052860SChristopher Di Bella 6322052860SChristopher Di Bella// [iterator.concept.inc], concept incrementable 6422052860SChristopher Di Bellatemplate<class I> 6522052860SChristopher Di Bella concept incrementable = see below; // since C++20 6622052860SChristopher Di Bella 6718b03b00SMark de Wever// [iterator.concept.iterator], concept input_or_output_iterator 6838225d69SChristopher Di Bella template<class I> 6938225d69SChristopher Di Bella concept input_or_output_iterator = see below; // since C++20 7038225d69SChristopher Di Bella 7118b03b00SMark de Wever// [iterator.concept.sentinel], concept sentinel_for 7238225d69SChristopher Di Bellatemplate<class S, class I> 7338225d69SChristopher Di Bella concept sentinel_for = see below; // since C++20 7438225d69SChristopher Di Bella 75bdd68357Szoecarver// [iterator.concept.sizedsentinel], concept sized_sentinel_for 76bdd68357Szoecarvertemplate<class S, class I> 77bdd68357Szoecarver inline constexpr bool disable_sized_sentinel_for = false; 78bdd68357Szoecarver 79bdd68357Szoecarvertemplate<class S, class I> 80bdd68357Szoecarver concept sized_sentinel_for = see below; 81bdd68357Szoecarver 82c05d1eedSChristopher Di Bella// [iterator.concept.input], concept input_iterator 83c05d1eedSChristopher Di Bellatemplate<class I> 84c05d1eedSChristopher Di Bella concept input_iterator = see below; // since C++20 85c05d1eedSChristopher Di Bella 86fa3e2626SChristopher Di Bella// [iterator.concept.forward], concept forward_iterator 87fa3e2626SChristopher Di Bellatemplate<class I> 88fa3e2626SChristopher Di Bella concept forward_iterator = see below; // since C++20 89fa3e2626SChristopher Di Bella 909c5d86aaSChristopher Di Bella// [iterator.concept.bidir], concept bidirectional_iterator 919c5d86aaSChristopher Di Bellatemplate<class I> 929c5d86aaSChristopher Di Bella concept bidirectional_iterator = see below; // since C++20 939c5d86aaSChristopher Di Bella 946ffc41b0Szoecarver// [iterator.concept.random.access], concept random_access_iterator 956ffc41b0Szoecarvertemplate<class I> 966ffc41b0Szoecarver concept random_access_iterator = see below; // since C++20 976ffc41b0Szoecarver 9858b29a4eSLouis Dionne// [indirectcallable] 9958b29a4eSLouis Dionne// [indirectcallable.indirectinvocable] 10058b29a4eSLouis Dionnetemplate<class F, class I> 10158b29a4eSLouis Dionne concept indirectly_unary_invocable = see below; // since C++20 10258b29a4eSLouis Dionne 10358b29a4eSLouis Dionnetemplate<class F, class I> 10458b29a4eSLouis Dionne concept indirectly_regular_unary_invocable = see below; // since C++20 10558b29a4eSLouis Dionne 10658b29a4eSLouis Dionnetemplate<class F, class I> 10758b29a4eSLouis Dionne concept indirect_unary_predicate = see below; // since C++20 10858b29a4eSLouis Dionne 10958b29a4eSLouis Dionnetemplate<class F, class I1, class I2> 11058b29a4eSLouis Dionne concept indirect_binary_predicate = see below; // since C++20 11158b29a4eSLouis Dionne 11258b29a4eSLouis Dionnetemplate<class F, class I1, class I2 = I1> 11358b29a4eSLouis Dionne concept indirect_equivalence_relation = see below; // since C++20 11458b29a4eSLouis Dionne 11558b29a4eSLouis Dionnetemplate<class F, class I1, class I2 = I1> 11658b29a4eSLouis Dionne concept indirect_strict_weak_order = see below; // since C++20 11758b29a4eSLouis Dionne 11858b29a4eSLouis Dionnetemplate<class F, class... Is> 11958b29a4eSLouis Dionne using indirect_result_t = see below; // since C++20 12058b29a4eSLouis Dionne 12158b29a4eSLouis Dionne// [projected], projected 12258b29a4eSLouis Dionnetemplate<indirectly_readable I, indirectly_regular_unary_invocable<I> Proj> 12358b29a4eSLouis Dionne struct projected; // since C++20 12458b29a4eSLouis Dionne 12558b29a4eSLouis Dionnetemplate<weakly_incrementable I, indirectly_regular_unary_invocable<I> Proj> 12658b29a4eSLouis Dionne struct incrementable_traits<projected<I, Proj>>; // since C++20 12758b29a4eSLouis Dionne 128075f2370Szoecarver// [alg.req.ind.move], concept indirectly_movable 129075f2370Szoecarvertemplate<class In, class Out> 130075f2370Szoecarver concept indirectly_movable = see below; // since C++20 131075f2370Szoecarver 132075f2370Szoecarvertemplate<class In, class Out> 133075f2370Szoecarver concept indirectly_movable_storable = see below; // since C++20 134075f2370Szoecarver 1353e519524SHoward Hinnanttemplate<class Category, class T, class Distance = ptrdiff_t, 1363e519524SHoward Hinnant class Pointer = T*, class Reference = T&> 1371055cb91SLouis Dionnestruct iterator // deprecated in C++17 1383e519524SHoward Hinnant{ 1393e519524SHoward Hinnant typedef T value_type; 1403e519524SHoward Hinnant typedef Distance difference_type; 1413e519524SHoward Hinnant typedef Pointer pointer; 1423e519524SHoward Hinnant typedef Reference reference; 1433e519524SHoward Hinnant typedef Category iterator_category; 1443e519524SHoward Hinnant}; 1453e519524SHoward Hinnant 1463e519524SHoward Hinnantstruct input_iterator_tag {}; 1473e519524SHoward Hinnantstruct output_iterator_tag {}; 1483e519524SHoward Hinnantstruct forward_iterator_tag : public input_iterator_tag {}; 1493e519524SHoward Hinnantstruct bidirectional_iterator_tag : public forward_iterator_tag {}; 1503e519524SHoward Hinnantstruct random_access_iterator_tag : public bidirectional_iterator_tag {}; 1513e519524SHoward Hinnant 152f51ee632SMarshall Clow// 27.4.3, iterator operations 15312b01ab7SLouis Dionnetemplate <class InputIterator, class Distance> // constexpr in C++17 15412b01ab7SLouis Dionne constexpr void advance(InputIterator& i, Distance n); 1553e519524SHoward Hinnant 156f51ee632SMarshall Clowtemplate <class InputIterator> // constexpr in C++17 157f51ee632SMarshall Clow constexpr typename iterator_traits<InputIterator>::difference_type 1583e519524SHoward Hinnant distance(InputIterator first, InputIterator last); 1593e519524SHoward Hinnant 160f51ee632SMarshall Clowtemplate <class InputIterator> // constexpr in C++17 161f51ee632SMarshall Clow constexpr InputIterator next(InputIterator x, 162f51ee632SMarshall Clowtypename iterator_traits<InputIterator>::difference_type n = 1); 163f51ee632SMarshall Clow 164f51ee632SMarshall Clowtemplate <class BidirectionalIterator> // constexpr in C++17 165f51ee632SMarshall Clow constexpr BidirectionalIterator prev(BidirectionalIterator x, 166f51ee632SMarshall Clow typename iterator_traits<BidirectionalIterator>::difference_type n = 1); 167f51ee632SMarshall Clow 16836d0fdf9SChristopher Di Bella// [range.iter.ops], range iterator operations 16936d0fdf9SChristopher Di Bellanamespace ranges { 17036d0fdf9SChristopher Di Bella // [range.iter.op.advance], ranges::advance 17136d0fdf9SChristopher Di Bella template<input_or_output_iterator I> 17236d0fdf9SChristopher Di Bella constexpr void advance(I& i, iter_difference_t<I> n); // since C++20 17336d0fdf9SChristopher Di Bella template<input_or_output_iterator I, sentinel_for<I> S> 17436d0fdf9SChristopher Di Bella constexpr void advance(I& i, S bound); // since C++20 17536d0fdf9SChristopher Di Bella template<input_or_output_iterator I, sentinel_for<I> S> 17636d0fdf9SChristopher Di Bella constexpr iter_difference_t<I> advance(I& i, iter_difference_t<I> n, S bound); // since C++20 17736d0fdf9SChristopher Di Bella} 17836d0fdf9SChristopher Di Bella 1793e519524SHoward Hinnanttemplate <class Iterator> 1803e519524SHoward Hinnantclass reverse_iterator 1811055cb91SLouis Dionne : public iterator<typename iterator_traits<Iterator>::iterator_category, // until C++17 1823e519524SHoward Hinnant typename iterator_traits<Iterator>::value_type, 1833e519524SHoward Hinnant typename iterator_traits<Iterator>::difference_type, 1843e519524SHoward Hinnant typename iterator_traits<Iterator>::pointer, 1853e519524SHoward Hinnant typename iterator_traits<Iterator>::reference> 1863e519524SHoward Hinnant{ 1873e519524SHoward Hinnantprotected: 1883e519524SHoward Hinnant Iterator current; 1893e519524SHoward Hinnantpublic: 1903e519524SHoward Hinnant typedef Iterator iterator_type; 1913e519524SHoward Hinnant typedef typename iterator_traits<Iterator>::difference_type difference_type; 1923e519524SHoward Hinnant typedef typename iterator_traits<Iterator>::reference reference; 1933e519524SHoward Hinnant typedef typename iterator_traits<Iterator>::pointer pointer; 1943e519524SHoward Hinnant 1951b8f260eSMarshall Clow constexpr reverse_iterator(); 1961b8f260eSMarshall Clow constexpr explicit reverse_iterator(Iterator x); 1971b8f260eSMarshall Clow template <class U> constexpr reverse_iterator(const reverse_iterator<U>& u); 1981b8f260eSMarshall Clow template <class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u); 1991b8f260eSMarshall Clow constexpr Iterator base() const; 2001b8f260eSMarshall Clow constexpr reference operator*() const; 2011b8f260eSMarshall Clow constexpr pointer operator->() const; 2021b8f260eSMarshall Clow constexpr reverse_iterator& operator++(); 2031b8f260eSMarshall Clow constexpr reverse_iterator operator++(int); 2041b8f260eSMarshall Clow constexpr reverse_iterator& operator--(); 2051b8f260eSMarshall Clow constexpr reverse_iterator operator--(int); 2061b8f260eSMarshall Clow constexpr reverse_iterator operator+ (difference_type n) const; 2071b8f260eSMarshall Clow constexpr reverse_iterator& operator+=(difference_type n); 2081b8f260eSMarshall Clow constexpr reverse_iterator operator- (difference_type n) const; 2091b8f260eSMarshall Clow constexpr reverse_iterator& operator-=(difference_type n); 2101b8f260eSMarshall Clow constexpr reference operator[](difference_type n) const; 2113e519524SHoward Hinnant}; 2123e519524SHoward Hinnant 2133e519524SHoward Hinnanttemplate <class Iterator1, class Iterator2> 2141b8f260eSMarshall Clowconstexpr bool // constexpr in C++17 2153e519524SHoward Hinnantoperator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 2163e519524SHoward Hinnant 2173e519524SHoward Hinnanttemplate <class Iterator1, class Iterator2> 2181b8f260eSMarshall Clowconstexpr bool // constexpr in C++17 2193e519524SHoward Hinnantoperator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 2203e519524SHoward Hinnant 2213e519524SHoward Hinnanttemplate <class Iterator1, class Iterator2> 2221b8f260eSMarshall Clowconstexpr bool // constexpr in C++17 2233e519524SHoward Hinnantoperator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 2243e519524SHoward Hinnant 2253e519524SHoward Hinnanttemplate <class Iterator1, class Iterator2> 2261b8f260eSMarshall Clowconstexpr bool // constexpr in C++17 2273e519524SHoward Hinnantoperator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 2283e519524SHoward Hinnant 2293e519524SHoward Hinnanttemplate <class Iterator1, class Iterator2> 2301b8f260eSMarshall Clowconstexpr bool // constexpr in C++17 2313e519524SHoward Hinnantoperator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 2323e519524SHoward Hinnant 2333e519524SHoward Hinnanttemplate <class Iterator1, class Iterator2> 2341b8f260eSMarshall Clowconstexpr bool // constexpr in C++17 2353e519524SHoward Hinnantoperator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 2363e519524SHoward Hinnant 2373e519524SHoward Hinnanttemplate <class Iterator1, class Iterator2> 2381b8f260eSMarshall Clowconstexpr auto 239947ce6b5SMarshall Clowoperator-(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y) 2401b8f260eSMarshall Clow-> decltype(__y.base() - __x.base()); // constexpr in C++17 2413e519524SHoward Hinnant 2423e519524SHoward Hinnanttemplate <class Iterator> 2431b8f260eSMarshall Clowconstexpr reverse_iterator<Iterator> 2441b8f260eSMarshall Clowoperator+(typename reverse_iterator<Iterator>::difference_type n, 2451b8f260eSMarshall Clow const reverse_iterator<Iterator>& x); // constexpr in C++17 2463e519524SHoward Hinnant 2471b8f260eSMarshall Clowtemplate <class Iterator> 2481b8f260eSMarshall Clowconstexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14, constexpr in C++17 2496a640a18SMarshall Clow 2503e519524SHoward Hinnanttemplate <class Container> 2513e519524SHoward Hinnantclass back_insert_iterator 25241bdf64dSLouis Dionne : public iterator<output_iterator_tag, void, void, void, void> // until C++17 2533e519524SHoward Hinnant{ 2543e519524SHoward Hinnantprotected: 2553e519524SHoward Hinnant Container* container; 2563e519524SHoward Hinnantpublic: 2573e519524SHoward Hinnant typedef Container container_type; 2583e519524SHoward Hinnant typedef void value_type; 25941bdf64dSLouis Dionne typedef void difference_type; // until C++20 26041bdf64dSLouis Dionne typedef ptrdiff_t difference_type; // since C++20 2618892b4eeSEric Fiselier typedef void reference; 2623e519524SHoward Hinnant typedef void pointer; 2633e519524SHoward Hinnant 26406e2b737SArthur O'Dwyer explicit back_insert_iterator(Container& x); // constexpr in C++20 26506e2b737SArthur O'Dwyer back_insert_iterator& operator=(const typename Container::value_type& value); // constexpr in C++20 26606e2b737SArthur O'Dwyer back_insert_iterator& operator*(); // constexpr in C++20 26706e2b737SArthur O'Dwyer back_insert_iterator& operator++(); // constexpr in C++20 26806e2b737SArthur O'Dwyer back_insert_iterator operator++(int); // constexpr in C++20 2693e519524SHoward Hinnant}; 2703e519524SHoward Hinnant 27106e2b737SArthur O'Dwyertemplate <class Container> back_insert_iterator<Container> back_inserter(Container& x); // constexpr in C++20 2723e519524SHoward Hinnant 2733e519524SHoward Hinnanttemplate <class Container> 2743e519524SHoward Hinnantclass front_insert_iterator 27541bdf64dSLouis Dionne : public iterator<output_iterator_tag, void, void, void, void> // until C++17 2763e519524SHoward Hinnant{ 2773e519524SHoward Hinnantprotected: 2783e519524SHoward Hinnant Container* container; 2793e519524SHoward Hinnantpublic: 2803e519524SHoward Hinnant typedef Container container_type; 2813e519524SHoward Hinnant typedef void value_type; 28241bdf64dSLouis Dionne typedef void difference_type; // until C++20 28341bdf64dSLouis Dionne typedef ptrdiff_t difference_type; // since C++20 2848892b4eeSEric Fiselier typedef void reference; 2853e519524SHoward Hinnant typedef void pointer; 2863e519524SHoward Hinnant 28706e2b737SArthur O'Dwyer explicit front_insert_iterator(Container& x); // constexpr in C++20 28806e2b737SArthur O'Dwyer front_insert_iterator& operator=(const typename Container::value_type& value); // constexpr in C++20 28906e2b737SArthur O'Dwyer front_insert_iterator& operator*(); // constexpr in C++20 29006e2b737SArthur O'Dwyer front_insert_iterator& operator++(); // constexpr in C++20 29106e2b737SArthur O'Dwyer front_insert_iterator operator++(int); // constexpr in C++20 2923e519524SHoward Hinnant}; 2933e519524SHoward Hinnant 29406e2b737SArthur O'Dwyertemplate <class Container> front_insert_iterator<Container> front_inserter(Container& x); // constexpr in C++20 2953e519524SHoward Hinnant 2963e519524SHoward Hinnanttemplate <class Container> 2973e519524SHoward Hinnantclass insert_iterator 29841bdf64dSLouis Dionne : public iterator<output_iterator_tag, void, void, void, void> // until C++17 2993e519524SHoward Hinnant{ 3003e519524SHoward Hinnantprotected: 3013e519524SHoward Hinnant Container* container; 3023e519524SHoward Hinnant typename Container::iterator iter; 3033e519524SHoward Hinnantpublic: 3043e519524SHoward Hinnant typedef Container container_type; 3053e519524SHoward Hinnant typedef void value_type; 30641bdf64dSLouis Dionne typedef void difference_type; // until C++20 30741bdf64dSLouis Dionne typedef ptrdiff_t difference_type; // since C++20 3088892b4eeSEric Fiselier typedef void reference; 3093e519524SHoward Hinnant typedef void pointer; 3103e519524SHoward Hinnant 31106e2b737SArthur O'Dwyer insert_iterator(Container& x, typename Container::iterator i); // constexpr in C++20 31206e2b737SArthur O'Dwyer insert_iterator& operator=(const typename Container::value_type& value); // constexpr in C++20 31306e2b737SArthur O'Dwyer insert_iterator& operator*(); // constexpr in C++20 31406e2b737SArthur O'Dwyer insert_iterator& operator++(); // constexpr in C++20 31506e2b737SArthur O'Dwyer insert_iterator& operator++(int); // constexpr in C++20 3163e519524SHoward Hinnant}; 3173e519524SHoward Hinnant 3183e519524SHoward Hinnanttemplate <class Container, class Iterator> 31906e2b737SArthur O'Dwyerinsert_iterator<Container> inserter(Container& x, Iterator i); // constexpr in C++20 3203e519524SHoward Hinnant 321947ce6b5SMarshall Clowtemplate <class Iterator> 322947ce6b5SMarshall Clowclass move_iterator { 323947ce6b5SMarshall Clowpublic: 324947ce6b5SMarshall Clow typedef Iterator iterator_type; 325947ce6b5SMarshall Clow typedef typename iterator_traits<Iterator>::difference_type difference_type; 326947ce6b5SMarshall Clow typedef Iterator pointer; 327947ce6b5SMarshall Clow typedef typename iterator_traits<Iterator>::value_type value_type; 328947ce6b5SMarshall Clow typedef typename iterator_traits<Iterator>::iterator_category iterator_category; 329947ce6b5SMarshall Clow typedef value_type&& reference; 330947ce6b5SMarshall Clow 331720ef472SMarshall Clow constexpr move_iterator(); // all the constexprs are in C++17 332720ef472SMarshall Clow constexpr explicit move_iterator(Iterator i); 333720ef472SMarshall Clow template <class U> 334720ef472SMarshall Clow constexpr move_iterator(const move_iterator<U>& u); 335720ef472SMarshall Clow template <class U> 336720ef472SMarshall Clow constexpr move_iterator& operator=(const move_iterator<U>& u); 337720ef472SMarshall Clow constexpr iterator_type base() const; 338720ef472SMarshall Clow constexpr reference operator*() const; 339720ef472SMarshall Clow constexpr pointer operator->() const; 340720ef472SMarshall Clow constexpr move_iterator& operator++(); 341720ef472SMarshall Clow constexpr move_iterator operator++(int); 342720ef472SMarshall Clow constexpr move_iterator& operator--(); 343720ef472SMarshall Clow constexpr move_iterator operator--(int); 344720ef472SMarshall Clow constexpr move_iterator operator+(difference_type n) const; 345720ef472SMarshall Clow constexpr move_iterator& operator+=(difference_type n); 346720ef472SMarshall Clow constexpr move_iterator operator-(difference_type n) const; 347720ef472SMarshall Clow constexpr move_iterator& operator-=(difference_type n); 348720ef472SMarshall Clow constexpr unspecified operator[](difference_type n) const; 349947ce6b5SMarshall Clowprivate: 350947ce6b5SMarshall Clow Iterator current; // exposition only 351947ce6b5SMarshall Clow}; 352947ce6b5SMarshall Clow 353947ce6b5SMarshall Clowtemplate <class Iterator1, class Iterator2> 354720ef472SMarshall Clowconstexpr bool // constexpr in C++17 355947ce6b5SMarshall Clowoperator==(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 356947ce6b5SMarshall Clow 357947ce6b5SMarshall Clowtemplate <class Iterator1, class Iterator2> 358720ef472SMarshall Clowconstexpr bool // constexpr in C++17 359947ce6b5SMarshall Clowoperator!=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 360947ce6b5SMarshall Clow 361947ce6b5SMarshall Clowtemplate <class Iterator1, class Iterator2> 362720ef472SMarshall Clowconstexpr bool // constexpr in C++17 363947ce6b5SMarshall Clowoperator<(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 364947ce6b5SMarshall Clow 365947ce6b5SMarshall Clowtemplate <class Iterator1, class Iterator2> 366720ef472SMarshall Clowconstexpr bool // constexpr in C++17 367947ce6b5SMarshall Clowoperator<=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 368947ce6b5SMarshall Clow 369947ce6b5SMarshall Clowtemplate <class Iterator1, class Iterator2> 370720ef472SMarshall Clowconstexpr bool // constexpr in C++17 371947ce6b5SMarshall Clowoperator>(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 372947ce6b5SMarshall Clow 373947ce6b5SMarshall Clowtemplate <class Iterator1, class Iterator2> 374720ef472SMarshall Clowconstexpr bool // constexpr in C++17 375947ce6b5SMarshall Clowoperator>=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 376947ce6b5SMarshall Clow 377947ce6b5SMarshall Clowtemplate <class Iterator1, class Iterator2> 378720ef472SMarshall Clowconstexpr auto // constexpr in C++17 379947ce6b5SMarshall Clowoperator-(const move_iterator<Iterator1>& x, 380947ce6b5SMarshall Clow const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base()); 381947ce6b5SMarshall Clow 382947ce6b5SMarshall Clowtemplate <class Iterator> 383720ef472SMarshall Clowconstexpr move_iterator<Iterator> operator+( // constexpr in C++17 384720ef472SMarshall Clow typename move_iterator<Iterator>::difference_type n, 385947ce6b5SMarshall Clow const move_iterator<Iterator>& x); 386947ce6b5SMarshall Clow 387720ef472SMarshall Clowtemplate <class Iterator> // constexpr in C++17 388720ef472SMarshall Clowconstexpr move_iterator<Iterator> make_move_iterator(const Iterator& i); 389947ce6b5SMarshall Clow 390065cf3f9Szoecarver// [default.sentinel], default sentinel 391065cf3f9Szoecarverstruct default_sentinel_t; 392065cf3f9Szoecarverinline constexpr default_sentinel_t default_sentinel{}; 393947ce6b5SMarshall Clow 3943e519524SHoward Hinnanttemplate <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t> 3953e519524SHoward Hinnantclass istream_iterator 3961055cb91SLouis Dionne : public iterator<input_iterator_tag, T, Distance, const T*, const T&> // until C++17 3973e519524SHoward Hinnant{ 3983e519524SHoward Hinnantpublic: 39941bdf64dSLouis Dionne typedef input_iterator_tag iterator_category; 40041bdf64dSLouis Dionne typedef T value_type; 40141bdf64dSLouis Dionne typedef Distance difference_type; 40241bdf64dSLouis Dionne typedef const T* pointer; 40341bdf64dSLouis Dionne typedef const T& reference; 40441bdf64dSLouis Dionne 4053e519524SHoward Hinnant typedef charT char_type; 4063e519524SHoward Hinnant typedef traits traits_type; 4073e519524SHoward Hinnant typedef basic_istream<charT, traits> istream_type; 4083e519524SHoward Hinnant 40960d5e0e0SMarshall Clow constexpr istream_iterator(); 4103e519524SHoward Hinnant istream_iterator(istream_type& s); 4113e519524SHoward Hinnant istream_iterator(const istream_iterator& x); 4123e519524SHoward Hinnant ~istream_iterator(); 4133e519524SHoward Hinnant 4143e519524SHoward Hinnant const T& operator*() const; 4153e519524SHoward Hinnant const T* operator->() const; 4163e519524SHoward Hinnant istream_iterator& operator++(); 4173e519524SHoward Hinnant istream_iterator operator++(int); 4183e519524SHoward Hinnant}; 4193e519524SHoward Hinnant 4203e519524SHoward Hinnanttemplate <class T, class charT, class traits, class Distance> 4213e519524SHoward Hinnantbool operator==(const istream_iterator<T,charT,traits,Distance>& x, 4223e519524SHoward Hinnant const istream_iterator<T,charT,traits,Distance>& y); 4233e519524SHoward Hinnanttemplate <class T, class charT, class traits, class Distance> 4243e519524SHoward Hinnantbool operator!=(const istream_iterator<T,charT,traits,Distance>& x, 4253e519524SHoward Hinnant const istream_iterator<T,charT,traits,Distance>& y); 4263e519524SHoward Hinnant 4273e519524SHoward Hinnanttemplate <class T, class charT = char, class traits = char_traits<charT> > 4283e519524SHoward Hinnantclass ostream_iterator 4291055cb91SLouis Dionne : public iterator<output_iterator_tag, void, void, void, void> // until C++17 4303e519524SHoward Hinnant{ 4313e519524SHoward Hinnantpublic: 43241bdf64dSLouis Dionne typedef output_iterator_tag iterator_category; 43341bdf64dSLouis Dionne typedef void value_type; 43441bdf64dSLouis Dionne typedef void difference_type; // until C++20 43541bdf64dSLouis Dionne typedef ptrdiff_t difference_type; // since C++20 43641bdf64dSLouis Dionne typedef void pointer; 43741bdf64dSLouis Dionne typedef void reference; 43841bdf64dSLouis Dionne 4393e519524SHoward Hinnant typedef charT char_type; 4403e519524SHoward Hinnant typedef traits traits_type; 4413e519524SHoward Hinnant typedef basic_ostream<charT,traits> ostream_type; 4423e519524SHoward Hinnant 4433e519524SHoward Hinnant ostream_iterator(ostream_type& s); 4443e519524SHoward Hinnant ostream_iterator(ostream_type& s, const charT* delimiter); 4453e519524SHoward Hinnant ostream_iterator(const ostream_iterator& x); 4463e519524SHoward Hinnant ~ostream_iterator(); 4473e519524SHoward Hinnant ostream_iterator& operator=(const T& value); 4483e519524SHoward Hinnant 4493e519524SHoward Hinnant ostream_iterator& operator*(); 4503e519524SHoward Hinnant ostream_iterator& operator++(); 4513e519524SHoward Hinnant ostream_iterator& operator++(int); 4523e519524SHoward Hinnant}; 4533e519524SHoward Hinnant 4543e519524SHoward Hinnanttemplate<class charT, class traits = char_traits<charT> > 4553e519524SHoward Hinnantclass istreambuf_iterator 45641bdf64dSLouis Dionne : public iterator<input_iterator_tag, charT, traits::off_type, unspecified, charT> // until C++17 4573e519524SHoward Hinnant{ 4583e519524SHoward Hinnantpublic: 45941bdf64dSLouis Dionne typedef input_iterator_tag iterator_category; 46041bdf64dSLouis Dionne typedef charT value_type; 46141bdf64dSLouis Dionne typedef traits::off_type difference_type; 46241bdf64dSLouis Dionne typedef unspecified pointer; 46341bdf64dSLouis Dionne typedef charT reference; 46441bdf64dSLouis Dionne 4653e519524SHoward Hinnant typedef charT char_type; 4663e519524SHoward Hinnant typedef traits traits_type; 46741bdf64dSLouis Dionne typedef traits::int_type int_type; 4683e519524SHoward Hinnant typedef basic_streambuf<charT, traits> streambuf_type; 4693e519524SHoward Hinnant typedef basic_istream<charT, traits> istream_type; 4703e519524SHoward Hinnant 4718e882dcbSHoward Hinnant istreambuf_iterator() noexcept; 4728e882dcbSHoward Hinnant istreambuf_iterator(istream_type& s) noexcept; 4738e882dcbSHoward Hinnant istreambuf_iterator(streambuf_type* s) noexcept; 4748e882dcbSHoward Hinnant istreambuf_iterator(a-private-type) noexcept; 4753e519524SHoward Hinnant 4763e519524SHoward Hinnant charT operator*() const; 4773e519524SHoward Hinnant pointer operator->() const; 4783e519524SHoward Hinnant istreambuf_iterator& operator++(); 4793e519524SHoward Hinnant a-private-type operator++(int); 4803e519524SHoward Hinnant 4813e519524SHoward Hinnant bool equal(const istreambuf_iterator& b) const; 4823e519524SHoward Hinnant}; 4833e519524SHoward Hinnant 4843e519524SHoward Hinnanttemplate <class charT, class traits> 4853e519524SHoward Hinnantbool operator==(const istreambuf_iterator<charT,traits>& a, 4863e519524SHoward Hinnant const istreambuf_iterator<charT,traits>& b); 4873e519524SHoward Hinnanttemplate <class charT, class traits> 4883e519524SHoward Hinnantbool operator!=(const istreambuf_iterator<charT,traits>& a, 4893e519524SHoward Hinnant const istreambuf_iterator<charT,traits>& b); 4903e519524SHoward Hinnant 4913e519524SHoward Hinnanttemplate <class charT, class traits = char_traits<charT> > 4923e519524SHoward Hinnantclass ostreambuf_iterator 4931055cb91SLouis Dionne : public iterator<output_iterator_tag, void, void, void, void> // until C++17 4943e519524SHoward Hinnant{ 4953e519524SHoward Hinnantpublic: 49641bdf64dSLouis Dionne typedef output_iterator_tag iterator_category; 49741bdf64dSLouis Dionne typedef void value_type; 49841bdf64dSLouis Dionne typedef void difference_type; // until C++20 49941bdf64dSLouis Dionne typedef ptrdiff_t difference_type; // since C++20 50041bdf64dSLouis Dionne typedef void pointer; 50141bdf64dSLouis Dionne typedef void reference; 50241bdf64dSLouis Dionne 5033e519524SHoward Hinnant typedef charT char_type; 5043e519524SHoward Hinnant typedef traits traits_type; 5053e519524SHoward Hinnant typedef basic_streambuf<charT, traits> streambuf_type; 5063e519524SHoward Hinnant typedef basic_ostream<charT, traits> ostream_type; 5073e519524SHoward Hinnant 5088e882dcbSHoward Hinnant ostreambuf_iterator(ostream_type& s) noexcept; 5098e882dcbSHoward Hinnant ostreambuf_iterator(streambuf_type* s) noexcept; 5103e519524SHoward Hinnant ostreambuf_iterator& operator=(charT c); 5113e519524SHoward Hinnant ostreambuf_iterator& operator*(); 5123e519524SHoward Hinnant ostreambuf_iterator& operator++(); 5133e519524SHoward Hinnant ostreambuf_iterator& operator++(int); 5148e882dcbSHoward Hinnant bool failed() const noexcept; 5153e519524SHoward Hinnant}; 5163e519524SHoward Hinnant 517020b623aSMarshall Clowtemplate <class C> constexpr auto begin(C& c) -> decltype(c.begin()); 518020b623aSMarshall Clowtemplate <class C> constexpr auto begin(const C& c) -> decltype(c.begin()); 519020b623aSMarshall Clowtemplate <class C> constexpr auto end(C& c) -> decltype(c.end()); 520020b623aSMarshall Clowtemplate <class C> constexpr auto end(const C& c) -> decltype(c.end()); 521020b623aSMarshall Clowtemplate <class T, size_t N> constexpr T* begin(T (&array)[N]); 522020b623aSMarshall Clowtemplate <class T, size_t N> constexpr T* end(T (&array)[N]); 5233e519524SHoward Hinnant 524020b623aSMarshall Clowtemplate <class C> auto constexpr cbegin(const C& c) -> decltype(std::begin(c)); // C++14 525020b623aSMarshall Clowtemplate <class C> auto constexpr cend(const C& c) -> decltype(std::end(c)); // C++14 526020b623aSMarshall Clowtemplate <class C> auto constexpr rbegin(C& c) -> decltype(c.rbegin()); // C++14 527020b623aSMarshall Clowtemplate <class C> auto constexpr rbegin(const C& c) -> decltype(c.rbegin()); // C++14 528020b623aSMarshall Clowtemplate <class C> auto constexpr rend(C& c) -> decltype(c.rend()); // C++14 529020b623aSMarshall Clowtemplate <class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // C++14 530020b623aSMarshall Clowtemplate <class E> reverse_iterator<const E*> constexpr rbegin(initializer_list<E> il); // C++14 531020b623aSMarshall Clowtemplate <class E> reverse_iterator<const E*> constexpr rend(initializer_list<E> il); // C++14 532020b623aSMarshall Clowtemplate <class T, size_t N> reverse_iterator<T*> constexpr rbegin(T (&array)[N]); // C++14 533020b623aSMarshall Clowtemplate <class T, size_t N> reverse_iterator<T*> constexpr rend(T (&array)[N]); // C++14 534020b623aSMarshall Clowtemplate <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 535020b623aSMarshall Clowtemplate <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); // C++14 5361e548c72SMarshall Clow 537ad755104SMarshall Clow// 24.8, container access: 538ad755104SMarshall Clowtemplate <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17 539ad755104SMarshall Clowtemplate <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17 5407d3986eaSMarshall Clow 5417d3986eaSMarshall Clowtemplate <class C> constexpr auto ssize(const C& c) 5427d3986eaSMarshall Clow -> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>; // C++20 5437d3986eaSMarshall Clowtemplate <class T, ptrdiff_t> constexpr ptrdiff_t ssize(const T (&array)[N]) noexcept; // C++20 5447d3986eaSMarshall Clow 545ad755104SMarshall Clowtemplate <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17 546ad755104SMarshall Clowtemplate <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17 547ad755104SMarshall Clowtemplate <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17 548ad755104SMarshall Clowtemplate <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17 549ad755104SMarshall Clowtemplate <class C> constexpr auto data(const C& c) -> decltype(c.data()); // C++17 550ad755104SMarshall Clowtemplate <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // C++17 551ad755104SMarshall Clowtemplate <class E> constexpr const E* data(initializer_list<E> il) noexcept; // C++17 552ad755104SMarshall Clow 5533e519524SHoward Hinnant} // std 5543e519524SHoward Hinnant 5553e519524SHoward Hinnant*/ 5563e519524SHoward Hinnant 5573e519524SHoward Hinnant#include <__config> 5585f51fb34SArthur O'Dwyer#include <__debug> 559c204c130SMarshall Clow#include <__functional_base> 56036d0fdf9SChristopher Di Bella#include <__iterator/advance.h> 56157ebf3d0SLouis Dionne#include <__iterator/concepts.h> 562065cf3f9Szoecarver#include <__iterator/default_sentinel.h> 563e0adf7e0Szoecarver#include <__iterator/incrementable_traits.h> 56497e383aaSLouis Dionne#include <__iterator/iter_move.h> 56540d6d2c4Szoecarver#include <__iterator/iter_swap.h> 566120fa829Szoecarver#include <__iterator/iterator_traits.h> 567857fa7b7SChristopher Di Bella#include <__iterator/next.h> 5680dc7fd1bSChristopher Di Bella#include <__iterator/prev.h> 56958b29a4eSLouis Dionne#include <__iterator/projected.h> 570e0adf7e0Szoecarver#include <__iterator/readable_traits.h> 571f992cfbaSLouis Dionne#include <__memory/addressof.h> 572d41c6d51SArthur O'Dwyer#include <__memory/pointer_traits.h> 573*6adbc83eSChristopher Di Bella#include <__utility/forward.h> 5745f51fb34SArthur O'Dwyer#include <compare> 5755f51fb34SArthur O'Dwyer#include <concepts> // Mandated by the Standard. 5765f51fb34SArthur O'Dwyer#include <cstddef> 5775f51fb34SArthur O'Dwyer#include <initializer_list> 5785f51fb34SArthur O'Dwyer#include <iosfwd> // for forward declarations of vector and string 5795f51fb34SArthur O'Dwyer#include <type_traits> 580f56972e2SMarshall Clow#include <version> 581b5c63a2eSHoward Hinnant 582073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 5833e519524SHoward Hinnant#pragma GCC system_header 584073458b1SHoward Hinnant#endif 5853e519524SHoward Hinnant 5863e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD 587fe31f11cSChristopher Di Bella 5883e519524SHoward Hinnanttemplate<class _Category, class _Tp, class _Distance = ptrdiff_t, 5893e519524SHoward Hinnant class _Pointer = _Tp*, class _Reference = _Tp&> 5901055cb91SLouis Dionnestruct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator 5913e519524SHoward Hinnant{ 5923e519524SHoward Hinnant typedef _Tp value_type; 5933e519524SHoward Hinnant typedef _Distance difference_type; 5943e519524SHoward Hinnant typedef _Pointer pointer; 5953e519524SHoward Hinnant typedef _Reference reference; 5963e519524SHoward Hinnant typedef _Category iterator_category; 5973e519524SHoward Hinnant}; 5983e519524SHoward Hinnant 5993e519524SHoward Hinnanttemplate <class _InputIter> 600f51ee632SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 6013e519524SHoward Hinnanttypename iterator_traits<_InputIter>::difference_type 6023e519524SHoward Hinnant__distance(_InputIter __first, _InputIter __last, input_iterator_tag) 6033e519524SHoward Hinnant{ 6043e519524SHoward Hinnant typename iterator_traits<_InputIter>::difference_type __r(0); 6053e519524SHoward Hinnant for (; __first != __last; ++__first) 6063e519524SHoward Hinnant ++__r; 6073e519524SHoward Hinnant return __r; 6083e519524SHoward Hinnant} 6093e519524SHoward Hinnant 6103e519524SHoward Hinnanttemplate <class _RandIter> 611f51ee632SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 6123e519524SHoward Hinnanttypename iterator_traits<_RandIter>::difference_type 6133e519524SHoward Hinnant__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag) 6143e519524SHoward Hinnant{ 6153e519524SHoward Hinnant return __last - __first; 6163e519524SHoward Hinnant} 6173e519524SHoward Hinnant 6183e519524SHoward Hinnanttemplate <class _InputIter> 619f51ee632SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 6203e519524SHoward Hinnanttypename iterator_traits<_InputIter>::difference_type 6213e519524SHoward Hinnantdistance(_InputIter __first, _InputIter __last) 6223e519524SHoward Hinnant{ 623c0428b3cSArthur O'Dwyer return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); 6243e519524SHoward Hinnant} 6253e519524SHoward Hinnant 626e02ed1c2SEric Fiseliertemplate <class _Tp, class = void> 627e02ed1c2SEric Fiselierstruct __is_stashing_iterator : false_type {}; 628e02ed1c2SEric Fiselier 629e02ed1c2SEric Fiseliertemplate <class _Tp> 630e02ed1c2SEric Fiselierstruct __is_stashing_iterator<_Tp, typename __void_t<typename _Tp::__stashing_iterator_tag>::type> 631e02ed1c2SEric Fiselier : true_type {}; 632e02ed1c2SEric Fiselier 6331055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_PUSH 6343e519524SHoward Hinnanttemplate <class _Iter> 635e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS reverse_iterator 6361055cb91SLouis Dionne#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) 6373e519524SHoward Hinnant : public iterator<typename iterator_traits<_Iter>::iterator_category, 6383e519524SHoward Hinnant typename iterator_traits<_Iter>::value_type, 6393e519524SHoward Hinnant typename iterator_traits<_Iter>::difference_type, 6403e519524SHoward Hinnant typename iterator_traits<_Iter>::pointer, 6413e519524SHoward Hinnant typename iterator_traits<_Iter>::reference> 6421055cb91SLouis Dionne#endif 6433e519524SHoward Hinnant{ 6441055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_POP 6453b83496dSMarshall Clowprivate: 6461055cb91SLouis Dionne#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES 6471055cb91SLouis Dionne _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break 6481055cb91SLouis Dionne#endif 649e02ed1c2SEric Fiselier 650e02ed1c2SEric Fiselier static_assert(!__is_stashing_iterator<_Iter>::value, 651e02ed1c2SEric Fiselier "The specified iterator type cannot be used with reverse_iterator; " 652e02ed1c2SEric Fiselier "Using stashing iterators with reverse_iterator causes undefined behavior"); 653e02ed1c2SEric Fiselier 654b2d74f29SMarshall Clowprotected: 655b2d74f29SMarshall Clow _Iter current; 6563e519524SHoward Hinnantpublic: 6573e519524SHoward Hinnant typedef _Iter iterator_type; 6583e519524SHoward Hinnant typedef typename iterator_traits<_Iter>::difference_type difference_type; 6593e519524SHoward Hinnant typedef typename iterator_traits<_Iter>::reference reference; 6603e519524SHoward Hinnant typedef typename iterator_traits<_Iter>::pointer pointer; 661d41c6d51SArthur O'Dwyer typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, 662d41c6d51SArthur O'Dwyer random_access_iterator_tag, 663d41c6d51SArthur O'Dwyer typename iterator_traits<_Iter>::iterator_category> iterator_category; 6641055cb91SLouis Dionne typedef typename iterator_traits<_Iter>::value_type value_type; 6651055cb91SLouis Dionne 666d41c6d51SArthur O'Dwyer#if _LIBCPP_STD_VER > 17 667d41c6d51SArthur O'Dwyer typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, 668d41c6d51SArthur O'Dwyer random_access_iterator_tag, 669d41c6d51SArthur O'Dwyer bidirectional_iterator_tag> iterator_concept; 670d41c6d51SArthur O'Dwyer#endif 6713e519524SHoward Hinnant 6721055cb91SLouis Dionne#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES 6731b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 6741b8f260eSMarshall Clow reverse_iterator() : __t(), current() {} 675e4d3a993SLouis Dionne 6761b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 6771b8f260eSMarshall Clow explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {} 678e4d3a993SLouis Dionne 679e4d3a993SLouis Dionne template <class _Up, class = _EnableIf< 680e4d3a993SLouis Dionne !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value 681e4d3a993SLouis Dionne > > 6821b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 683e4d3a993SLouis Dionne reverse_iterator(const reverse_iterator<_Up>& __u) 684e4d3a993SLouis Dionne : __t(__u.base()), current(__u.base()) 685e4d3a993SLouis Dionne { } 686e4d3a993SLouis Dionne 687e4d3a993SLouis Dionne template <class _Up, class = _EnableIf< 688e4d3a993SLouis Dionne !is_same<_Up, _Iter>::value && 689e4d3a993SLouis Dionne is_convertible<_Up const&, _Iter>::value && 690e4d3a993SLouis Dionne is_assignable<_Up const&, _Iter>::value 691e4d3a993SLouis Dionne > > 6921b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 693e4d3a993SLouis Dionne reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { 694e4d3a993SLouis Dionne __t = current = __u.base(); 695e4d3a993SLouis Dionne return *this; 696e4d3a993SLouis Dionne } 6971055cb91SLouis Dionne#else 6981055cb91SLouis Dionne _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 6991055cb91SLouis Dionne reverse_iterator() : current() {} 700e4d3a993SLouis Dionne 7011055cb91SLouis Dionne _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7021055cb91SLouis Dionne explicit reverse_iterator(_Iter __x) : current(__x) {} 703e4d3a993SLouis Dionne 704e4d3a993SLouis Dionne template <class _Up, class = _EnableIf< 705e4d3a993SLouis Dionne !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value 706e4d3a993SLouis Dionne > > 7071055cb91SLouis Dionne _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 708e4d3a993SLouis Dionne reverse_iterator(const reverse_iterator<_Up>& __u) 709e4d3a993SLouis Dionne : current(__u.base()) 710e4d3a993SLouis Dionne { } 711e4d3a993SLouis Dionne 712e4d3a993SLouis Dionne template <class _Up, class = _EnableIf< 713e4d3a993SLouis Dionne !is_same<_Up, _Iter>::value && 714e4d3a993SLouis Dionne is_convertible<_Up const&, _Iter>::value && 715e4d3a993SLouis Dionne is_assignable<_Up const&, _Iter>::value 716e4d3a993SLouis Dionne > > 7171055cb91SLouis Dionne _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 718e4d3a993SLouis Dionne reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { 719e4d3a993SLouis Dionne current = __u.base(); 720e4d3a993SLouis Dionne return *this; 721e4d3a993SLouis Dionne } 7221055cb91SLouis Dionne#endif 7231b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7241b8f260eSMarshall Clow _Iter base() const {return current;} 7251b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7261b8f260eSMarshall Clow reference operator*() const {_Iter __tmp = current; return *--__tmp;} 7271b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7281b8f260eSMarshall Clow pointer operator->() const {return _VSTD::addressof(operator*());} 7291b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7301b8f260eSMarshall Clow reverse_iterator& operator++() {--current; return *this;} 7311b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7321b8f260eSMarshall Clow reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;} 7331b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7341b8f260eSMarshall Clow reverse_iterator& operator--() {++current; return *this;} 7351b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7361b8f260eSMarshall Clow reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;} 7371b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7381b8f260eSMarshall Clow reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);} 7391b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7401b8f260eSMarshall Clow reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;} 7411b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7421b8f260eSMarshall Clow reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);} 7431b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7441b8f260eSMarshall Clow reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;} 7451b8f260eSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7461b8f260eSMarshall Clow reference operator[](difference_type __n) const {return *(*this + __n);} 7473e519524SHoward Hinnant}; 7483e519524SHoward Hinnant 7493e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 7501b8f260eSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7513e519524SHoward Hinnantbool 7523e519524SHoward Hinnantoperator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7533e519524SHoward Hinnant{ 7543e519524SHoward Hinnant return __x.base() == __y.base(); 7553e519524SHoward Hinnant} 7563e519524SHoward Hinnant 7573e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 7581b8f260eSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7593e519524SHoward Hinnantbool 7603e519524SHoward Hinnantoperator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7613e519524SHoward Hinnant{ 7623e519524SHoward Hinnant return __x.base() > __y.base(); 7633e519524SHoward Hinnant} 7643e519524SHoward Hinnant 7653e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 7661b8f260eSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7673e519524SHoward Hinnantbool 7683e519524SHoward Hinnantoperator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7693e519524SHoward Hinnant{ 7703e519524SHoward Hinnant return __x.base() != __y.base(); 7713e519524SHoward Hinnant} 7723e519524SHoward Hinnant 7733e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 7741b8f260eSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7753e519524SHoward Hinnantbool 7763e519524SHoward Hinnantoperator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7773e519524SHoward Hinnant{ 7783e519524SHoward Hinnant return __x.base() < __y.base(); 7793e519524SHoward Hinnant} 7803e519524SHoward Hinnant 7813e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 7821b8f260eSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7833e519524SHoward Hinnantbool 7843e519524SHoward Hinnantoperator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7853e519524SHoward Hinnant{ 7863e519524SHoward Hinnant return __x.base() <= __y.base(); 7873e519524SHoward Hinnant} 7883e519524SHoward Hinnant 7893e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 7901b8f260eSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7913e519524SHoward Hinnantbool 7923e519524SHoward Hinnantoperator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7933e519524SHoward Hinnant{ 7943e519524SHoward Hinnant return __x.base() >= __y.base(); 7953e519524SHoward Hinnant} 7963e519524SHoward Hinnant 7972ee83725SMarshall Clow#ifndef _LIBCPP_CXX03_LANG 798947ce6b5SMarshall Clowtemplate <class _Iter1, class _Iter2> 7991b8f260eSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 800947ce6b5SMarshall Clowauto 801947ce6b5SMarshall Clowoperator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 802947ce6b5SMarshall Clow-> decltype(__y.base() - __x.base()) 803947ce6b5SMarshall Clow{ 804947ce6b5SMarshall Clow return __y.base() - __x.base(); 805947ce6b5SMarshall Clow} 806947ce6b5SMarshall Clow#else 8073e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 8083e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 8093e519524SHoward Hinnanttypename reverse_iterator<_Iter1>::difference_type 8103e519524SHoward Hinnantoperator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 8113e519524SHoward Hinnant{ 8123e519524SHoward Hinnant return __y.base() - __x.base(); 8133e519524SHoward Hinnant} 814947ce6b5SMarshall Clow#endif 8153e519524SHoward Hinnant 8163e519524SHoward Hinnanttemplate <class _Iter> 8171b8f260eSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 8183e519524SHoward Hinnantreverse_iterator<_Iter> 8193e519524SHoward Hinnantoperator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x) 8203e519524SHoward Hinnant{ 8213e519524SHoward Hinnant return reverse_iterator<_Iter>(__x.base() - __n); 8223e519524SHoward Hinnant} 8233e519524SHoward Hinnant 8246a640a18SMarshall Clow#if _LIBCPP_STD_VER > 11 8256a640a18SMarshall Clowtemplate <class _Iter> 8261b8f260eSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 8276a640a18SMarshall Clowreverse_iterator<_Iter> make_reverse_iterator(_Iter __i) 8286a640a18SMarshall Clow{ 8296a640a18SMarshall Clow return reverse_iterator<_Iter>(__i); 8306a640a18SMarshall Clow} 8316a640a18SMarshall Clow#endif 8326a640a18SMarshall Clow 8331055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_PUSH 8343e519524SHoward Hinnanttemplate <class _Container> 835e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS back_insert_iterator 8361055cb91SLouis Dionne#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) 8371055cb91SLouis Dionne : public iterator<output_iterator_tag, void, void, void, void> 8381055cb91SLouis Dionne#endif 8393e519524SHoward Hinnant{ 8401055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_POP 8413e519524SHoward Hinnantprotected: 8423e519524SHoward Hinnant _Container* container; 8433e519524SHoward Hinnantpublic: 8441055cb91SLouis Dionne typedef output_iterator_tag iterator_category; 8451055cb91SLouis Dionne typedef void value_type; 84641bdf64dSLouis Dionne#if _LIBCPP_STD_VER > 17 84741bdf64dSLouis Dionne typedef ptrdiff_t difference_type; 84841bdf64dSLouis Dionne#else 8491055cb91SLouis Dionne typedef void difference_type; 85041bdf64dSLouis Dionne#endif 8511055cb91SLouis Dionne typedef void pointer; 8521055cb91SLouis Dionne typedef void reference; 8533e519524SHoward Hinnant typedef _Container container_type; 8543e519524SHoward Hinnant 85506e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} 85606e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_) 857e4383379SHoward Hinnant {container->push_back(__value_); return *this;} 858046492b9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 85906e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_) 860e4383379SHoward Hinnant {container->push_back(_VSTD::move(__value_)); return *this;} 861046492b9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 86206e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;} 86306e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;} 86406e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;} 8653e519524SHoward Hinnant}; 8663e519524SHoward Hinnant 8673e519524SHoward Hinnanttemplate <class _Container> 86806e2b737SArthur O'Dwyerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 8693e519524SHoward Hinnantback_insert_iterator<_Container> 8703e519524SHoward Hinnantback_inserter(_Container& __x) 8713e519524SHoward Hinnant{ 8723e519524SHoward Hinnant return back_insert_iterator<_Container>(__x); 8733e519524SHoward Hinnant} 8743e519524SHoward Hinnant 8751055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_PUSH 8763e519524SHoward Hinnanttemplate <class _Container> 877e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS front_insert_iterator 8781055cb91SLouis Dionne#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) 8791055cb91SLouis Dionne : public iterator<output_iterator_tag, void, void, void, void> 8801055cb91SLouis Dionne#endif 8813e519524SHoward Hinnant{ 8821055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_POP 8833e519524SHoward Hinnantprotected: 8843e519524SHoward Hinnant _Container* container; 8853e519524SHoward Hinnantpublic: 8861055cb91SLouis Dionne typedef output_iterator_tag iterator_category; 8871055cb91SLouis Dionne typedef void value_type; 88841bdf64dSLouis Dionne#if _LIBCPP_STD_VER > 17 88941bdf64dSLouis Dionne typedef ptrdiff_t difference_type; 89041bdf64dSLouis Dionne#else 8911055cb91SLouis Dionne typedef void difference_type; 89241bdf64dSLouis Dionne#endif 8931055cb91SLouis Dionne typedef void pointer; 8941055cb91SLouis Dionne typedef void reference; 8953e519524SHoward Hinnant typedef _Container container_type; 8963e519524SHoward Hinnant 89706e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} 89806e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value_) 899e4383379SHoward Hinnant {container->push_front(__value_); return *this;} 900046492b9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 90106e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value_) 902e4383379SHoward Hinnant {container->push_front(_VSTD::move(__value_)); return *this;} 903046492b9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 90406e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;} 90506e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;} 90606e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator operator++(int) {return *this;} 9073e519524SHoward Hinnant}; 9083e519524SHoward Hinnant 9093e519524SHoward Hinnanttemplate <class _Container> 91006e2b737SArthur O'Dwyerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 9113e519524SHoward Hinnantfront_insert_iterator<_Container> 9123e519524SHoward Hinnantfront_inserter(_Container& __x) 9133e519524SHoward Hinnant{ 9143e519524SHoward Hinnant return front_insert_iterator<_Container>(__x); 9153e519524SHoward Hinnant} 9163e519524SHoward Hinnant 9171055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_PUSH 9183e519524SHoward Hinnanttemplate <class _Container> 919e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS insert_iterator 9201055cb91SLouis Dionne#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) 9211055cb91SLouis Dionne : public iterator<output_iterator_tag, void, void, void, void> 9221055cb91SLouis Dionne#endif 9233e519524SHoward Hinnant{ 9241055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_POP 9253e519524SHoward Hinnantprotected: 9263e519524SHoward Hinnant _Container* container; 927462f8f06SChristopher Di Bella typename _Container::iterator iter; // FIXME: `ranges::iterator_t<Container>` in C++20 mode 9283e519524SHoward Hinnantpublic: 9291055cb91SLouis Dionne typedef output_iterator_tag iterator_category; 9301055cb91SLouis Dionne typedef void value_type; 93141bdf64dSLouis Dionne#if _LIBCPP_STD_VER > 17 93241bdf64dSLouis Dionne typedef ptrdiff_t difference_type; 93341bdf64dSLouis Dionne#else 9341055cb91SLouis Dionne typedef void difference_type; 93541bdf64dSLouis Dionne#endif 9361055cb91SLouis Dionne typedef void pointer; 9371055cb91SLouis Dionne typedef void reference; 9383e519524SHoward Hinnant typedef _Container container_type; 9393e519524SHoward Hinnant 94006e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, typename _Container::iterator __i) 941f519be34SMarshall Clow : container(_VSTD::addressof(__x)), iter(__i) {} 94206e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_) 943e4383379SHoward Hinnant {iter = container->insert(iter, __value_); ++iter; return *this;} 944046492b9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 94506e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value_) 946e4383379SHoward Hinnant {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;} 947046492b9SEric Fiselier#endif // _LIBCPP_CXX03_LANG 94806e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;} 94906e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;} 95006e2b737SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++(int) {return *this;} 9513e519524SHoward Hinnant}; 9523e519524SHoward Hinnant 9533e519524SHoward Hinnanttemplate <class _Container> 95406e2b737SArthur O'Dwyerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 9553e519524SHoward Hinnantinsert_iterator<_Container> 9563e519524SHoward Hinnantinserter(_Container& __x, typename _Container::iterator __i) 9573e519524SHoward Hinnant{ 9583e519524SHoward Hinnant return insert_iterator<_Container>(__x, __i); 9593e519524SHoward Hinnant} 9603e519524SHoward Hinnant 9611055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_PUSH 9623e519524SHoward Hinnanttemplate <class _Tp, class _CharT = char, 9633e519524SHoward Hinnant class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t> 964e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS istream_iterator 9651055cb91SLouis Dionne#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) 9663e519524SHoward Hinnant : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&> 9671055cb91SLouis Dionne#endif 9683e519524SHoward Hinnant{ 9691055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_POP 9703e519524SHoward Hinnantpublic: 9711055cb91SLouis Dionne typedef input_iterator_tag iterator_category; 9721055cb91SLouis Dionne typedef _Tp value_type; 9731055cb91SLouis Dionne typedef _Distance difference_type; 9741055cb91SLouis Dionne typedef const _Tp* pointer; 9751055cb91SLouis Dionne typedef const _Tp& reference; 9763e519524SHoward Hinnant typedef _CharT char_type; 9773e519524SHoward Hinnant typedef _Traits traits_type; 9783e519524SHoward Hinnant typedef basic_istream<_CharT,_Traits> istream_type; 9793e519524SHoward Hinnantprivate: 9803e519524SHoward Hinnant istream_type* __in_stream_; 9813e519524SHoward Hinnant _Tp __value_; 9823e519524SHoward Hinnantpublic: 983527a7fdfSBruce Mitchener _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {} 984bc6a7df0SMarshall Clow _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s)) 9853e519524SHoward Hinnant { 9863e519524SHoward Hinnant if (!(*__in_stream_ >> __value_)) 987527a7fdfSBruce Mitchener __in_stream_ = nullptr; 9883e519524SHoward Hinnant } 9893e519524SHoward Hinnant 9903e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;} 991bc6a7df0SMarshall Clow _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return _VSTD::addressof((operator*()));} 9923e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++() 9933e519524SHoward Hinnant { 9943e519524SHoward Hinnant if (!(*__in_stream_ >> __value_)) 995527a7fdfSBruce Mitchener __in_stream_ = nullptr; 9963e519524SHoward Hinnant return *this; 9973e519524SHoward Hinnant } 9983e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int) 9993e519524SHoward Hinnant {istream_iterator __t(*this); ++(*this); return __t;} 10003e519524SHoward Hinnant 10016f56d3eeSRoger Ferrer Ibanez template <class _Up, class _CharU, class _TraitsU, class _DistanceU> 10023e519524SHoward Hinnant friend _LIBCPP_INLINE_VISIBILITY 10036f56d3eeSRoger Ferrer Ibanez bool 10046f56d3eeSRoger Ferrer Ibanez operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, 10056f56d3eeSRoger Ferrer Ibanez const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); 10063e519524SHoward Hinnant 10076f56d3eeSRoger Ferrer Ibanez template <class _Up, class _CharU, class _TraitsU, class _DistanceU> 10083e519524SHoward Hinnant friend _LIBCPP_INLINE_VISIBILITY 10096f56d3eeSRoger Ferrer Ibanez bool 10106f56d3eeSRoger Ferrer Ibanez operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, 10116f56d3eeSRoger Ferrer Ibanez const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); 10123e519524SHoward Hinnant}; 10133e519524SHoward Hinnant 10146f56d3eeSRoger Ferrer Ibaneztemplate <class _Tp, class _CharT, class _Traits, class _Distance> 10156f56d3eeSRoger Ferrer Ibanezinline _LIBCPP_INLINE_VISIBILITY 10166f56d3eeSRoger Ferrer Ibanezbool 10176f56d3eeSRoger Ferrer Ibanezoperator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, 10186f56d3eeSRoger Ferrer Ibanez const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) 10196f56d3eeSRoger Ferrer Ibanez{ 10206f56d3eeSRoger Ferrer Ibanez return __x.__in_stream_ == __y.__in_stream_; 10216f56d3eeSRoger Ferrer Ibanez} 10226f56d3eeSRoger Ferrer Ibanez 10236f56d3eeSRoger Ferrer Ibaneztemplate <class _Tp, class _CharT, class _Traits, class _Distance> 10246f56d3eeSRoger Ferrer Ibanezinline _LIBCPP_INLINE_VISIBILITY 10256f56d3eeSRoger Ferrer Ibanezbool 10266f56d3eeSRoger Ferrer Ibanezoperator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, 10276f56d3eeSRoger Ferrer Ibanez const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) 10286f56d3eeSRoger Ferrer Ibanez{ 10296f56d3eeSRoger Ferrer Ibanez return !(__x == __y); 10306f56d3eeSRoger Ferrer Ibanez} 10316f56d3eeSRoger Ferrer Ibanez 10321055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_PUSH 10333e519524SHoward Hinnanttemplate <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> > 1034e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS ostream_iterator 10351055cb91SLouis Dionne#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) 10363e519524SHoward Hinnant : public iterator<output_iterator_tag, void, void, void, void> 10371055cb91SLouis Dionne#endif 10383e519524SHoward Hinnant{ 10391055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_POP 10403e519524SHoward Hinnantpublic: 104171a16e40SLouis Dionne typedef output_iterator_tag iterator_category; 104271a16e40SLouis Dionne typedef void value_type; 104371a16e40SLouis Dionne#if _LIBCPP_STD_VER > 17 104441bdf64dSLouis Dionne typedef ptrdiff_t difference_type; 104571a16e40SLouis Dionne#else 104671a16e40SLouis Dionne typedef void difference_type; 104771a16e40SLouis Dionne#endif 104871a16e40SLouis Dionne typedef void pointer; 104971a16e40SLouis Dionne typedef void reference; 10503e519524SHoward Hinnant typedef _CharT char_type; 10513e519524SHoward Hinnant typedef _Traits traits_type; 10523e519524SHoward Hinnant typedef basic_ostream<_CharT, _Traits> ostream_type; 105371a16e40SLouis Dionne 10543e519524SHoward Hinnantprivate: 10553e519524SHoward Hinnant ostream_type* __out_stream_; 10563e519524SHoward Hinnant const char_type* __delim_; 10573e519524SHoward Hinnantpublic: 1058853042cfSMarshall Clow _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT 1059527a7fdfSBruce Mitchener : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {} 1060853042cfSMarshall Clow _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT 1061bc6a7df0SMarshall Clow : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {} 1062e4383379SHoward Hinnant _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_) 10633e519524SHoward Hinnant { 1064e4383379SHoward Hinnant *__out_stream_ << __value_; 10653e519524SHoward Hinnant if (__delim_) 10663e519524SHoward Hinnant *__out_stream_ << __delim_; 10673e519524SHoward Hinnant return *this; 10683e519524SHoward Hinnant } 10693e519524SHoward Hinnant 10703e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*() {return *this;} 10713e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++() {return *this;} 10723e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;} 10733e519524SHoward Hinnant}; 10743e519524SHoward Hinnant 10751055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_PUSH 10763e519524SHoward Hinnanttemplate<class _CharT, class _Traits> 1077e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS istreambuf_iterator 10781055cb91SLouis Dionne#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) 10793e519524SHoward Hinnant : public iterator<input_iterator_tag, _CharT, 10803e519524SHoward Hinnant typename _Traits::off_type, _CharT*, 10813e519524SHoward Hinnant _CharT> 10821055cb91SLouis Dionne#endif 10833e519524SHoward Hinnant{ 10841055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_POP 10853e519524SHoward Hinnantpublic: 10861055cb91SLouis Dionne typedef input_iterator_tag iterator_category; 10871055cb91SLouis Dionne typedef _CharT value_type; 10881055cb91SLouis Dionne typedef typename _Traits::off_type difference_type; 10891055cb91SLouis Dionne typedef _CharT* pointer; 10901055cb91SLouis Dionne typedef _CharT reference; 10913e519524SHoward Hinnant typedef _CharT char_type; 10923e519524SHoward Hinnant typedef _Traits traits_type; 10933e519524SHoward Hinnant typedef typename _Traits::int_type int_type; 10943e519524SHoward Hinnant typedef basic_streambuf<_CharT,_Traits> streambuf_type; 10953e519524SHoward Hinnant typedef basic_istream<_CharT,_Traits> istream_type; 10963e519524SHoward Hinnantprivate: 1097dfdf5085SHoward Hinnant mutable streambuf_type* __sbuf_; 10983e519524SHoward Hinnant 10993e519524SHoward Hinnant class __proxy 11003e519524SHoward Hinnant { 11013e519524SHoward Hinnant char_type __keep_; 11023e519524SHoward Hinnant streambuf_type* __sbuf_; 11033e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s) 11043e519524SHoward Hinnant : __keep_(__c), __sbuf_(__s) {} 11053e519524SHoward Hinnant friend class istreambuf_iterator; 11063e519524SHoward Hinnant public: 11073e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY char_type operator*() const {return __keep_;} 11083e519524SHoward Hinnant }; 11093e519524SHoward Hinnant 1110848a5374SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1111dfdf5085SHoward Hinnant bool __test_for_eof() const 11123e519524SHoward Hinnant { 11133e519524SHoward Hinnant if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof())) 1114527a7fdfSBruce Mitchener __sbuf_ = nullptr; 1115527a7fdfSBruce Mitchener return __sbuf_ == nullptr; 11163e519524SHoward Hinnant } 11173e519524SHoward Hinnantpublic: 1118527a7fdfSBruce Mitchener _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {} 11198e882dcbSHoward Hinnant _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT 1120a96d7458SHoward Hinnant : __sbuf_(__s.rdbuf()) {} 11218e882dcbSHoward Hinnant _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT 1122a96d7458SHoward Hinnant : __sbuf_(__s) {} 11238e882dcbSHoward Hinnant _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT 11243e519524SHoward Hinnant : __sbuf_(__p.__sbuf_) {} 11253e519524SHoward Hinnant 1126c206366fSHoward Hinnant _LIBCPP_INLINE_VISIBILITY char_type operator*() const 1127c206366fSHoward Hinnant {return static_cast<char_type>(__sbuf_->sgetc());} 11283e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++() 11293e519524SHoward Hinnant { 1130dfdf5085SHoward Hinnant __sbuf_->sbumpc(); 11313e519524SHoward Hinnant return *this; 11323e519524SHoward Hinnant } 11333e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY __proxy operator++(int) 11343e519524SHoward Hinnant { 1135dfdf5085SHoward Hinnant return __proxy(__sbuf_->sbumpc(), __sbuf_); 11363e519524SHoward Hinnant } 11373e519524SHoward Hinnant 11383e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const 1139dfdf5085SHoward Hinnant {return __test_for_eof() == __b.__test_for_eof();} 11403e519524SHoward Hinnant}; 11413e519524SHoward Hinnant 11423e519524SHoward Hinnanttemplate <class _CharT, class _Traits> 11433e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 11443e519524SHoward Hinnantbool operator==(const istreambuf_iterator<_CharT,_Traits>& __a, 11453e519524SHoward Hinnant const istreambuf_iterator<_CharT,_Traits>& __b) 11463e519524SHoward Hinnant {return __a.equal(__b);} 11473e519524SHoward Hinnant 11483e519524SHoward Hinnanttemplate <class _CharT, class _Traits> 11493e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 11503e519524SHoward Hinnantbool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, 11513e519524SHoward Hinnant const istreambuf_iterator<_CharT,_Traits>& __b) 11523e519524SHoward Hinnant {return !__a.equal(__b);} 11533e519524SHoward Hinnant 11541055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_PUSH 11553e519524SHoward Hinnanttemplate <class _CharT, class _Traits> 1156e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS ostreambuf_iterator 11571055cb91SLouis Dionne#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) 11583e519524SHoward Hinnant : public iterator<output_iterator_tag, void, void, void, void> 11591055cb91SLouis Dionne#endif 11603e519524SHoward Hinnant{ 11611055cb91SLouis Dionne_LIBCPP_SUPPRESS_DEPRECATED_POP 11623e519524SHoward Hinnantpublic: 116371a16e40SLouis Dionne typedef output_iterator_tag iterator_category; 116471a16e40SLouis Dionne typedef void value_type; 116571a16e40SLouis Dionne#if _LIBCPP_STD_VER > 17 116641bdf64dSLouis Dionne typedef ptrdiff_t difference_type; 116771a16e40SLouis Dionne#else 116871a16e40SLouis Dionne typedef void difference_type; 116971a16e40SLouis Dionne#endif 117071a16e40SLouis Dionne typedef void pointer; 117171a16e40SLouis Dionne typedef void reference; 11723e519524SHoward Hinnant typedef _CharT char_type; 11733e519524SHoward Hinnant typedef _Traits traits_type; 11743e519524SHoward Hinnant typedef basic_streambuf<_CharT, _Traits> streambuf_type; 11753e519524SHoward Hinnant typedef basic_ostream<_CharT, _Traits> ostream_type; 117671a16e40SLouis Dionne 11773e519524SHoward Hinnantprivate: 11783e519524SHoward Hinnant streambuf_type* __sbuf_; 11793e519524SHoward Hinnantpublic: 11808e882dcbSHoward Hinnant _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT 11813e519524SHoward Hinnant : __sbuf_(__s.rdbuf()) {} 11828e882dcbSHoward Hinnant _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT 11833e519524SHoward Hinnant : __sbuf_(__s) {} 11843e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c) 11853e519524SHoward Hinnant { 11863e519524SHoward Hinnant if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof())) 1187527a7fdfSBruce Mitchener __sbuf_ = nullptr; 11883e519524SHoward Hinnant return *this; 11893e519524SHoward Hinnant } 11903e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;} 11913e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;} 11923e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;} 1193527a7fdfSBruce Mitchener _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == nullptr;} 119492b5940fSHoward Hinnant 119592b5940fSHoward Hinnant template <class _Ch, class _Tr> 119692b5940fSHoward Hinnant friend 119792b5940fSHoward Hinnant _LIBCPP_HIDDEN 119892b5940fSHoward Hinnant ostreambuf_iterator<_Ch, _Tr> 119992b5940fSHoward Hinnant __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s, 120092b5940fSHoward Hinnant const _Ch* __ob, const _Ch* __op, const _Ch* __oe, 120192b5940fSHoward Hinnant ios_base& __iob, _Ch __fl); 12023e519524SHoward Hinnant}; 12033e519524SHoward Hinnant 12043e519524SHoward Hinnanttemplate <class _Iter> 1205e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS move_iterator 12063e519524SHoward Hinnant{ 12073e519524SHoward Hinnantprivate: 12083e519524SHoward Hinnant _Iter __i; 12093e519524SHoward Hinnantpublic: 12103e519524SHoward Hinnant typedef _Iter iterator_type; 12113e519524SHoward Hinnant typedef typename iterator_traits<iterator_type>::value_type value_type; 12123e519524SHoward Hinnant typedef typename iterator_traits<iterator_type>::difference_type difference_type; 121305333fc8SMarshall Clow typedef iterator_type pointer; 1214d41c6d51SArthur O'Dwyer typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, 1215d41c6d51SArthur O'Dwyer random_access_iterator_tag, 1216d41c6d51SArthur O'Dwyer typename iterator_traits<_Iter>::iterator_category> iterator_category; 1217d41c6d51SArthur O'Dwyer#if _LIBCPP_STD_VER > 17 1218d41c6d51SArthur O'Dwyer typedef input_iterator_tag iterator_concept; 1219d41c6d51SArthur O'Dwyer#endif 1220d41c6d51SArthur O'Dwyer 1221046492b9SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 1222906c5085SEric Fiselier typedef typename iterator_traits<iterator_type>::reference __reference; 1223906c5085SEric Fiselier typedef typename conditional< 1224906c5085SEric Fiselier is_reference<__reference>::value, 1225906c5085SEric Fiselier typename remove_reference<__reference>::type&&, 1226906c5085SEric Fiselier __reference 1227906c5085SEric Fiselier >::type reference; 12283e519524SHoward Hinnant#else 12293e519524SHoward Hinnant typedef typename iterator_traits<iterator_type>::reference reference; 12303e519524SHoward Hinnant#endif 12313e519524SHoward Hinnant 1232720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1233720ef472SMarshall Clow move_iterator() : __i() {} 1234e4d3a993SLouis Dionne 1235720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1236720ef472SMarshall Clow explicit move_iterator(_Iter __x) : __i(__x) {} 1237e4d3a993SLouis Dionne 1238e4d3a993SLouis Dionne template <class _Up, class = _EnableIf< 1239e4d3a993SLouis Dionne !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value 1240e4d3a993SLouis Dionne > > 1241720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1242720ef472SMarshall Clow move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {} 1243e4d3a993SLouis Dionne 1244e4d3a993SLouis Dionne template <class _Up, class = _EnableIf< 1245e4d3a993SLouis Dionne !is_same<_Up, _Iter>::value && 1246e4d3a993SLouis Dionne is_convertible<_Up const&, _Iter>::value && 1247e4d3a993SLouis Dionne is_assignable<_Iter&, _Up const&>::value 1248e4d3a993SLouis Dionne > > 1249e4d3a993SLouis Dionne _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1250e4d3a993SLouis Dionne move_iterator& operator=(const move_iterator<_Up>& __u) { 1251e4d3a993SLouis Dionne __i = __u.base(); 1252e4d3a993SLouis Dionne return *this; 1253e4d3a993SLouis Dionne } 1254e4d3a993SLouis Dionne 1255720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;} 1256720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1257720ef472SMarshall Clow reference operator*() const { return static_cast<reference>(*__i); } 1258720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1259720ef472SMarshall Clow pointer operator->() const { return __i;} 1260720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1261720ef472SMarshall Clow move_iterator& operator++() {++__i; return *this;} 1262720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1263720ef472SMarshall Clow move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;} 1264720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1265720ef472SMarshall Clow move_iterator& operator--() {--__i; return *this;} 1266720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1267720ef472SMarshall Clow move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;} 1268720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1269720ef472SMarshall Clow move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);} 1270720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1271720ef472SMarshall Clow move_iterator& operator+=(difference_type __n) {__i += __n; return *this;} 1272720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1273720ef472SMarshall Clow move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);} 1274720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1275720ef472SMarshall Clow move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;} 1276720ef472SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1277720ef472SMarshall Clow reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); } 12783e519524SHoward Hinnant}; 12793e519524SHoward Hinnant 12803e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 1281720ef472SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 12823e519524SHoward Hinnantbool 12833e519524SHoward Hinnantoperator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 12843e519524SHoward Hinnant{ 12853e519524SHoward Hinnant return __x.base() == __y.base(); 12863e519524SHoward Hinnant} 12873e519524SHoward Hinnant 12883e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 1289720ef472SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 12903e519524SHoward Hinnantbool 12913e519524SHoward Hinnantoperator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 12923e519524SHoward Hinnant{ 12933e519524SHoward Hinnant return __x.base() < __y.base(); 12943e519524SHoward Hinnant} 12953e519524SHoward Hinnant 12963e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 1297720ef472SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 12983e519524SHoward Hinnantbool 12993e519524SHoward Hinnantoperator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 13003e519524SHoward Hinnant{ 13013e519524SHoward Hinnant return __x.base() != __y.base(); 13023e519524SHoward Hinnant} 13033e519524SHoward Hinnant 13043e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 1305720ef472SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 13063e519524SHoward Hinnantbool 13073e519524SHoward Hinnantoperator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 13083e519524SHoward Hinnant{ 13093e519524SHoward Hinnant return __x.base() > __y.base(); 13103e519524SHoward Hinnant} 13113e519524SHoward Hinnant 13123e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 1313720ef472SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 13143e519524SHoward Hinnantbool 13153e519524SHoward Hinnantoperator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 13163e519524SHoward Hinnant{ 13173e519524SHoward Hinnant return __x.base() >= __y.base(); 13183e519524SHoward Hinnant} 13193e519524SHoward Hinnant 13203e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 1321720ef472SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 13223e519524SHoward Hinnantbool 13233e519524SHoward Hinnantoperator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 13243e519524SHoward Hinnant{ 13253e519524SHoward Hinnant return __x.base() <= __y.base(); 13263e519524SHoward Hinnant} 13273e519524SHoward Hinnant 13282ee83725SMarshall Clow#ifndef _LIBCPP_CXX03_LANG 1329947ce6b5SMarshall Clowtemplate <class _Iter1, class _Iter2> 1330720ef472SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1331947ce6b5SMarshall Clowauto 1332947ce6b5SMarshall Clowoperator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 1333947ce6b5SMarshall Clow-> decltype(__x.base() - __y.base()) 1334947ce6b5SMarshall Clow{ 1335947ce6b5SMarshall Clow return __x.base() - __y.base(); 1336947ce6b5SMarshall Clow} 1337947ce6b5SMarshall Clow#else 13383e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 13393e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 13403e519524SHoward Hinnanttypename move_iterator<_Iter1>::difference_type 13413e519524SHoward Hinnantoperator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 13423e519524SHoward Hinnant{ 13433e519524SHoward Hinnant return __x.base() - __y.base(); 13443e519524SHoward Hinnant} 1345947ce6b5SMarshall Clow#endif 13463e519524SHoward Hinnant 13473e519524SHoward Hinnanttemplate <class _Iter> 1348720ef472SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 13493e519524SHoward Hinnantmove_iterator<_Iter> 13503e519524SHoward Hinnantoperator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) 13513e519524SHoward Hinnant{ 13523e519524SHoward Hinnant return move_iterator<_Iter>(__x.base() + __n); 13533e519524SHoward Hinnant} 13543e519524SHoward Hinnant 13553e519524SHoward Hinnanttemplate <class _Iter> 1356720ef472SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 13573e519524SHoward Hinnantmove_iterator<_Iter> 135854c83368SMarshall Clowmake_move_iterator(_Iter __i) 13593e519524SHoward Hinnant{ 13603e519524SHoward Hinnant return move_iterator<_Iter>(__i); 13613e519524SHoward Hinnant} 13623e519524SHoward Hinnant 13633e519524SHoward Hinnant// __wrap_iter 13643e519524SHoward Hinnant 13653e519524SHoward Hinnanttemplate <class _Iter> class __wrap_iter; 13663e519524SHoward Hinnant 13673e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 13689cad5025SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 13693e519524SHoward Hinnantbool 137061b302f9SEric Fiselieroperator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 13713e519524SHoward Hinnant 13723e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 13739cad5025SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 13743e519524SHoward Hinnantbool 137561b302f9SEric Fiselieroperator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 13763e519524SHoward Hinnant 13773e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 13789cad5025SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 13793e519524SHoward Hinnantbool 138061b302f9SEric Fiselieroperator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 13813e519524SHoward Hinnant 13823e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 13839cad5025SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 13843e519524SHoward Hinnantbool 138561b302f9SEric Fiselieroperator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 13863e519524SHoward Hinnant 13873e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 13889cad5025SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 13893e519524SHoward Hinnantbool 139061b302f9SEric Fiselieroperator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 13913e519524SHoward Hinnant 13923e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 13939cad5025SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 13943e519524SHoward Hinnantbool 139561b302f9SEric Fiselieroperator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 13963e519524SHoward Hinnant 13972ee83725SMarshall Clow#ifndef _LIBCPP_CXX03_LANG 1398947ce6b5SMarshall Clowtemplate <class _Iter1, class _Iter2> 13999cad5025SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1400947ce6b5SMarshall Clowauto 140161b302f9SEric Fiselieroperator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT 1402947ce6b5SMarshall Clow-> decltype(__x.base() - __y.base()); 1403947ce6b5SMarshall Clow#else 14043e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 1405aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 14063e519524SHoward Hinnanttypename __wrap_iter<_Iter1>::difference_type 140761b302f9SEric Fiselieroperator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 1408947ce6b5SMarshall Clow#endif 14093e519524SHoward Hinnant 14103e519524SHoward Hinnanttemplate <class _Iter> 14119cad5025SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 14123e519524SHoward Hinnant__wrap_iter<_Iter> 141361b302f9SEric Fiselieroperator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT; 14143e519524SHoward Hinnant 141513c90a57SLouis Dionnetemplate <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy(_Ip, _Ip, _Op); 141613c90a57SLouis Dionnetemplate <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy_backward(_B1, _B1, _B2); 14173ed89b51Szoecarvertemplate <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 move(_Ip, _Ip, _Op); 14183ed89b51Szoecarvertemplate <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 move_backward(_B1, _B1, _B2); 14193e519524SHoward Hinnant 14203e519524SHoward Hinnanttemplate <class _Iter> 14213e519524SHoward Hinnantclass __wrap_iter 14223e519524SHoward Hinnant{ 14233e519524SHoward Hinnantpublic: 14243e519524SHoward Hinnant typedef _Iter iterator_type; 14253e519524SHoward Hinnant typedef typename iterator_traits<iterator_type>::value_type value_type; 14263e519524SHoward Hinnant typedef typename iterator_traits<iterator_type>::difference_type difference_type; 14273e519524SHoward Hinnant typedef typename iterator_traits<iterator_type>::pointer pointer; 14283e519524SHoward Hinnant typedef typename iterator_traits<iterator_type>::reference reference; 1429d41c6d51SArthur O'Dwyer typedef typename iterator_traits<iterator_type>::iterator_category iterator_category; 1430d41c6d51SArthur O'Dwyer#if _LIBCPP_STD_VER > 17 1431fc924887SArthur O'Dwyer typedef contiguous_iterator_tag iterator_concept; 1432d41c6d51SArthur O'Dwyer#endif 1433d41c6d51SArthur O'Dwyer 14343e519524SHoward Hinnantprivate: 14353e519524SHoward Hinnant iterator_type __i; 14363e519524SHoward Hinnantpublic: 143761b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT 143807186a7dSMarshall Clow#if _LIBCPP_STD_VER > 11 143907186a7dSMarshall Clow : __i{} 144007186a7dSMarshall Clow#endif 1441c36bfc49SHoward Hinnant { 144231e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1443c36bfc49SHoward Hinnant __get_db()->__insert_i(this); 1444c36bfc49SHoward Hinnant#endif 1445c36bfc49SHoward Hinnant } 14469cad5025SMarshall Clow template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 14479cad5025SMarshall Clow __wrap_iter(const __wrap_iter<_Up>& __u, 1448527a7fdfSBruce Mitchener typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT 1449f554add5SHoward Hinnant : __i(__u.base()) 1450f554add5SHoward Hinnant { 145131e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1452f554add5SHoward Hinnant __get_db()->__iterator_copy(this, &__u); 1453f554add5SHoward Hinnant#endif 1454f554add5SHoward Hinnant } 145531e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 14569cad5025SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1457f554add5SHoward Hinnant __wrap_iter(const __wrap_iter& __x) 1458f554add5SHoward Hinnant : __i(__x.base()) 1459f554add5SHoward Hinnant { 1460f554add5SHoward Hinnant __get_db()->__iterator_copy(this, &__x); 1461f554add5SHoward Hinnant } 14629cad5025SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1463f554add5SHoward Hinnant __wrap_iter& operator=(const __wrap_iter& __x) 1464f554add5SHoward Hinnant { 1465f554add5SHoward Hinnant if (this != &__x) 1466f554add5SHoward Hinnant { 1467f554add5SHoward Hinnant __get_db()->__iterator_copy(this, &__x); 1468f554add5SHoward Hinnant __i = __x.__i; 1469f554add5SHoward Hinnant } 1470f554add5SHoward Hinnant return *this; 1471f554add5SHoward Hinnant } 14729cad5025SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1473f554add5SHoward Hinnant ~__wrap_iter() 1474f554add5SHoward Hinnant { 1475f554add5SHoward Hinnant __get_db()->__erase_i(this); 1476f554add5SHoward Hinnant } 1477f554add5SHoward Hinnant#endif 147861b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT 1479f554add5SHoward Hinnant { 148031e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1481f554add5SHoward Hinnant _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), 1482f554add5SHoward Hinnant "Attempted to dereference a non-dereferenceable iterator"); 1483cec9af9eSHoward Hinnant#endif 1484f554add5SHoward Hinnant return *__i; 1485f554add5SHoward Hinnant } 148661b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT 14873ec1f00bSHoward Hinnant { 148831e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 14893ec1f00bSHoward Hinnant _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), 14903ec1f00bSHoward Hinnant "Attempted to dereference a non-dereferenceable iterator"); 14913ec1f00bSHoward Hinnant#endif 1492fe0e86e6SLouis Dionne return _VSTD::__to_address(__i); 14933ec1f00bSHoward Hinnant } 149461b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT 1495f554add5SHoward Hinnant { 149631e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1497f554add5SHoward Hinnant _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), 149896100f15SKristina Bessonova "Attempted to increment a non-incrementable iterator"); 1499cec9af9eSHoward Hinnant#endif 1500f554add5SHoward Hinnant ++__i; 1501f554add5SHoward Hinnant return *this; 1502f554add5SHoward Hinnant } 150361b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT 1504f554add5SHoward Hinnant {__wrap_iter __tmp(*this); ++(*this); return __tmp;} 15054ce0a916SMarshall Clow 150661b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT 1507f554add5SHoward Hinnant { 150831e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1509f554add5SHoward Hinnant _LIBCPP_ASSERT(__get_const_db()->__decrementable(this), 151096100f15SKristina Bessonova "Attempted to decrement a non-decrementable iterator"); 1511cec9af9eSHoward Hinnant#endif 1512f554add5SHoward Hinnant --__i; 1513f554add5SHoward Hinnant return *this; 1514f554add5SHoward Hinnant } 151561b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT 1516f554add5SHoward Hinnant {__wrap_iter __tmp(*this); --(*this); return __tmp;} 151761b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT 1518f554add5SHoward Hinnant {__wrap_iter __w(*this); __w += __n; return __w;} 151961b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT 1520f554add5SHoward Hinnant { 152131e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1522f554add5SHoward Hinnant _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n), 152396100f15SKristina Bessonova "Attempted to add/subtract an iterator outside its valid range"); 1524cec9af9eSHoward Hinnant#endif 1525f554add5SHoward Hinnant __i += __n; 1526f554add5SHoward Hinnant return *this; 1527f554add5SHoward Hinnant } 152861b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT 1529f554add5SHoward Hinnant {return *this + (-__n);} 153061b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT 1531f554add5SHoward Hinnant {*this += -__n; return *this;} 153261b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT 1533f554add5SHoward Hinnant { 153431e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1535f554add5SHoward Hinnant _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n), 153696100f15SKristina Bessonova "Attempted to subscript an iterator outside its valid range"); 1537cec9af9eSHoward Hinnant#endif 1538f554add5SHoward Hinnant return __i[__n]; 1539f554add5SHoward Hinnant } 15403e519524SHoward Hinnant 154161b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;} 15423e519524SHoward Hinnant 15433e519524SHoward Hinnantprivate: 154431e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 15459cad5025SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x) 1546f554add5SHoward Hinnant { 1547f554add5SHoward Hinnant __get_db()->__insert_ic(this, __p); 1548f554add5SHoward Hinnant } 1549fc88dbd2SHoward Hinnant#else 155061b302f9SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} 1551f554add5SHoward Hinnant#endif 15523e519524SHoward Hinnant 15533e519524SHoward Hinnant template <class _Up> friend class __wrap_iter; 15543e519524SHoward Hinnant template <class _CharT, class _Traits, class _Alloc> friend class basic_string; 1555e2f2d1edSEric Fiselier template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector; 15567ad06a93SMarshall Clow template <class _Tp, size_t> friend class _LIBCPP_TEMPLATE_VIS span; 15573e519524SHoward Hinnant 15583e519524SHoward Hinnant template <class _Iter1, class _Iter2> 15599cad5025SMarshall Clow _LIBCPP_CONSTEXPR_IF_NODEBUG friend 15603e519524SHoward Hinnant bool 156161b302f9SEric Fiselier operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 15623e519524SHoward Hinnant 15633e519524SHoward Hinnant template <class _Iter1, class _Iter2> 15649cad5025SMarshall Clow _LIBCPP_CONSTEXPR_IF_NODEBUG friend 15653e519524SHoward Hinnant bool 156661b302f9SEric Fiselier operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 15673e519524SHoward Hinnant 15683e519524SHoward Hinnant template <class _Iter1, class _Iter2> 15699cad5025SMarshall Clow _LIBCPP_CONSTEXPR_IF_NODEBUG friend 15703e519524SHoward Hinnant bool 157161b302f9SEric Fiselier operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 15723e519524SHoward Hinnant 15733e519524SHoward Hinnant template <class _Iter1, class _Iter2> 15749cad5025SMarshall Clow _LIBCPP_CONSTEXPR_IF_NODEBUG friend 15753e519524SHoward Hinnant bool 157661b302f9SEric Fiselier operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 15773e519524SHoward Hinnant 15783e519524SHoward Hinnant template <class _Iter1, class _Iter2> 15799cad5025SMarshall Clow _LIBCPP_CONSTEXPR_IF_NODEBUG friend 15803e519524SHoward Hinnant bool 158161b302f9SEric Fiselier operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 15823e519524SHoward Hinnant 15833e519524SHoward Hinnant template <class _Iter1, class _Iter2> 15849cad5025SMarshall Clow _LIBCPP_CONSTEXPR_IF_NODEBUG friend 15853e519524SHoward Hinnant bool 158661b302f9SEric Fiselier operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 15873e519524SHoward Hinnant 15882ee83725SMarshall Clow#ifndef _LIBCPP_CXX03_LANG 1589947ce6b5SMarshall Clow template <class _Iter1, class _Iter2> 15909cad5025SMarshall Clow _LIBCPP_CONSTEXPR_IF_NODEBUG friend 1591947ce6b5SMarshall Clow auto 159261b302f9SEric Fiselier operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT 1593947ce6b5SMarshall Clow -> decltype(__x.base() - __y.base()); 1594947ce6b5SMarshall Clow#else 15953e519524SHoward Hinnant template <class _Iter1, class _Iter2> 15969cad5025SMarshall Clow _LIBCPP_CONSTEXPR_IF_NODEBUG friend 15973e519524SHoward Hinnant typename __wrap_iter<_Iter1>::difference_type 159861b302f9SEric Fiselier operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT; 1599947ce6b5SMarshall Clow#endif 16003e519524SHoward Hinnant 16013e519524SHoward Hinnant template <class _Iter1> 16029cad5025SMarshall Clow _LIBCPP_CONSTEXPR_IF_NODEBUG friend 16033e519524SHoward Hinnant __wrap_iter<_Iter1> 160461b302f9SEric Fiselier operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT; 16053e519524SHoward Hinnant}; 16063e519524SHoward Hinnant 1607d41c6d51SArthur O'Dwyer#if _LIBCPP_STD_VER <= 17 1608d41c6d51SArthur O'Dwyertemplate <class _It> 1609fc924887SArthur O'Dwyerstruct __is_cpp17_contiguous_iterator<__wrap_iter<_It> > : true_type {}; 1610d41c6d51SArthur O'Dwyer#endif 1611d41c6d51SArthur O'Dwyer 1612d41c6d51SArthur O'Dwyertemplate <class _Iter> 1613d41c6d51SArthur O'Dwyer_LIBCPP_CONSTEXPR 1614fc924887SArthur O'Dwyerdecltype(_VSTD::__to_address(declval<_Iter>())) 1615d41c6d51SArthur O'Dwyer__to_address(__wrap_iter<_Iter> __w) _NOEXCEPT { 1616d41c6d51SArthur O'Dwyer return _VSTD::__to_address(__w.base()); 1617d41c6d51SArthur O'Dwyer} 1618d41c6d51SArthur O'Dwyer 16193e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 16209cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16213e519524SHoward Hinnantbool 162261b302f9SEric Fiselieroperator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT 16233e519524SHoward Hinnant{ 16243e519524SHoward Hinnant return __x.base() == __y.base(); 16253e519524SHoward Hinnant} 16263e519524SHoward Hinnant 16273e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 16289cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16293e519524SHoward Hinnantbool 163061b302f9SEric Fiselieroperator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT 16313e519524SHoward Hinnant{ 163231e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 163342a3046eSHoward Hinnant _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), 1634f554add5SHoward Hinnant "Attempted to compare incomparable iterators"); 1635cec9af9eSHoward Hinnant#endif 16363e519524SHoward Hinnant return __x.base() < __y.base(); 16373e519524SHoward Hinnant} 16383e519524SHoward Hinnant 16393e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 16409cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16413e519524SHoward Hinnantbool 164261b302f9SEric Fiselieroperator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT 16433e519524SHoward Hinnant{ 1644f554add5SHoward Hinnant return !(__x == __y); 16453e519524SHoward Hinnant} 16463e519524SHoward Hinnant 16473e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 16489cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16493e519524SHoward Hinnantbool 165061b302f9SEric Fiselieroperator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT 16513e519524SHoward Hinnant{ 1652f554add5SHoward Hinnant return __y < __x; 16533e519524SHoward Hinnant} 16543e519524SHoward Hinnant 16553e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 16569cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16573e519524SHoward Hinnantbool 165861b302f9SEric Fiselieroperator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT 16593e519524SHoward Hinnant{ 1660f554add5SHoward Hinnant return !(__x < __y); 16613e519524SHoward Hinnant} 16623e519524SHoward Hinnant 16633e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 16649cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16653e519524SHoward Hinnantbool 166661b302f9SEric Fiselieroperator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT 16673e519524SHoward Hinnant{ 1668f554add5SHoward Hinnant return !(__y < __x); 16693e519524SHoward Hinnant} 16703e519524SHoward Hinnant 16716e551ae1SHoward Hinnanttemplate <class _Iter1> 16729cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16736e551ae1SHoward Hinnantbool 167461b302f9SEric Fiselieroperator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT 16756e551ae1SHoward Hinnant{ 16766e551ae1SHoward Hinnant return !(__x == __y); 16776e551ae1SHoward Hinnant} 16786e551ae1SHoward Hinnant 16796e551ae1SHoward Hinnanttemplate <class _Iter1> 16809cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16816e551ae1SHoward Hinnantbool 168261b302f9SEric Fiselieroperator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT 16836e551ae1SHoward Hinnant{ 16846e551ae1SHoward Hinnant return __y < __x; 16856e551ae1SHoward Hinnant} 16866e551ae1SHoward Hinnant 16876e551ae1SHoward Hinnanttemplate <class _Iter1> 16889cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16896e551ae1SHoward Hinnantbool 169061b302f9SEric Fiselieroperator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT 16916e551ae1SHoward Hinnant{ 16926e551ae1SHoward Hinnant return !(__x < __y); 16936e551ae1SHoward Hinnant} 16946e551ae1SHoward Hinnant 16956e551ae1SHoward Hinnanttemplate <class _Iter1> 16969cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16976e551ae1SHoward Hinnantbool 169861b302f9SEric Fiselieroperator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT 16996e551ae1SHoward Hinnant{ 17006e551ae1SHoward Hinnant return !(__y < __x); 17016e551ae1SHoward Hinnant} 17026e551ae1SHoward Hinnant 17032ee83725SMarshall Clow#ifndef _LIBCPP_CXX03_LANG 1704947ce6b5SMarshall Clowtemplate <class _Iter1, class _Iter2> 17059cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1706947ce6b5SMarshall Clowauto 170761b302f9SEric Fiselieroperator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT 1708947ce6b5SMarshall Clow-> decltype(__x.base() - __y.base()) 1709947ce6b5SMarshall Clow{ 171031e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 1711947ce6b5SMarshall Clow _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), 1712947ce6b5SMarshall Clow "Attempted to subtract incompatible iterators"); 1713947ce6b5SMarshall Clow#endif 1714947ce6b5SMarshall Clow return __x.base() - __y.base(); 1715947ce6b5SMarshall Clow} 1716947ce6b5SMarshall Clow#else 17173e519524SHoward Hinnanttemplate <class _Iter1, class _Iter2> 17189cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 17193e519524SHoward Hinnanttypename __wrap_iter<_Iter1>::difference_type 172061b302f9SEric Fiselieroperator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT 17213e519524SHoward Hinnant{ 172231e82037SLouis Dionne#if _LIBCPP_DEBUG_LEVEL == 2 172342a3046eSHoward Hinnant _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), 1724f554add5SHoward Hinnant "Attempted to subtract incompatible iterators"); 1725cec9af9eSHoward Hinnant#endif 17263e519524SHoward Hinnant return __x.base() - __y.base(); 17273e519524SHoward Hinnant} 1728947ce6b5SMarshall Clow#endif 17293e519524SHoward Hinnant 17303e519524SHoward Hinnanttemplate <class _Iter> 17319cad5025SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 17323e519524SHoward Hinnant__wrap_iter<_Iter> 17333e519524SHoward Hinnantoperator+(typename __wrap_iter<_Iter>::difference_type __n, 173461b302f9SEric Fiselier __wrap_iter<_Iter> __x) _NOEXCEPT 17353e519524SHoward Hinnant{ 1736f554add5SHoward Hinnant __x += __n; 1737f554add5SHoward Hinnant return __x; 17383e519524SHoward Hinnant} 17393e519524SHoward Hinnant 17403772a46aSMarshall Clowtemplate <class _Tp, size_t _Np> 17412ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 17423772a46aSMarshall Clow_Tp* 17433772a46aSMarshall Clowbegin(_Tp (&__array)[_Np]) 17443772a46aSMarshall Clow{ 17453772a46aSMarshall Clow return __array; 17463772a46aSMarshall Clow} 17473772a46aSMarshall Clow 17483772a46aSMarshall Clowtemplate <class _Tp, size_t _Np> 17492ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 17503772a46aSMarshall Clow_Tp* 17513772a46aSMarshall Clowend(_Tp (&__array)[_Np]) 17523772a46aSMarshall Clow{ 17533772a46aSMarshall Clow return __array + _Np; 17543772a46aSMarshall Clow} 17553772a46aSMarshall Clow 175654613ab4SEric Fiselier#if !defined(_LIBCPP_CXX03_LANG) 1757c66a611bSMarshall Clow 1758c003db1fSHoward Hinnanttemplate <class _Cp> 17592ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17603e519524SHoward Hinnantauto 1761c003db1fSHoward Hinnantbegin(_Cp& __c) -> decltype(__c.begin()) 17623e519524SHoward Hinnant{ 17633e519524SHoward Hinnant return __c.begin(); 17643e519524SHoward Hinnant} 17653e519524SHoward Hinnant 1766c003db1fSHoward Hinnanttemplate <class _Cp> 17672ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17683e519524SHoward Hinnantauto 1769c003db1fSHoward Hinnantbegin(const _Cp& __c) -> decltype(__c.begin()) 17703e519524SHoward Hinnant{ 17713e519524SHoward Hinnant return __c.begin(); 17723e519524SHoward Hinnant} 17733e519524SHoward Hinnant 1774c003db1fSHoward Hinnanttemplate <class _Cp> 17752ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17763e519524SHoward Hinnantauto 1777c003db1fSHoward Hinnantend(_Cp& __c) -> decltype(__c.end()) 17783e519524SHoward Hinnant{ 17793e519524SHoward Hinnant return __c.end(); 17803e519524SHoward Hinnant} 17813e519524SHoward Hinnant 1782c003db1fSHoward Hinnanttemplate <class _Cp> 17832ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17843e519524SHoward Hinnantauto 1785c003db1fSHoward Hinnantend(const _Cp& __c) -> decltype(__c.end()) 17863e519524SHoward Hinnant{ 17873e519524SHoward Hinnant return __c.end(); 17883e519524SHoward Hinnant} 17893e519524SHoward Hinnant 17901e548c72SMarshall Clow#if _LIBCPP_STD_VER > 11 17911e548c72SMarshall Clow 17923772a46aSMarshall Clowtemplate <class _Tp, size_t _Np> 17932ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17943772a46aSMarshall Clowreverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) 17953772a46aSMarshall Clow{ 17963772a46aSMarshall Clow return reverse_iterator<_Tp*>(__array + _Np); 17973772a46aSMarshall Clow} 17983772a46aSMarshall Clow 17993772a46aSMarshall Clowtemplate <class _Tp, size_t _Np> 18002ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 18013772a46aSMarshall Clowreverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) 18023772a46aSMarshall Clow{ 18033772a46aSMarshall Clow return reverse_iterator<_Tp*>(__array); 18043772a46aSMarshall Clow} 18053772a46aSMarshall Clow 18063772a46aSMarshall Clowtemplate <class _Ep> 18072ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 18083772a46aSMarshall Clowreverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il) 18093772a46aSMarshall Clow{ 18103772a46aSMarshall Clow return reverse_iterator<const _Ep*>(__il.end()); 18113772a46aSMarshall Clow} 18123772a46aSMarshall Clow 18133772a46aSMarshall Clowtemplate <class _Ep> 18142ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 18153772a46aSMarshall Clowreverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il) 18163772a46aSMarshall Clow{ 18173772a46aSMarshall Clow return reverse_iterator<const _Ep*>(__il.begin()); 18183772a46aSMarshall Clow} 18193772a46aSMarshall Clow 18201e548c72SMarshall Clowtemplate <class _Cp> 18212ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 18227725546aSMarshall Clowauto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c)) 18231e548c72SMarshall Clow{ 18247725546aSMarshall Clow return _VSTD::begin(__c); 18251e548c72SMarshall Clow} 18261e548c72SMarshall Clow 18271e548c72SMarshall Clowtemplate <class _Cp> 18282ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 18297725546aSMarshall Clowauto cend(const _Cp& __c) -> decltype(_VSTD::end(__c)) 18301e548c72SMarshall Clow{ 18317725546aSMarshall Clow return _VSTD::end(__c); 18321e548c72SMarshall Clow} 18331e548c72SMarshall Clow 18341e548c72SMarshall Clowtemplate <class _Cp> 18352ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 18361e548c72SMarshall Clowauto rbegin(_Cp& __c) -> decltype(__c.rbegin()) 18371e548c72SMarshall Clow{ 18381e548c72SMarshall Clow return __c.rbegin(); 18391e548c72SMarshall Clow} 18401e548c72SMarshall Clow 18411e548c72SMarshall Clowtemplate <class _Cp> 18422ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 18431e548c72SMarshall Clowauto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) 18441e548c72SMarshall Clow{ 18451e548c72SMarshall Clow return __c.rbegin(); 18461e548c72SMarshall Clow} 18471e548c72SMarshall Clow 18481e548c72SMarshall Clowtemplate <class _Cp> 18492ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 18501e548c72SMarshall Clowauto rend(_Cp& __c) -> decltype(__c.rend()) 18511e548c72SMarshall Clow{ 18521e548c72SMarshall Clow return __c.rend(); 18531e548c72SMarshall Clow} 18541e548c72SMarshall Clow 18551e548c72SMarshall Clowtemplate <class _Cp> 18562ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 18571e548c72SMarshall Clowauto rend(const _Cp& __c) -> decltype(__c.rend()) 18581e548c72SMarshall Clow{ 18591e548c72SMarshall Clow return __c.rend(); 18601e548c72SMarshall Clow} 18611e548c72SMarshall Clow 18621e548c72SMarshall Clowtemplate <class _Cp> 18632ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 18647725546aSMarshall Clowauto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c)) 18651e548c72SMarshall Clow{ 18667725546aSMarshall Clow return _VSTD::rbegin(__c); 18671e548c72SMarshall Clow} 18681e548c72SMarshall Clow 18691e548c72SMarshall Clowtemplate <class _Cp> 18702ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 18717725546aSMarshall Clowauto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c)) 18721e548c72SMarshall Clow{ 18737725546aSMarshall Clow return _VSTD::rend(__c); 18741e548c72SMarshall Clow} 18751e548c72SMarshall Clow 18761e548c72SMarshall Clow#endif 18771e548c72SMarshall Clow 18781e548c72SMarshall Clow 187954613ab4SEric Fiselier#else // defined(_LIBCPP_CXX03_LANG) 18803e519524SHoward Hinnant 1881c003db1fSHoward Hinnanttemplate <class _Cp> 18822ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 1883c003db1fSHoward Hinnanttypename _Cp::iterator 1884c003db1fSHoward Hinnantbegin(_Cp& __c) 18853e519524SHoward Hinnant{ 18863e519524SHoward Hinnant return __c.begin(); 18873e519524SHoward Hinnant} 18883e519524SHoward Hinnant 1889c003db1fSHoward Hinnanttemplate <class _Cp> 18902ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 1891c003db1fSHoward Hinnanttypename _Cp::const_iterator 1892c003db1fSHoward Hinnantbegin(const _Cp& __c) 18933e519524SHoward Hinnant{ 18943e519524SHoward Hinnant return __c.begin(); 18953e519524SHoward Hinnant} 18963e519524SHoward Hinnant 1897c003db1fSHoward Hinnanttemplate <class _Cp> 18982ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 1899c003db1fSHoward Hinnanttypename _Cp::iterator 1900c003db1fSHoward Hinnantend(_Cp& __c) 19013e519524SHoward Hinnant{ 19023e519524SHoward Hinnant return __c.end(); 19033e519524SHoward Hinnant} 19043e519524SHoward Hinnant 1905c003db1fSHoward Hinnanttemplate <class _Cp> 19062ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 1907c003db1fSHoward Hinnanttypename _Cp::const_iterator 1908c003db1fSHoward Hinnantend(const _Cp& __c) 19093e519524SHoward Hinnant{ 19103e519524SHoward Hinnant return __c.end(); 19113e519524SHoward Hinnant} 19123e519524SHoward Hinnant 191354613ab4SEric Fiselier#endif // !defined(_LIBCPP_CXX03_LANG) 19143e519524SHoward Hinnant 1915ad755104SMarshall Clow#if _LIBCPP_STD_VER > 14 1916d1dcda19SMarshall Clow 1917d1dcda19SMarshall Clow// #if _LIBCPP_STD_VER > 11 1918d1dcda19SMarshall Clow// template <> 1919d1dcda19SMarshall Clow// struct _LIBCPP_TEMPLATE_VIS plus<void> 1920d1dcda19SMarshall Clow// { 1921d1dcda19SMarshall Clow// template <class _T1, class _T2> 1922d1dcda19SMarshall Clow// _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1923d1dcda19SMarshall Clow// auto operator()(_T1&& __t, _T2&& __u) const 1924d1dcda19SMarshall Clow// _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) 1925d1dcda19SMarshall Clow// -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) 1926d1dcda19SMarshall Clow// { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } 1927d1dcda19SMarshall Clow// typedef void is_transparent; 1928d1dcda19SMarshall Clow// }; 1929d1dcda19SMarshall Clow// #endif 1930d1dcda19SMarshall Clow 193188d21343SMarshall Clowtemplate <class _Cont> 19322ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 1933d1dcda19SMarshall Clowconstexpr auto size(const _Cont& __c) 1934d1dcda19SMarshall Clow_NOEXCEPT_(noexcept(__c.size())) 1935d1dcda19SMarshall Clow-> decltype (__c.size()) 1936d1dcda19SMarshall Clow{ return __c.size(); } 1937ad755104SMarshall Clow 193888d21343SMarshall Clowtemplate <class _Tp, size_t _Sz> 19392ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 1940fd838227SEric Fiselierconstexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; } 1941ad755104SMarshall Clow 19427d3986eaSMarshall Clow#if _LIBCPP_STD_VER > 17 19437d3986eaSMarshall Clowtemplate <class _Cont> 19442ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 19457d3986eaSMarshall Clowconstexpr auto ssize(const _Cont& __c) 19467d3986eaSMarshall Clow_NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()))) 19477d3986eaSMarshall Clow-> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>> 19487d3986eaSMarshall Clow{ return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); } 19497d3986eaSMarshall Clow 19507d3986eaSMarshall Clowtemplate <class _Tp, ptrdiff_t _Sz> 19512ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 19527d3986eaSMarshall Clowconstexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; } 19537d3986eaSMarshall Clow#endif 19547d3986eaSMarshall Clow 195588d21343SMarshall Clowtemplate <class _Cont> 19562ffa1705SMarshall Clow_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 1957d1dcda19SMarshall Clowconstexpr auto empty(const _Cont& __c) 1958d1dcda19SMarshall Clow_NOEXCEPT_(noexcept(__c.empty())) 1959d1dcda19SMarshall Clow-> decltype (__c.empty()) 1960d1dcda19SMarshall Clow{ return __c.empty(); } 1961ad755104SMarshall Clow 196288d21343SMarshall Clowtemplate <class _Tp, size_t _Sz> 19632ffa1705SMarshall Clow_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 1964fd838227SEric Fiselierconstexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; } 1965ad755104SMarshall Clow 1966ad755104SMarshall Clowtemplate <class _Ep> 19672ffa1705SMarshall Clow_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 1968ad755104SMarshall Clowconstexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; } 1969ad755104SMarshall Clow 197088d21343SMarshall Clowtemplate <class _Cont> constexpr 19712ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 1972d1dcda19SMarshall Clowauto data(_Cont& __c) 1973d1dcda19SMarshall Clow_NOEXCEPT_(noexcept(__c.data())) 1974d1dcda19SMarshall Clow-> decltype (__c.data()) 1975d1dcda19SMarshall Clow{ return __c.data(); } 1976ad755104SMarshall Clow 197788d21343SMarshall Clowtemplate <class _Cont> constexpr 19782ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 1979d1dcda19SMarshall Clowauto data(const _Cont& __c) 1980d1dcda19SMarshall Clow_NOEXCEPT_(noexcept(__c.data())) 1981d1dcda19SMarshall Clow-> decltype (__c.data()) 1982d1dcda19SMarshall Clow{ return __c.data(); } 1983ad755104SMarshall Clow 198488d21343SMarshall Clowtemplate <class _Tp, size_t _Sz> 19852ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 198688d21343SMarshall Clowconstexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; } 1987ad755104SMarshall Clow 1988ad755104SMarshall Clowtemplate <class _Ep> 19892ffa1705SMarshall Clow_LIBCPP_INLINE_VISIBILITY 1990ad755104SMarshall Clowconstexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); } 1991ad755104SMarshall Clow#endif 1992ad755104SMarshall Clow 19932ac6babcSArthur O'Dwyertemplate <class _Container, class _Predicate> 19942ac6babcSArthur O'Dwyertypename _Container::size_type 19952ac6babcSArthur O'Dwyer__libcpp_erase_if_container(_Container& __c, _Predicate& __pred) { 19962ac6babcSArthur O'Dwyer typename _Container::size_type __old_size = __c.size(); 19972ac6babcSArthur O'Dwyer 19982ac6babcSArthur O'Dwyer const typename _Container::iterator __last = __c.end(); 19992ac6babcSArthur O'Dwyer for (typename _Container::iterator __iter = __c.begin(); __iter != __last;) { 20002ac6babcSArthur O'Dwyer if (__pred(*__iter)) 20012ac6babcSArthur O'Dwyer __iter = __c.erase(__iter); 20022ac6babcSArthur O'Dwyer else 20032ac6babcSArthur O'Dwyer ++__iter; 20042ac6babcSArthur O'Dwyer } 20052ac6babcSArthur O'Dwyer 20062ac6babcSArthur O'Dwyer return __old_size - __c.size(); 20072ac6babcSArthur O'Dwyer} 2008ad755104SMarshall Clow 20093e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD 20103e519524SHoward Hinnant 20113e519524SHoward Hinnant#endif // _LIBCPP_ITERATOR 2012