iterator 68 KB

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