17a984708SDavid Chisnall// -*- C++ -*- 27a984708SDavid Chisnall//===-------------------------- iterator ----------------------------------===// 37a984708SDavid Chisnall// 47a984708SDavid Chisnall// The LLVM Compiler Infrastructure 57a984708SDavid Chisnall// 67a984708SDavid Chisnall// This file is dual licensed under the MIT and the University of Illinois Open 77a984708SDavid Chisnall// Source Licenses. See LICENSE.TXT for details. 87a984708SDavid Chisnall// 97a984708SDavid Chisnall//===----------------------------------------------------------------------===// 107a984708SDavid Chisnall 117a984708SDavid Chisnall#ifndef _LIBCPP_ITERATOR 127a984708SDavid Chisnall#define _LIBCPP_ITERATOR 137a984708SDavid Chisnall 147a984708SDavid Chisnall/* 157a984708SDavid Chisnall iterator synopsis 167a984708SDavid Chisnall 177a984708SDavid Chisnallnamespace std 187a984708SDavid Chisnall{ 197a984708SDavid Chisnall 207a984708SDavid Chisnalltemplate<class Iterator> 217a984708SDavid Chisnallstruct iterator_traits 227a984708SDavid Chisnall{ 237a984708SDavid Chisnall typedef typename Iterator::difference_type difference_type; 247a984708SDavid Chisnall typedef typename Iterator::value_type value_type; 257a984708SDavid Chisnall typedef typename Iterator::pointer pointer; 267a984708SDavid Chisnall typedef typename Iterator::reference reference; 277a984708SDavid Chisnall typedef typename Iterator::iterator_category iterator_category; 287a984708SDavid Chisnall}; 297a984708SDavid Chisnall 307a984708SDavid Chisnalltemplate<class T> 317a984708SDavid Chisnallstruct iterator_traits<T*> 327a984708SDavid Chisnall{ 337a984708SDavid Chisnall typedef ptrdiff_t difference_type; 347a984708SDavid Chisnall typedef T value_type; 357a984708SDavid Chisnall typedef T* pointer; 367a984708SDavid Chisnall typedef T& reference; 377a984708SDavid Chisnall typedef random_access_iterator_tag iterator_category; 387a984708SDavid Chisnall}; 397a984708SDavid Chisnall 407a984708SDavid Chisnalltemplate<class Category, class T, class Distance = ptrdiff_t, 417a984708SDavid Chisnall class Pointer = T*, class Reference = T&> 427a984708SDavid Chisnallstruct iterator 437a984708SDavid Chisnall{ 447a984708SDavid Chisnall typedef T value_type; 457a984708SDavid Chisnall typedef Distance difference_type; 467a984708SDavid Chisnall typedef Pointer pointer; 477a984708SDavid Chisnall typedef Reference reference; 487a984708SDavid Chisnall typedef Category iterator_category; 497a984708SDavid Chisnall}; 507a984708SDavid Chisnall 517a984708SDavid Chisnallstruct input_iterator_tag {}; 527a984708SDavid Chisnallstruct output_iterator_tag {}; 537a984708SDavid Chisnallstruct forward_iterator_tag : public input_iterator_tag {}; 547a984708SDavid Chisnallstruct bidirectional_iterator_tag : public forward_iterator_tag {}; 557a984708SDavid Chisnallstruct random_access_iterator_tag : public bidirectional_iterator_tag {}; 567a984708SDavid Chisnall 5760ff8e32SDimitry Andric// 27.4.3, iterator operations 587a984708SDavid Chisnall// extension: second argument not conforming to C++03 5960ff8e32SDimitry Andrictemplate <class InputIterator> // constexpr in C++17 6060ff8e32SDimitry Andric constexpr void advance(InputIterator& i, 617a984708SDavid Chisnall typename iterator_traits<InputIterator>::difference_type n); 627a984708SDavid Chisnall 6360ff8e32SDimitry Andrictemplate <class InputIterator> // constexpr in C++17 6460ff8e32SDimitry Andric constexpr typename iterator_traits<InputIterator>::difference_type 657a984708SDavid Chisnall distance(InputIterator first, InputIterator last); 667a984708SDavid Chisnall 6760ff8e32SDimitry Andrictemplate <class InputIterator> // constexpr in C++17 6860ff8e32SDimitry Andric constexpr InputIterator next(InputIterator x, 6960ff8e32SDimitry Andrictypename iterator_traits<InputIterator>::difference_type n = 1); 7060ff8e32SDimitry Andric 7160ff8e32SDimitry Andrictemplate <class BidirectionalIterator> // constexpr in C++17 7260ff8e32SDimitry Andric constexpr BidirectionalIterator prev(BidirectionalIterator x, 7360ff8e32SDimitry Andric typename iterator_traits<BidirectionalIterator>::difference_type n = 1); 7460ff8e32SDimitry Andric 757a984708SDavid Chisnalltemplate <class Iterator> 767a984708SDavid Chisnallclass reverse_iterator 777a984708SDavid Chisnall : public iterator<typename iterator_traits<Iterator>::iterator_category, 787a984708SDavid Chisnall typename iterator_traits<Iterator>::value_type, 797a984708SDavid Chisnall typename iterator_traits<Iterator>::difference_type, 807a984708SDavid Chisnall typename iterator_traits<Iterator>::pointer, 817a984708SDavid Chisnall typename iterator_traits<Iterator>::reference> 827a984708SDavid Chisnall{ 837a984708SDavid Chisnallprotected: 847a984708SDavid Chisnall Iterator current; 857a984708SDavid Chisnallpublic: 867a984708SDavid Chisnall typedef Iterator iterator_type; 877a984708SDavid Chisnall typedef typename iterator_traits<Iterator>::difference_type difference_type; 887a984708SDavid Chisnall typedef typename iterator_traits<Iterator>::reference reference; 897a984708SDavid Chisnall typedef typename iterator_traits<Iterator>::pointer pointer; 907a984708SDavid Chisnall 91aed8d94eSDimitry Andric constexpr reverse_iterator(); 92aed8d94eSDimitry Andric constexpr explicit reverse_iterator(Iterator x); 93aed8d94eSDimitry Andric template <class U> constexpr reverse_iterator(const reverse_iterator<U>& u); 94aed8d94eSDimitry Andric template <class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u); 95aed8d94eSDimitry Andric constexpr Iterator base() const; 96aed8d94eSDimitry Andric constexpr reference operator*() const; 97aed8d94eSDimitry Andric constexpr pointer operator->() const; 98aed8d94eSDimitry Andric constexpr reverse_iterator& operator++(); 99aed8d94eSDimitry Andric constexpr reverse_iterator operator++(int); 100aed8d94eSDimitry Andric constexpr reverse_iterator& operator--(); 101aed8d94eSDimitry Andric constexpr reverse_iterator operator--(int); 102aed8d94eSDimitry Andric constexpr reverse_iterator operator+ (difference_type n) const; 103aed8d94eSDimitry Andric constexpr reverse_iterator& operator+=(difference_type n); 104aed8d94eSDimitry Andric constexpr reverse_iterator operator- (difference_type n) const; 105aed8d94eSDimitry Andric constexpr reverse_iterator& operator-=(difference_type n); 106aed8d94eSDimitry Andric constexpr reference operator[](difference_type n) const; 1077a984708SDavid Chisnall}; 1087a984708SDavid Chisnall 1097a984708SDavid Chisnalltemplate <class Iterator1, class Iterator2> 110aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 1117a984708SDavid Chisnalloperator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 1127a984708SDavid Chisnall 1137a984708SDavid Chisnalltemplate <class Iterator1, class Iterator2> 114aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 1157a984708SDavid Chisnalloperator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 1167a984708SDavid Chisnall 1177a984708SDavid Chisnalltemplate <class Iterator1, class Iterator2> 118aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 1197a984708SDavid Chisnalloperator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 1207a984708SDavid Chisnall 1217a984708SDavid Chisnalltemplate <class Iterator1, class Iterator2> 122aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 1237a984708SDavid Chisnalloperator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 1247a984708SDavid Chisnall 1257a984708SDavid Chisnalltemplate <class Iterator1, class Iterator2> 126aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 1277a984708SDavid Chisnalloperator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 1287a984708SDavid Chisnall 1297a984708SDavid Chisnalltemplate <class Iterator1, class Iterator2> 130aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 1317a984708SDavid Chisnalloperator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); 1327a984708SDavid Chisnall 1337a984708SDavid Chisnalltemplate <class Iterator1, class Iterator2> 134aed8d94eSDimitry Andricconstexpr auto 1357c82a1ecSDimitry Andricoperator-(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y) 136aed8d94eSDimitry Andric-> decltype(__y.base() - __x.base()); // constexpr in C++17 1377a984708SDavid Chisnall 1387a984708SDavid Chisnalltemplate <class Iterator> 139aed8d94eSDimitry Andricconstexpr reverse_iterator<Iterator> 140aed8d94eSDimitry Andricoperator+(typename reverse_iterator<Iterator>::difference_type n, 141aed8d94eSDimitry Andric const reverse_iterator<Iterator>& x); // constexpr in C++17 1427a984708SDavid Chisnall 143aed8d94eSDimitry Andrictemplate <class Iterator> 144aed8d94eSDimitry Andricconstexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14, constexpr in C++17 145d72607e9SDimitry Andric 1467a984708SDavid Chisnalltemplate <class Container> 1477a984708SDavid Chisnallclass back_insert_iterator 1487a984708SDavid Chisnall{ 1497a984708SDavid Chisnallprotected: 1507a984708SDavid Chisnall Container* container; 1517a984708SDavid Chisnallpublic: 1527a984708SDavid Chisnall typedef Container container_type; 1537a984708SDavid Chisnall typedef void value_type; 1547a984708SDavid Chisnall typedef void difference_type; 1557c82a1ecSDimitry Andric typedef void reference; 1567a984708SDavid Chisnall typedef void pointer; 1577a984708SDavid Chisnall 1587a984708SDavid Chisnall explicit back_insert_iterator(Container& x); 1597a984708SDavid Chisnall back_insert_iterator& operator=(const typename Container::value_type& value); 1607a984708SDavid Chisnall back_insert_iterator& operator*(); 1617a984708SDavid Chisnall back_insert_iterator& operator++(); 1627a984708SDavid Chisnall back_insert_iterator operator++(int); 1637a984708SDavid Chisnall}; 1647a984708SDavid Chisnall 1657a984708SDavid Chisnalltemplate <class Container> back_insert_iterator<Container> back_inserter(Container& x); 1667a984708SDavid Chisnall 1677a984708SDavid Chisnalltemplate <class Container> 1687a984708SDavid Chisnallclass front_insert_iterator 1697a984708SDavid Chisnall{ 1707a984708SDavid Chisnallprotected: 1717a984708SDavid Chisnall Container* container; 1727a984708SDavid Chisnallpublic: 1737a984708SDavid Chisnall typedef Container container_type; 1747a984708SDavid Chisnall typedef void value_type; 1757a984708SDavid Chisnall typedef void difference_type; 1767c82a1ecSDimitry Andric typedef void reference; 1777a984708SDavid Chisnall typedef void pointer; 1787a984708SDavid Chisnall 1797a984708SDavid Chisnall explicit front_insert_iterator(Container& x); 1807a984708SDavid Chisnall front_insert_iterator& operator=(const typename Container::value_type& value); 1817a984708SDavid Chisnall front_insert_iterator& operator*(); 1827a984708SDavid Chisnall front_insert_iterator& operator++(); 1837a984708SDavid Chisnall front_insert_iterator operator++(int); 1847a984708SDavid Chisnall}; 1857a984708SDavid Chisnall 1867a984708SDavid Chisnalltemplate <class Container> front_insert_iterator<Container> front_inserter(Container& x); 1877a984708SDavid Chisnall 1887a984708SDavid Chisnalltemplate <class Container> 1897a984708SDavid Chisnallclass insert_iterator 1907a984708SDavid Chisnall{ 1917a984708SDavid Chisnallprotected: 1927a984708SDavid Chisnall Container* container; 1937a984708SDavid Chisnall typename Container::iterator iter; 1947a984708SDavid Chisnallpublic: 1957a984708SDavid Chisnall typedef Container container_type; 1967a984708SDavid Chisnall typedef void value_type; 1977a984708SDavid Chisnall typedef void difference_type; 1987c82a1ecSDimitry Andric typedef void reference; 1997a984708SDavid Chisnall typedef void pointer; 2007a984708SDavid Chisnall 2017a984708SDavid Chisnall insert_iterator(Container& x, typename Container::iterator i); 2027a984708SDavid Chisnall insert_iterator& operator=(const typename Container::value_type& value); 2037a984708SDavid Chisnall insert_iterator& operator*(); 2047a984708SDavid Chisnall insert_iterator& operator++(); 2057a984708SDavid Chisnall insert_iterator& operator++(int); 2067a984708SDavid Chisnall}; 2077a984708SDavid Chisnall 2087a984708SDavid Chisnalltemplate <class Container, class Iterator> 2097a984708SDavid Chisnallinsert_iterator<Container> inserter(Container& x, Iterator i); 2107a984708SDavid Chisnall 2117c82a1ecSDimitry Andrictemplate <class Iterator> 2127c82a1ecSDimitry Andricclass move_iterator { 2137c82a1ecSDimitry Andricpublic: 2147c82a1ecSDimitry Andric typedef Iterator iterator_type; 2157c82a1ecSDimitry Andric typedef typename iterator_traits<Iterator>::difference_type difference_type; 2167c82a1ecSDimitry Andric typedef Iterator pointer; 2177c82a1ecSDimitry Andric typedef typename iterator_traits<Iterator>::value_type value_type; 2187c82a1ecSDimitry Andric typedef typename iterator_traits<Iterator>::iterator_category iterator_category; 2197c82a1ecSDimitry Andric typedef value_type&& reference; 2207c82a1ecSDimitry Andric 221aed8d94eSDimitry Andric constexpr move_iterator(); // all the constexprs are in C++17 222aed8d94eSDimitry Andric constexpr explicit move_iterator(Iterator i); 223aed8d94eSDimitry Andric template <class U> 224aed8d94eSDimitry Andric constexpr move_iterator(const move_iterator<U>& u); 225aed8d94eSDimitry Andric template <class U> 226aed8d94eSDimitry Andric constexpr move_iterator& operator=(const move_iterator<U>& u); 227aed8d94eSDimitry Andric constexpr iterator_type base() const; 228aed8d94eSDimitry Andric constexpr reference operator*() const; 229aed8d94eSDimitry Andric constexpr pointer operator->() const; 230aed8d94eSDimitry Andric constexpr move_iterator& operator++(); 231aed8d94eSDimitry Andric constexpr move_iterator operator++(int); 232aed8d94eSDimitry Andric constexpr move_iterator& operator--(); 233aed8d94eSDimitry Andric constexpr move_iterator operator--(int); 234aed8d94eSDimitry Andric constexpr move_iterator operator+(difference_type n) const; 235aed8d94eSDimitry Andric constexpr move_iterator& operator+=(difference_type n); 236aed8d94eSDimitry Andric constexpr move_iterator operator-(difference_type n) const; 237aed8d94eSDimitry Andric constexpr move_iterator& operator-=(difference_type n); 238aed8d94eSDimitry Andric constexpr unspecified operator[](difference_type n) const; 2397c82a1ecSDimitry Andricprivate: 2407c82a1ecSDimitry Andric Iterator current; // exposition only 2417c82a1ecSDimitry Andric}; 2427c82a1ecSDimitry Andric 2437c82a1ecSDimitry Andrictemplate <class Iterator1, class Iterator2> 244aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 2457c82a1ecSDimitry Andricoperator==(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 2467c82a1ecSDimitry Andric 2477c82a1ecSDimitry Andrictemplate <class Iterator1, class Iterator2> 248aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 2497c82a1ecSDimitry Andricoperator!=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 2507c82a1ecSDimitry Andric 2517c82a1ecSDimitry Andrictemplate <class Iterator1, class Iterator2> 252aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 2537c82a1ecSDimitry Andricoperator<(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 2547c82a1ecSDimitry Andric 2557c82a1ecSDimitry Andrictemplate <class Iterator1, class Iterator2> 256aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 2577c82a1ecSDimitry Andricoperator<=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 2587c82a1ecSDimitry Andric 2597c82a1ecSDimitry Andrictemplate <class Iterator1, class Iterator2> 260aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 2617c82a1ecSDimitry Andricoperator>(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 2627c82a1ecSDimitry Andric 2637c82a1ecSDimitry Andrictemplate <class Iterator1, class Iterator2> 264aed8d94eSDimitry Andricconstexpr bool // constexpr in C++17 2657c82a1ecSDimitry Andricoperator>=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y); 2667c82a1ecSDimitry Andric 2677c82a1ecSDimitry Andrictemplate <class Iterator1, class Iterator2> 268aed8d94eSDimitry Andricconstexpr auto // constexpr in C++17 2697c82a1ecSDimitry Andricoperator-(const move_iterator<Iterator1>& x, 2707c82a1ecSDimitry Andric const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base()); 2717c82a1ecSDimitry Andric 2727c82a1ecSDimitry Andrictemplate <class Iterator> 273aed8d94eSDimitry Andricconstexpr move_iterator<Iterator> operator+( // constexpr in C++17 274aed8d94eSDimitry Andric typename move_iterator<Iterator>::difference_type n, 2757c82a1ecSDimitry Andric const move_iterator<Iterator>& x); 2767c82a1ecSDimitry Andric 277aed8d94eSDimitry Andrictemplate <class Iterator> // constexpr in C++17 278aed8d94eSDimitry Andricconstexpr move_iterator<Iterator> make_move_iterator(const Iterator& i); 2797c82a1ecSDimitry Andric 2807c82a1ecSDimitry Andric 2817a984708SDavid Chisnalltemplate <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t> 2827a984708SDavid Chisnallclass istream_iterator 2837a984708SDavid Chisnall : public iterator<input_iterator_tag, T, Distance, const T*, const T&> 2847a984708SDavid Chisnall{ 2857a984708SDavid Chisnallpublic: 2867a984708SDavid Chisnall typedef charT char_type; 2877a984708SDavid Chisnall typedef traits traits_type; 2887a984708SDavid Chisnall typedef basic_istream<charT,traits> istream_type; 2897a984708SDavid Chisnall 290854fa44bSDimitry Andric constexpr istream_iterator(); 2917a984708SDavid Chisnall istream_iterator(istream_type& s); 2927a984708SDavid Chisnall istream_iterator(const istream_iterator& x); 2937a984708SDavid Chisnall ~istream_iterator(); 2947a984708SDavid Chisnall 2957a984708SDavid Chisnall const T& operator*() const; 2967a984708SDavid Chisnall const T* operator->() const; 2977a984708SDavid Chisnall istream_iterator& operator++(); 2987a984708SDavid Chisnall istream_iterator operator++(int); 2997a984708SDavid Chisnall}; 3007a984708SDavid Chisnall 3017a984708SDavid Chisnalltemplate <class T, class charT, class traits, class Distance> 3027a984708SDavid Chisnallbool operator==(const istream_iterator<T,charT,traits,Distance>& x, 3037a984708SDavid Chisnall const istream_iterator<T,charT,traits,Distance>& y); 3047a984708SDavid Chisnalltemplate <class T, class charT, class traits, class Distance> 3057a984708SDavid Chisnallbool operator!=(const istream_iterator<T,charT,traits,Distance>& x, 3067a984708SDavid Chisnall const istream_iterator<T,charT,traits,Distance>& y); 3077a984708SDavid Chisnall 3087a984708SDavid Chisnalltemplate <class T, class charT = char, class traits = char_traits<charT> > 3097a984708SDavid Chisnallclass ostream_iterator 3107a984708SDavid Chisnall : public iterator<output_iterator_tag, void, void, void ,void> 3117a984708SDavid Chisnall{ 3127a984708SDavid Chisnallpublic: 3137a984708SDavid Chisnall typedef charT char_type; 3147a984708SDavid Chisnall typedef traits traits_type; 3157a984708SDavid Chisnall typedef basic_ostream<charT,traits> ostream_type; 3167a984708SDavid Chisnall 3177a984708SDavid Chisnall ostream_iterator(ostream_type& s); 3187a984708SDavid Chisnall ostream_iterator(ostream_type& s, const charT* delimiter); 3197a984708SDavid Chisnall ostream_iterator(const ostream_iterator& x); 3207a984708SDavid Chisnall ~ostream_iterator(); 3217a984708SDavid Chisnall ostream_iterator& operator=(const T& value); 3227a984708SDavid Chisnall 3237a984708SDavid Chisnall ostream_iterator& operator*(); 3247a984708SDavid Chisnall ostream_iterator& operator++(); 3257a984708SDavid Chisnall ostream_iterator& operator++(int); 3267a984708SDavid Chisnall}; 3277a984708SDavid Chisnall 3287a984708SDavid Chisnalltemplate<class charT, class traits = char_traits<charT> > 3297a984708SDavid Chisnallclass istreambuf_iterator 3307a984708SDavid Chisnall : public iterator<input_iterator_tag, charT, 3317a984708SDavid Chisnall typename traits::off_type, unspecified, 3327a984708SDavid Chisnall charT> 3337a984708SDavid Chisnall{ 3347a984708SDavid Chisnallpublic: 3357a984708SDavid Chisnall typedef charT char_type; 3367a984708SDavid Chisnall typedef traits traits_type; 3377a984708SDavid Chisnall typedef typename traits::int_type int_type; 3387a984708SDavid Chisnall typedef basic_streambuf<charT,traits> streambuf_type; 3397a984708SDavid Chisnall typedef basic_istream<charT,traits> istream_type; 3407a984708SDavid Chisnall 341936e9439SDimitry Andric istreambuf_iterator() noexcept; 342936e9439SDimitry Andric istreambuf_iterator(istream_type& s) noexcept; 343936e9439SDimitry Andric istreambuf_iterator(streambuf_type* s) noexcept; 344936e9439SDimitry Andric istreambuf_iterator(a-private-type) noexcept; 3457a984708SDavid Chisnall 3467a984708SDavid Chisnall charT operator*() const; 3477a984708SDavid Chisnall pointer operator->() const; 3487a984708SDavid Chisnall istreambuf_iterator& operator++(); 3497a984708SDavid Chisnall a-private-type operator++(int); 3507a984708SDavid Chisnall 3517a984708SDavid Chisnall bool equal(const istreambuf_iterator& b) const; 3527a984708SDavid Chisnall}; 3537a984708SDavid Chisnall 3547a984708SDavid Chisnalltemplate <class charT, class traits> 3557a984708SDavid Chisnallbool operator==(const istreambuf_iterator<charT,traits>& a, 3567a984708SDavid Chisnall const istreambuf_iterator<charT,traits>& b); 3577a984708SDavid Chisnalltemplate <class charT, class traits> 3587a984708SDavid Chisnallbool operator!=(const istreambuf_iterator<charT,traits>& a, 3597a984708SDavid Chisnall const istreambuf_iterator<charT,traits>& b); 3607a984708SDavid Chisnall 3617a984708SDavid Chisnalltemplate <class charT, class traits = char_traits<charT> > 3627a984708SDavid Chisnallclass ostreambuf_iterator 3637a984708SDavid Chisnall : public iterator<output_iterator_tag, void, void, void, void> 3647a984708SDavid Chisnall{ 3657a984708SDavid Chisnallpublic: 3667a984708SDavid Chisnall typedef charT char_type; 3677a984708SDavid Chisnall typedef traits traits_type; 3687a984708SDavid Chisnall typedef basic_streambuf<charT,traits> streambuf_type; 3697a984708SDavid Chisnall typedef basic_ostream<charT,traits> ostream_type; 3707a984708SDavid Chisnall 371936e9439SDimitry Andric ostreambuf_iterator(ostream_type& s) noexcept; 372936e9439SDimitry Andric ostreambuf_iterator(streambuf_type* s) noexcept; 3737a984708SDavid Chisnall ostreambuf_iterator& operator=(charT c); 3747a984708SDavid Chisnall ostreambuf_iterator& operator*(); 3757a984708SDavid Chisnall ostreambuf_iterator& operator++(); 3767a984708SDavid Chisnall ostreambuf_iterator& operator++(int); 377936e9439SDimitry Andric bool failed() const noexcept; 3787a984708SDavid Chisnall}; 3797a984708SDavid Chisnall 380aed8d94eSDimitry Andrictemplate <class C> constexpr auto begin(C& c) -> decltype(c.begin()); 381aed8d94eSDimitry Andrictemplate <class C> constexpr auto begin(const C& c) -> decltype(c.begin()); 382aed8d94eSDimitry Andrictemplate <class C> constexpr auto end(C& c) -> decltype(c.end()); 383aed8d94eSDimitry Andrictemplate <class C> constexpr auto end(const C& c) -> decltype(c.end()); 384aed8d94eSDimitry Andrictemplate <class T, size_t N> constexpr T* begin(T (&array)[N]); 385aed8d94eSDimitry Andrictemplate <class T, size_t N> constexpr T* end(T (&array)[N]); 3867a984708SDavid Chisnall 387aed8d94eSDimitry Andrictemplate <class C> auto constexpr cbegin(const C& c) -> decltype(std::begin(c)); // C++14 388aed8d94eSDimitry Andrictemplate <class C> auto constexpr cend(const C& c) -> decltype(std::end(c)); // C++14 389aed8d94eSDimitry Andrictemplate <class C> auto constexpr rbegin(C& c) -> decltype(c.rbegin()); // C++14 390aed8d94eSDimitry Andrictemplate <class C> auto constexpr rbegin(const C& c) -> decltype(c.rbegin()); // C++14 391aed8d94eSDimitry Andrictemplate <class C> auto constexpr rend(C& c) -> decltype(c.rend()); // C++14 392aed8d94eSDimitry Andrictemplate <class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // C++14 393aed8d94eSDimitry Andrictemplate <class E> reverse_iterator<const E*> constexpr rbegin(initializer_list<E> il); // C++14 394aed8d94eSDimitry Andrictemplate <class E> reverse_iterator<const E*> constexpr rend(initializer_list<E> il); // C++14 395aed8d94eSDimitry Andrictemplate <class T, size_t N> reverse_iterator<T*> constexpr rbegin(T (&array)[N]); // C++14 396aed8d94eSDimitry Andrictemplate <class T, size_t N> reverse_iterator<T*> constexpr rend(T (&array)[N]); // C++14 397aed8d94eSDimitry Andrictemplate <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 398aed8d94eSDimitry Andrictemplate <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); // C++14 3994f7ab58eSDimitry Andric 400d72607e9SDimitry Andric// 24.8, container access: 401d72607e9SDimitry Andrictemplate <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17 402d72607e9SDimitry Andrictemplate <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17 403d72607e9SDimitry Andrictemplate <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17 404d72607e9SDimitry Andrictemplate <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17 405d72607e9SDimitry Andrictemplate <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17 406d72607e9SDimitry Andrictemplate <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17 407d72607e9SDimitry Andrictemplate <class C> constexpr auto data(const C& c) -> decltype(c.data()); // C++17 408d72607e9SDimitry Andrictemplate <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // C++17 409d72607e9SDimitry Andrictemplate <class E> constexpr const E* data(initializer_list<E> il) noexcept; // C++17 410d72607e9SDimitry Andric 4117a984708SDavid Chisnall} // std 4127a984708SDavid Chisnall 4137a984708SDavid Chisnall*/ 4147a984708SDavid Chisnall 4157a984708SDavid Chisnall#include <__config> 4167c82a1ecSDimitry Andric#include <iosfwd> // for forward declarations of vector and string. 417d72607e9SDimitry Andric#include <__functional_base> 4187a984708SDavid Chisnall#include <type_traits> 4197a984708SDavid Chisnall#include <cstddef> 4204f7ab58eSDimitry Andric#include <initializer_list> 421*b5893f02SDimitry Andric#include <version> 4221bf9f7c1SDimitry Andric#ifdef __APPLE__ 423fb6c5de6SDavid Chisnall#include <Availability.h> 424fb6c5de6SDavid Chisnall#endif 425fb6c5de6SDavid Chisnall 4264f7ab58eSDimitry Andric#include <__debug> 4277a984708SDavid Chisnall 4287a984708SDavid Chisnall#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 4297a984708SDavid Chisnall#pragma GCC system_header 4307a984708SDavid Chisnall#endif 4317a984708SDavid Chisnall 4327a984708SDavid Chisnall_LIBCPP_BEGIN_NAMESPACE_STD 4337a984708SDavid Chisnall 434aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS input_iterator_tag {}; 435aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS output_iterator_tag {}; 436aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {}; 437aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {}; 438aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {}; 4397a984708SDavid Chisnall 4407a984708SDavid Chisnalltemplate <class _Tp> 441*b5893f02SDimitry Andricstruct __has_iterator_typedefs 442*b5893f02SDimitry Andric{ 443*b5893f02SDimitry Andricprivate: 444*b5893f02SDimitry Andric struct __two {char __lx; char __lxx;}; 445*b5893f02SDimitry Andric template <class _Up> static __two __test(...); 446*b5893f02SDimitry Andric template <class _Up> static char __test(typename std::__void_t<typename _Up::iterator_category>::type* = 0, 447*b5893f02SDimitry Andric typename std::__void_t<typename _Up::difference_type>::type* = 0, 448*b5893f02SDimitry Andric typename std::__void_t<typename _Up::value_type>::type* = 0, 449*b5893f02SDimitry Andric typename std::__void_t<typename _Up::reference>::type* = 0, 450*b5893f02SDimitry Andric typename std::__void_t<typename _Up::pointer>::type* = 0 451*b5893f02SDimitry Andric ); 452*b5893f02SDimitry Andricpublic: 453*b5893f02SDimitry Andric static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1; 454*b5893f02SDimitry Andric}; 455*b5893f02SDimitry Andric 456*b5893f02SDimitry Andric 457*b5893f02SDimitry Andrictemplate <class _Tp> 4587a984708SDavid Chisnallstruct __has_iterator_category 4597a984708SDavid Chisnall{ 4607a984708SDavid Chisnallprivate: 4611e0896acSDavid Chisnall struct __two {char __lx; char __lxx;}; 4627a984708SDavid Chisnall template <class _Up> static __two __test(...); 4637a984708SDavid Chisnall template <class _Up> static char __test(typename _Up::iterator_category* = 0); 4647a984708SDavid Chisnallpublic: 4657a984708SDavid Chisnall static const bool value = sizeof(__test<_Tp>(0)) == 1; 4667a984708SDavid Chisnall}; 4677a984708SDavid Chisnall 468d72607e9SDimitry Andrictemplate <class _Iter, bool> struct __iterator_traits_impl {}; 4697a984708SDavid Chisnall 4707a984708SDavid Chisnalltemplate <class _Iter> 471d72607e9SDimitry Andricstruct __iterator_traits_impl<_Iter, true> 4727a984708SDavid Chisnall{ 4737a984708SDavid Chisnall typedef typename _Iter::difference_type difference_type; 4747a984708SDavid Chisnall typedef typename _Iter::value_type value_type; 4757a984708SDavid Chisnall typedef typename _Iter::pointer pointer; 4767a984708SDavid Chisnall typedef typename _Iter::reference reference; 4777a984708SDavid Chisnall typedef typename _Iter::iterator_category iterator_category; 4787a984708SDavid Chisnall}; 4797a984708SDavid Chisnall 4807a984708SDavid Chisnalltemplate <class _Iter, bool> struct __iterator_traits {}; 4817a984708SDavid Chisnall 4827a984708SDavid Chisnalltemplate <class _Iter> 4837a984708SDavid Chisnallstruct __iterator_traits<_Iter, true> 484d72607e9SDimitry Andric : __iterator_traits_impl 4857a984708SDavid Chisnall < 4867a984708SDavid Chisnall _Iter, 4877a984708SDavid Chisnall is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value || 4887a984708SDavid Chisnall is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value 4897a984708SDavid Chisnall > 4907a984708SDavid Chisnall{}; 4917a984708SDavid Chisnall 4927a984708SDavid Chisnall// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category 4937a984708SDavid Chisnall// exists. Else iterator_traits<Iterator> will be an empty class. This is a 4947a984708SDavid Chisnall// conforming extension which allows some programs to compile and behave as 4957a984708SDavid Chisnall// the client expects instead of failing at compile time. 4967a984708SDavid Chisnall 4977a984708SDavid Chisnalltemplate <class _Iter> 498aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS iterator_traits 499*b5893f02SDimitry Andric : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {}; 5007a984708SDavid Chisnall 5017a984708SDavid Chisnalltemplate<class _Tp> 502aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> 5037a984708SDavid Chisnall{ 5047a984708SDavid Chisnall typedef ptrdiff_t difference_type; 505b2c7081bSDimitry Andric typedef typename remove_cv<_Tp>::type value_type; 5067a984708SDavid Chisnall typedef _Tp* pointer; 5077a984708SDavid Chisnall typedef _Tp& reference; 5087a984708SDavid Chisnall typedef random_access_iterator_tag iterator_category; 5097a984708SDavid Chisnall}; 5107a984708SDavid Chisnall 5117a984708SDavid Chisnalltemplate <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value> 5127a984708SDavid Chisnallstruct __has_iterator_category_convertible_to 5137a984708SDavid Chisnall : public integral_constant<bool, is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up>::value> 5147a984708SDavid Chisnall{}; 5157a984708SDavid Chisnall 5167a984708SDavid Chisnalltemplate <class _Tp, class _Up> 5177a984708SDavid Chisnallstruct __has_iterator_category_convertible_to<_Tp, _Up, false> : public false_type {}; 5187a984708SDavid Chisnall 5197a984708SDavid Chisnalltemplate <class _Tp> 5207a984708SDavid Chisnallstruct __is_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {}; 5217a984708SDavid Chisnall 5227a984708SDavid Chisnalltemplate <class _Tp> 5237a984708SDavid Chisnallstruct __is_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {}; 5247a984708SDavid Chisnall 5257a984708SDavid Chisnalltemplate <class _Tp> 5267a984708SDavid Chisnallstruct __is_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {}; 5277a984708SDavid Chisnall 5287a984708SDavid Chisnalltemplate <class _Tp> 5297a984708SDavid Chisnallstruct __is_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {}; 5307a984708SDavid Chisnall 5319729cf09SDimitry Andrictemplate <class _Tp> 5329729cf09SDimitry Andricstruct __is_exactly_input_iterator 5339729cf09SDimitry Andric : public integral_constant<bool, 5349729cf09SDimitry Andric __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value && 5359729cf09SDimitry Andric !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {}; 5369729cf09SDimitry Andric 5377a984708SDavid Chisnalltemplate<class _Category, class _Tp, class _Distance = ptrdiff_t, 5387a984708SDavid Chisnall class _Pointer = _Tp*, class _Reference = _Tp&> 539aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS iterator 5407a984708SDavid Chisnall{ 5417a984708SDavid Chisnall typedef _Tp value_type; 5427a984708SDavid Chisnall typedef _Distance difference_type; 5437a984708SDavid Chisnall typedef _Pointer pointer; 5447a984708SDavid Chisnall typedef _Reference reference; 5457a984708SDavid Chisnall typedef _Category iterator_category; 5467a984708SDavid Chisnall}; 5477a984708SDavid Chisnall 5487a984708SDavid Chisnalltemplate <class _InputIter> 54960ff8e32SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 5507a984708SDavid Chisnallvoid __advance(_InputIter& __i, 5517a984708SDavid Chisnall typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag) 5527a984708SDavid Chisnall{ 5537a984708SDavid Chisnall for (; __n > 0; --__n) 5547a984708SDavid Chisnall ++__i; 5557a984708SDavid Chisnall} 5567a984708SDavid Chisnall 5577a984708SDavid Chisnalltemplate <class _BiDirIter> 55860ff8e32SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 5597a984708SDavid Chisnallvoid __advance(_BiDirIter& __i, 5607a984708SDavid Chisnall typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) 5617a984708SDavid Chisnall{ 5627a984708SDavid Chisnall if (__n >= 0) 5637a984708SDavid Chisnall for (; __n > 0; --__n) 5647a984708SDavid Chisnall ++__i; 5657a984708SDavid Chisnall else 5667a984708SDavid Chisnall for (; __n < 0; ++__n) 5677a984708SDavid Chisnall --__i; 5687a984708SDavid Chisnall} 5697a984708SDavid Chisnall 5707a984708SDavid Chisnalltemplate <class _RandIter> 57160ff8e32SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 5727a984708SDavid Chisnallvoid __advance(_RandIter& __i, 5737a984708SDavid Chisnall typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag) 5747a984708SDavid Chisnall{ 5757a984708SDavid Chisnall __i += __n; 5767a984708SDavid Chisnall} 5777a984708SDavid Chisnall 5787a984708SDavid Chisnalltemplate <class _InputIter> 57960ff8e32SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 5807a984708SDavid Chisnallvoid advance(_InputIter& __i, 5817a984708SDavid Chisnall typename iterator_traits<_InputIter>::difference_type __n) 5827a984708SDavid Chisnall{ 5837a984708SDavid Chisnall __advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); 5847a984708SDavid Chisnall} 5857a984708SDavid Chisnall 5867a984708SDavid Chisnalltemplate <class _InputIter> 58760ff8e32SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 5887a984708SDavid Chisnalltypename iterator_traits<_InputIter>::difference_type 5897a984708SDavid Chisnall__distance(_InputIter __first, _InputIter __last, input_iterator_tag) 5907a984708SDavid Chisnall{ 5917a984708SDavid Chisnall typename iterator_traits<_InputIter>::difference_type __r(0); 5927a984708SDavid Chisnall for (; __first != __last; ++__first) 5937a984708SDavid Chisnall ++__r; 5947a984708SDavid Chisnall return __r; 5957a984708SDavid Chisnall} 5967a984708SDavid Chisnall 5977a984708SDavid Chisnalltemplate <class _RandIter> 59860ff8e32SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 5997a984708SDavid Chisnalltypename iterator_traits<_RandIter>::difference_type 6007a984708SDavid Chisnall__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag) 6017a984708SDavid Chisnall{ 6027a984708SDavid Chisnall return __last - __first; 6037a984708SDavid Chisnall} 6047a984708SDavid Chisnall 6057a984708SDavid Chisnalltemplate <class _InputIter> 60660ff8e32SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 6077a984708SDavid Chisnalltypename iterator_traits<_InputIter>::difference_type 6087a984708SDavid Chisnalldistance(_InputIter __first, _InputIter __last) 6097a984708SDavid Chisnall{ 6107a984708SDavid Chisnall return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); 6117a984708SDavid Chisnall} 6127a984708SDavid Chisnall 6139729cf09SDimitry Andrictemplate <class _InputIter> 61460ff8e32SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 615b2c7081bSDimitry Andrictypename enable_if 616b2c7081bSDimitry Andric< 617b2c7081bSDimitry Andric __is_input_iterator<_InputIter>::value, 6189729cf09SDimitry Andric _InputIter 619b2c7081bSDimitry Andric>::type 6209729cf09SDimitry Andricnext(_InputIter __x, 621b2c7081bSDimitry Andric typename iterator_traits<_InputIter>::difference_type __n = 1) 6227a984708SDavid Chisnall{ 6237a984708SDavid Chisnall _VSTD::advance(__x, __n); 6247a984708SDavid Chisnall return __x; 6257a984708SDavid Chisnall} 6267a984708SDavid Chisnall 627b2c7081bSDimitry Andrictemplate <class _BidirectionalIter> 62860ff8e32SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 629b2c7081bSDimitry Andrictypename enable_if 630b2c7081bSDimitry Andric< 631b2c7081bSDimitry Andric __is_bidirectional_iterator<_BidirectionalIter>::value, 632b2c7081bSDimitry Andric _BidirectionalIter 633b2c7081bSDimitry Andric>::type 634b2c7081bSDimitry Andricprev(_BidirectionalIter __x, 635b2c7081bSDimitry Andric typename iterator_traits<_BidirectionalIter>::difference_type __n = 1) 6367a984708SDavid Chisnall{ 6377a984708SDavid Chisnall _VSTD::advance(__x, -__n); 6387a984708SDavid Chisnall return __x; 6397a984708SDavid Chisnall} 6407a984708SDavid Chisnall 641540d2a8bSDimitry Andric 642540d2a8bSDimitry Andrictemplate <class _Tp, class = void> 643540d2a8bSDimitry Andricstruct __is_stashing_iterator : false_type {}; 644540d2a8bSDimitry Andric 645540d2a8bSDimitry Andrictemplate <class _Tp> 646540d2a8bSDimitry Andricstruct __is_stashing_iterator<_Tp, typename __void_t<typename _Tp::__stashing_iterator_tag>::type> 647540d2a8bSDimitry Andric : true_type {}; 648540d2a8bSDimitry Andric 6497a984708SDavid Chisnalltemplate <class _Iter> 650aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS reverse_iterator 6517a984708SDavid Chisnall : public iterator<typename iterator_traits<_Iter>::iterator_category, 6527a984708SDavid Chisnall typename iterator_traits<_Iter>::value_type, 6537a984708SDavid Chisnall typename iterator_traits<_Iter>::difference_type, 6547a984708SDavid Chisnall typename iterator_traits<_Iter>::pointer, 6557a984708SDavid Chisnall typename iterator_traits<_Iter>::reference> 6567a984708SDavid Chisnall{ 6577a984708SDavid Chisnallprivate: 658aed8d94eSDimitry Andric /*mutable*/ _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break 659540d2a8bSDimitry Andric 660540d2a8bSDimitry Andric static_assert(!__is_stashing_iterator<_Iter>::value, 661540d2a8bSDimitry Andric "The specified iterator type cannot be used with reverse_iterator; " 662540d2a8bSDimitry Andric "Using stashing iterators with reverse_iterator causes undefined behavior"); 663540d2a8bSDimitry Andric 6647a984708SDavid Chisnallprotected: 6657a984708SDavid Chisnall _Iter current; 6667a984708SDavid Chisnallpublic: 6677a984708SDavid Chisnall typedef _Iter iterator_type; 6687a984708SDavid Chisnall typedef typename iterator_traits<_Iter>::difference_type difference_type; 6697a984708SDavid Chisnall typedef typename iterator_traits<_Iter>::reference reference; 6707a984708SDavid Chisnall typedef typename iterator_traits<_Iter>::pointer pointer; 6717a984708SDavid Chisnall 672aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 673aed8d94eSDimitry Andric reverse_iterator() : __t(), current() {} 674aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 675aed8d94eSDimitry Andric explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {} 676aed8d94eSDimitry Andric template <class _Up> 677aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 678aed8d94eSDimitry Andric reverse_iterator(const reverse_iterator<_Up>& __u) : __t(__u.base()), current(__u.base()) {} 679aed8d94eSDimitry Andric template <class _Up> 680aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 681aed8d94eSDimitry Andric reverse_iterator& operator=(const reverse_iterator<_Up>& __u) 682aed8d94eSDimitry Andric { __t = current = __u.base(); return *this; } 683aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 684aed8d94eSDimitry Andric _Iter base() const {return current;} 685aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 686aed8d94eSDimitry Andric reference operator*() const {_Iter __tmp = current; return *--__tmp;} 687aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 688aed8d94eSDimitry Andric pointer operator->() const {return _VSTD::addressof(operator*());} 689aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 690aed8d94eSDimitry Andric reverse_iterator& operator++() {--current; return *this;} 691aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 692aed8d94eSDimitry Andric reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;} 693aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 694aed8d94eSDimitry Andric reverse_iterator& operator--() {++current; return *this;} 695aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 696aed8d94eSDimitry Andric reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;} 697aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 698aed8d94eSDimitry Andric reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);} 699aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 700aed8d94eSDimitry Andric reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;} 701aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 702aed8d94eSDimitry Andric reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);} 703aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 704aed8d94eSDimitry Andric reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;} 705aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 706aed8d94eSDimitry Andric reference operator[](difference_type __n) const {return *(*this + __n);} 7077a984708SDavid Chisnall}; 7087a984708SDavid Chisnall 7097a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 710aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7117a984708SDavid Chisnallbool 7127a984708SDavid Chisnalloperator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7137a984708SDavid Chisnall{ 7147a984708SDavid Chisnall return __x.base() == __y.base(); 7157a984708SDavid Chisnall} 7167a984708SDavid Chisnall 7177a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 718aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7197a984708SDavid Chisnallbool 7207a984708SDavid Chisnalloperator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7217a984708SDavid Chisnall{ 7227a984708SDavid Chisnall return __x.base() > __y.base(); 7237a984708SDavid Chisnall} 7247a984708SDavid Chisnall 7257a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 726aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7277a984708SDavid Chisnallbool 7287a984708SDavid Chisnalloperator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7297a984708SDavid Chisnall{ 7307a984708SDavid Chisnall return __x.base() != __y.base(); 7317a984708SDavid Chisnall} 7327a984708SDavid Chisnall 7337a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 734aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7357a984708SDavid Chisnallbool 7367a984708SDavid Chisnalloperator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7377a984708SDavid Chisnall{ 7387a984708SDavid Chisnall return __x.base() < __y.base(); 7397a984708SDavid Chisnall} 7407a984708SDavid Chisnall 7417a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 742aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7437a984708SDavid Chisnallbool 7447a984708SDavid Chisnalloperator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7457a984708SDavid Chisnall{ 7467a984708SDavid Chisnall return __x.base() <= __y.base(); 7477a984708SDavid Chisnall} 7487a984708SDavid Chisnall 7497a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 750aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7517a984708SDavid Chisnallbool 7527a984708SDavid Chisnalloperator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7537a984708SDavid Chisnall{ 7547a984708SDavid Chisnall return __x.base() >= __y.base(); 7557a984708SDavid Chisnall} 7567a984708SDavid Chisnall 7577c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 7587c82a1ecSDimitry Andrictemplate <class _Iter1, class _Iter2> 759aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7607c82a1ecSDimitry Andricauto 7617c82a1ecSDimitry Andricoperator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7627c82a1ecSDimitry Andric-> decltype(__y.base() - __x.base()) 7637c82a1ecSDimitry Andric{ 7647c82a1ecSDimitry Andric return __y.base() - __x.base(); 7657c82a1ecSDimitry Andric} 7667c82a1ecSDimitry Andric#else 7677a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 7687a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7697a984708SDavid Chisnalltypename reverse_iterator<_Iter1>::difference_type 7707a984708SDavid Chisnalloperator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) 7717a984708SDavid Chisnall{ 7727a984708SDavid Chisnall return __y.base() - __x.base(); 7737a984708SDavid Chisnall} 7747c82a1ecSDimitry Andric#endif 7757a984708SDavid Chisnall 7767a984708SDavid Chisnalltemplate <class _Iter> 777aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 7787a984708SDavid Chisnallreverse_iterator<_Iter> 7797a984708SDavid Chisnalloperator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x) 7807a984708SDavid Chisnall{ 7817a984708SDavid Chisnall return reverse_iterator<_Iter>(__x.base() - __n); 7827a984708SDavid Chisnall} 7837a984708SDavid Chisnall 784d72607e9SDimitry Andric#if _LIBCPP_STD_VER > 11 785d72607e9SDimitry Andrictemplate <class _Iter> 786aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 787d72607e9SDimitry Andricreverse_iterator<_Iter> make_reverse_iterator(_Iter __i) 788d72607e9SDimitry Andric{ 789d72607e9SDimitry Andric return reverse_iterator<_Iter>(__i); 790d72607e9SDimitry Andric} 791d72607e9SDimitry Andric#endif 792d72607e9SDimitry Andric 7937a984708SDavid Chisnalltemplate <class _Container> 794aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS back_insert_iterator 7957a984708SDavid Chisnall : public iterator<output_iterator_tag, 7967a984708SDavid Chisnall void, 7977a984708SDavid Chisnall void, 7987a984708SDavid Chisnall void, 7997c82a1ecSDimitry Andric void> 8007a984708SDavid Chisnall{ 8017a984708SDavid Chisnallprotected: 8027a984708SDavid Chisnall _Container* container; 8037a984708SDavid Chisnallpublic: 8047a984708SDavid Chisnall typedef _Container container_type; 8057a984708SDavid Chisnall 806d72607e9SDimitry Andric _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} 8077a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_) 8087a984708SDavid Chisnall {container->push_back(__value_); return *this;} 809540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8107a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value_) 8117a984708SDavid Chisnall {container->push_back(_VSTD::move(__value_)); return *this;} 812540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 8137a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator*() {return *this;} 8147a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++() {return *this;} 8157a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY back_insert_iterator operator++(int) {return *this;} 8167a984708SDavid Chisnall}; 8177a984708SDavid Chisnall 8187a984708SDavid Chisnalltemplate <class _Container> 8197a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8207a984708SDavid Chisnallback_insert_iterator<_Container> 8217a984708SDavid Chisnallback_inserter(_Container& __x) 8227a984708SDavid Chisnall{ 8237a984708SDavid Chisnall return back_insert_iterator<_Container>(__x); 8247a984708SDavid Chisnall} 8257a984708SDavid Chisnall 8267a984708SDavid Chisnalltemplate <class _Container> 827aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS front_insert_iterator 8287a984708SDavid Chisnall : public iterator<output_iterator_tag, 8297a984708SDavid Chisnall void, 8307a984708SDavid Chisnall void, 8317a984708SDavid Chisnall void, 8327c82a1ecSDimitry Andric void> 8337a984708SDavid Chisnall{ 8347a984708SDavid Chisnallprotected: 8357a984708SDavid Chisnall _Container* container; 8367a984708SDavid Chisnallpublic: 8377a984708SDavid Chisnall typedef _Container container_type; 8387a984708SDavid Chisnall 839d72607e9SDimitry Andric _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} 8407a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_) 8417a984708SDavid Chisnall {container->push_front(__value_); return *this;} 842540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8437a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value_) 8447a984708SDavid Chisnall {container->push_front(_VSTD::move(__value_)); return *this;} 845540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 8467a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator*() {return *this;} 8477a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator++() {return *this;} 8487a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY front_insert_iterator operator++(int) {return *this;} 8497a984708SDavid Chisnall}; 8507a984708SDavid Chisnall 8517a984708SDavid Chisnalltemplate <class _Container> 8527a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8537a984708SDavid Chisnallfront_insert_iterator<_Container> 8547a984708SDavid Chisnallfront_inserter(_Container& __x) 8557a984708SDavid Chisnall{ 8567a984708SDavid Chisnall return front_insert_iterator<_Container>(__x); 8577a984708SDavid Chisnall} 8587a984708SDavid Chisnall 8597a984708SDavid Chisnalltemplate <class _Container> 860aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS insert_iterator 8617a984708SDavid Chisnall : public iterator<output_iterator_tag, 8627a984708SDavid Chisnall void, 8637a984708SDavid Chisnall void, 8647a984708SDavid Chisnall void, 8657c82a1ecSDimitry Andric void> 8667a984708SDavid Chisnall{ 8677a984708SDavid Chisnallprotected: 8687a984708SDavid Chisnall _Container* container; 8697a984708SDavid Chisnall typename _Container::iterator iter; 8707a984708SDavid Chisnallpublic: 8717a984708SDavid Chisnall typedef _Container container_type; 8727a984708SDavid Chisnall 8737a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i) 874d72607e9SDimitry Andric : container(_VSTD::addressof(__x)), iter(__i) {} 8757a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_) 8767a984708SDavid Chisnall {iter = container->insert(iter, __value_); ++iter; return *this;} 877540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8787a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value_) 8797a984708SDavid Chisnall {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;} 880540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 8817a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY insert_iterator& operator*() {return *this;} 8827a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++() {return *this;} 8837a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++(int) {return *this;} 8847a984708SDavid Chisnall}; 8857a984708SDavid Chisnall 8867a984708SDavid Chisnalltemplate <class _Container> 8877a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8887a984708SDavid Chisnallinsert_iterator<_Container> 8897a984708SDavid Chisnallinserter(_Container& __x, typename _Container::iterator __i) 8907a984708SDavid Chisnall{ 8917a984708SDavid Chisnall return insert_iterator<_Container>(__x, __i); 8927a984708SDavid Chisnall} 8937a984708SDavid Chisnall 8947a984708SDavid Chisnalltemplate <class _Tp, class _CharT = char, 8957a984708SDavid Chisnall class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t> 896aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS istream_iterator 8977a984708SDavid Chisnall : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&> 8987a984708SDavid Chisnall{ 8997a984708SDavid Chisnallpublic: 9007a984708SDavid Chisnall typedef _CharT char_type; 9017a984708SDavid Chisnall typedef _Traits traits_type; 9027a984708SDavid Chisnall typedef basic_istream<_CharT,_Traits> istream_type; 9037a984708SDavid Chisnallprivate: 9047a984708SDavid Chisnall istream_type* __in_stream_; 9057a984708SDavid Chisnall _Tp __value_; 9067a984708SDavid Chisnallpublic: 907854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {} 9087c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s)) 9097a984708SDavid Chisnall { 9107a984708SDavid Chisnall if (!(*__in_stream_ >> __value_)) 9117a984708SDavid Chisnall __in_stream_ = 0; 9127a984708SDavid Chisnall } 9137a984708SDavid Chisnall 9147a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;} 9157c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return _VSTD::addressof((operator*()));} 9167a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++() 9177a984708SDavid Chisnall { 9187a984708SDavid Chisnall if (!(*__in_stream_ >> __value_)) 9197a984708SDavid Chisnall __in_stream_ = 0; 9207a984708SDavid Chisnall return *this; 9217a984708SDavid Chisnall } 9227a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int) 9237a984708SDavid Chisnall {istream_iterator __t(*this); ++(*this); return __t;} 9247a984708SDavid Chisnall 925b2c7081bSDimitry Andric template <class _Up, class _CharU, class _TraitsU, class _DistanceU> 9267a984708SDavid Chisnall friend _LIBCPP_INLINE_VISIBILITY 927b2c7081bSDimitry Andric bool 928b2c7081bSDimitry Andric operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, 929b2c7081bSDimitry Andric const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); 9307a984708SDavid Chisnall 931b2c7081bSDimitry Andric template <class _Up, class _CharU, class _TraitsU, class _DistanceU> 9327a984708SDavid Chisnall friend _LIBCPP_INLINE_VISIBILITY 933b2c7081bSDimitry Andric bool 934b2c7081bSDimitry Andric operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, 935b2c7081bSDimitry Andric const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); 9367a984708SDavid Chisnall}; 9377a984708SDavid Chisnall 938b2c7081bSDimitry Andrictemplate <class _Tp, class _CharT, class _Traits, class _Distance> 939b2c7081bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 940b2c7081bSDimitry Andricbool 941b2c7081bSDimitry Andricoperator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, 942b2c7081bSDimitry Andric const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) 943b2c7081bSDimitry Andric{ 944b2c7081bSDimitry Andric return __x.__in_stream_ == __y.__in_stream_; 945b2c7081bSDimitry Andric} 946b2c7081bSDimitry Andric 947b2c7081bSDimitry Andrictemplate <class _Tp, class _CharT, class _Traits, class _Distance> 948b2c7081bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 949b2c7081bSDimitry Andricbool 950b2c7081bSDimitry Andricoperator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, 951b2c7081bSDimitry Andric const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) 952b2c7081bSDimitry Andric{ 953b2c7081bSDimitry Andric return !(__x == __y); 954b2c7081bSDimitry Andric} 955b2c7081bSDimitry Andric 9567a984708SDavid Chisnalltemplate <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> > 957aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS ostream_iterator 9587a984708SDavid Chisnall : public iterator<output_iterator_tag, void, void, void, void> 9597a984708SDavid Chisnall{ 9607a984708SDavid Chisnallpublic: 9617a984708SDavid Chisnall typedef _CharT char_type; 9627a984708SDavid Chisnall typedef _Traits traits_type; 9637a984708SDavid Chisnall typedef basic_ostream<_CharT,_Traits> ostream_type; 9647a984708SDavid Chisnallprivate: 9657a984708SDavid Chisnall ostream_type* __out_stream_; 9667a984708SDavid Chisnall const char_type* __delim_; 9677a984708SDavid Chisnallpublic: 968aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT 9697c82a1ecSDimitry Andric : __out_stream_(_VSTD::addressof(__s)), __delim_(0) {} 970aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT 9717c82a1ecSDimitry Andric : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {} 9727a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_) 9737a984708SDavid Chisnall { 9747a984708SDavid Chisnall *__out_stream_ << __value_; 9757a984708SDavid Chisnall if (__delim_) 9767a984708SDavid Chisnall *__out_stream_ << __delim_; 9777a984708SDavid Chisnall return *this; 9787a984708SDavid Chisnall } 9797a984708SDavid Chisnall 9807a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*() {return *this;} 9817a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++() {return *this;} 9827a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;} 9837a984708SDavid Chisnall}; 9847a984708SDavid Chisnall 9857a984708SDavid Chisnalltemplate<class _CharT, class _Traits> 986aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS istreambuf_iterator 9877a984708SDavid Chisnall : public iterator<input_iterator_tag, _CharT, 9887a984708SDavid Chisnall typename _Traits::off_type, _CharT*, 9897a984708SDavid Chisnall _CharT> 9907a984708SDavid Chisnall{ 9917a984708SDavid Chisnallpublic: 9927a984708SDavid Chisnall typedef _CharT char_type; 9937a984708SDavid Chisnall typedef _Traits traits_type; 9947a984708SDavid Chisnall typedef typename _Traits::int_type int_type; 9957a984708SDavid Chisnall typedef basic_streambuf<_CharT,_Traits> streambuf_type; 9967a984708SDavid Chisnall typedef basic_istream<_CharT,_Traits> istream_type; 9977a984708SDavid Chisnallprivate: 998fb6c5de6SDavid Chisnall mutable streambuf_type* __sbuf_; 9997a984708SDavid Chisnall 10007a984708SDavid Chisnall class __proxy 10017a984708SDavid Chisnall { 10027a984708SDavid Chisnall char_type __keep_; 10037a984708SDavid Chisnall streambuf_type* __sbuf_; 10047a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s) 10057a984708SDavid Chisnall : __keep_(__c), __sbuf_(__s) {} 10067a984708SDavid Chisnall friend class istreambuf_iterator; 10077a984708SDavid Chisnall public: 10087a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY char_type operator*() const {return __keep_;} 10097a984708SDavid Chisnall }; 10107a984708SDavid Chisnall 10117a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 1012fb6c5de6SDavid Chisnall bool __test_for_eof() const 10137a984708SDavid Chisnall { 10147a984708SDavid Chisnall if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof())) 10157a984708SDavid Chisnall __sbuf_ = 0; 1016fb6c5de6SDavid Chisnall return __sbuf_ == 0; 10177a984708SDavid Chisnall } 10187a984708SDavid Chisnallpublic: 1019fb6c5de6SDavid Chisnall _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(0) {} 1020936e9439SDimitry Andric _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT 1021cfdf2879SDavid Chisnall : __sbuf_(__s.rdbuf()) {} 1022936e9439SDimitry Andric _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT 1023cfdf2879SDavid Chisnall : __sbuf_(__s) {} 1024936e9439SDimitry Andric _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT 10257a984708SDavid Chisnall : __sbuf_(__p.__sbuf_) {} 10267a984708SDavid Chisnall 102794e3ee44SDavid Chisnall _LIBCPP_INLINE_VISIBILITY char_type operator*() const 102894e3ee44SDavid Chisnall {return static_cast<char_type>(__sbuf_->sgetc());} 10297a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++() 10307a984708SDavid Chisnall { 1031fb6c5de6SDavid Chisnall __sbuf_->sbumpc(); 10327a984708SDavid Chisnall return *this; 10337a984708SDavid Chisnall } 10347a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY __proxy operator++(int) 10357a984708SDavid Chisnall { 1036fb6c5de6SDavid Chisnall return __proxy(__sbuf_->sbumpc(), __sbuf_); 10377a984708SDavid Chisnall } 10387a984708SDavid Chisnall 10397a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const 1040fb6c5de6SDavid Chisnall {return __test_for_eof() == __b.__test_for_eof();} 10417a984708SDavid Chisnall}; 10427a984708SDavid Chisnall 10437a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 10447a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 10457a984708SDavid Chisnallbool operator==(const istreambuf_iterator<_CharT,_Traits>& __a, 10467a984708SDavid Chisnall const istreambuf_iterator<_CharT,_Traits>& __b) 10477a984708SDavid Chisnall {return __a.equal(__b);} 10487a984708SDavid Chisnall 10497a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 10507a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 10517a984708SDavid Chisnallbool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, 10527a984708SDavid Chisnall const istreambuf_iterator<_CharT,_Traits>& __b) 10537a984708SDavid Chisnall {return !__a.equal(__b);} 10547a984708SDavid Chisnall 10557a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 1056aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS ostreambuf_iterator 10577a984708SDavid Chisnall : public iterator<output_iterator_tag, void, void, void, void> 10587a984708SDavid Chisnall{ 10597a984708SDavid Chisnallpublic: 10607a984708SDavid Chisnall typedef _CharT char_type; 10617a984708SDavid Chisnall typedef _Traits traits_type; 10627a984708SDavid Chisnall typedef basic_streambuf<_CharT,_Traits> streambuf_type; 10637a984708SDavid Chisnall typedef basic_ostream<_CharT,_Traits> ostream_type; 10647a984708SDavid Chisnallprivate: 10657a984708SDavid Chisnall streambuf_type* __sbuf_; 10667a984708SDavid Chisnallpublic: 1067936e9439SDimitry Andric _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT 10687a984708SDavid Chisnall : __sbuf_(__s.rdbuf()) {} 1069936e9439SDimitry Andric _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT 10707a984708SDavid Chisnall : __sbuf_(__s) {} 10717a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c) 10727a984708SDavid Chisnall { 10737a984708SDavid Chisnall if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof())) 10747a984708SDavid Chisnall __sbuf_ = 0; 10757a984708SDavid Chisnall return *this; 10767a984708SDavid Chisnall } 10777a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;} 10787a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;} 10797a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;} 1080936e9439SDimitry Andric _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == 0;} 1081936e9439SDimitry Andric 1082fb6c5de6SDavid Chisnall#if !defined(__APPLE__) || \ 1083fb6c5de6SDavid Chisnall (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_8) || \ 1084fb6c5de6SDavid Chisnall (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0) 1085fb6c5de6SDavid Chisnall 1086936e9439SDimitry Andric template <class _Ch, class _Tr> 1087936e9439SDimitry Andric friend 1088936e9439SDimitry Andric _LIBCPP_HIDDEN 1089936e9439SDimitry Andric ostreambuf_iterator<_Ch, _Tr> 1090936e9439SDimitry Andric __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s, 1091936e9439SDimitry Andric const _Ch* __ob, const _Ch* __op, const _Ch* __oe, 1092936e9439SDimitry Andric ios_base& __iob, _Ch __fl); 1093fb6c5de6SDavid Chisnall#endif 10947a984708SDavid Chisnall}; 10957a984708SDavid Chisnall 10967a984708SDavid Chisnalltemplate <class _Iter> 1097aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS move_iterator 10987a984708SDavid Chisnall{ 10997a984708SDavid Chisnallprivate: 11007a984708SDavid Chisnall _Iter __i; 11017a984708SDavid Chisnallpublic: 11027a984708SDavid Chisnall typedef _Iter iterator_type; 11037a984708SDavid Chisnall typedef typename iterator_traits<iterator_type>::iterator_category iterator_category; 11047a984708SDavid Chisnall typedef typename iterator_traits<iterator_type>::value_type value_type; 11057a984708SDavid Chisnall typedef typename iterator_traits<iterator_type>::difference_type difference_type; 11067c82a1ecSDimitry Andric typedef iterator_type pointer; 1107540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 11087c82a1ecSDimitry Andric typedef typename iterator_traits<iterator_type>::reference __reference; 11097c82a1ecSDimitry Andric typedef typename conditional< 11107c82a1ecSDimitry Andric is_reference<__reference>::value, 11117c82a1ecSDimitry Andric typename remove_reference<__reference>::type&&, 11127c82a1ecSDimitry Andric __reference 11137c82a1ecSDimitry Andric >::type reference; 11147a984708SDavid Chisnall#else 11157a984708SDavid Chisnall typedef typename iterator_traits<iterator_type>::reference reference; 11167a984708SDavid Chisnall#endif 11177a984708SDavid Chisnall 1118aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1119aed8d94eSDimitry Andric move_iterator() : __i() {} 1120aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1121aed8d94eSDimitry Andric explicit move_iterator(_Iter __x) : __i(__x) {} 1122aed8d94eSDimitry Andric template <class _Up> 1123aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1124aed8d94eSDimitry Andric move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {} 1125aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;} 1126aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1127aed8d94eSDimitry Andric reference operator*() const { return static_cast<reference>(*__i); } 1128aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1129aed8d94eSDimitry Andric pointer operator->() const { return __i;} 1130aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1131aed8d94eSDimitry Andric move_iterator& operator++() {++__i; return *this;} 1132aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1133aed8d94eSDimitry Andric move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;} 1134aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1135aed8d94eSDimitry Andric move_iterator& operator--() {--__i; return *this;} 1136aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1137aed8d94eSDimitry Andric move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;} 1138aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1139aed8d94eSDimitry Andric move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);} 1140aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1141aed8d94eSDimitry Andric move_iterator& operator+=(difference_type __n) {__i += __n; return *this;} 1142aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1143aed8d94eSDimitry Andric move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);} 1144aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1145aed8d94eSDimitry Andric move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;} 1146aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1147aed8d94eSDimitry Andric reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); } 11487a984708SDavid Chisnall}; 11497a984708SDavid Chisnall 11507a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 1151aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 11527a984708SDavid Chisnallbool 11537a984708SDavid Chisnalloperator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 11547a984708SDavid Chisnall{ 11557a984708SDavid Chisnall return __x.base() == __y.base(); 11567a984708SDavid Chisnall} 11577a984708SDavid Chisnall 11587a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 1159aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 11607a984708SDavid Chisnallbool 11617a984708SDavid Chisnalloperator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 11627a984708SDavid Chisnall{ 11637a984708SDavid Chisnall return __x.base() < __y.base(); 11647a984708SDavid Chisnall} 11657a984708SDavid Chisnall 11667a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 1167aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 11687a984708SDavid Chisnallbool 11697a984708SDavid Chisnalloperator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 11707a984708SDavid Chisnall{ 11717a984708SDavid Chisnall return __x.base() != __y.base(); 11727a984708SDavid Chisnall} 11737a984708SDavid Chisnall 11747a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 1175aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 11767a984708SDavid Chisnallbool 11777a984708SDavid Chisnalloperator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 11787a984708SDavid Chisnall{ 11797a984708SDavid Chisnall return __x.base() > __y.base(); 11807a984708SDavid Chisnall} 11817a984708SDavid Chisnall 11827a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 1183aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 11847a984708SDavid Chisnallbool 11857a984708SDavid Chisnalloperator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 11867a984708SDavid Chisnall{ 11877a984708SDavid Chisnall return __x.base() >= __y.base(); 11887a984708SDavid Chisnall} 11897a984708SDavid Chisnall 11907a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 1191aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 11927a984708SDavid Chisnallbool 11937a984708SDavid Chisnalloperator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 11947a984708SDavid Chisnall{ 11957a984708SDavid Chisnall return __x.base() <= __y.base(); 11967a984708SDavid Chisnall} 11977a984708SDavid Chisnall 11987c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 11997c82a1ecSDimitry Andrictemplate <class _Iter1, class _Iter2> 1200aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 12017c82a1ecSDimitry Andricauto 12027c82a1ecSDimitry Andricoperator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 12037c82a1ecSDimitry Andric-> decltype(__x.base() - __y.base()) 12047c82a1ecSDimitry Andric{ 12057c82a1ecSDimitry Andric return __x.base() - __y.base(); 12067c82a1ecSDimitry Andric} 12077c82a1ecSDimitry Andric#else 12087a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 12097a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 12107a984708SDavid Chisnalltypename move_iterator<_Iter1>::difference_type 12117a984708SDavid Chisnalloperator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) 12127a984708SDavid Chisnall{ 12137a984708SDavid Chisnall return __x.base() - __y.base(); 12147a984708SDavid Chisnall} 12157c82a1ecSDimitry Andric#endif 12167a984708SDavid Chisnall 12177a984708SDavid Chisnalltemplate <class _Iter> 1218aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 12197a984708SDavid Chisnallmove_iterator<_Iter> 12207a984708SDavid Chisnalloperator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) 12217a984708SDavid Chisnall{ 12227a984708SDavid Chisnall return move_iterator<_Iter>(__x.base() + __n); 12237a984708SDavid Chisnall} 12247a984708SDavid Chisnall 12257a984708SDavid Chisnalltemplate <class _Iter> 1226aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 12277a984708SDavid Chisnallmove_iterator<_Iter> 12284f7ab58eSDimitry Andricmake_move_iterator(_Iter __i) 12297a984708SDavid Chisnall{ 12307a984708SDavid Chisnall return move_iterator<_Iter>(__i); 12317a984708SDavid Chisnall} 12327a984708SDavid Chisnall 12337a984708SDavid Chisnall// __wrap_iter 12347a984708SDavid Chisnall 12357a984708SDavid Chisnalltemplate <class _Iter> class __wrap_iter; 12367a984708SDavid Chisnall 12377a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 12384ba319b5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 12397a984708SDavid Chisnallbool 1240aed8d94eSDimitry Andricoperator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 12417a984708SDavid Chisnall 12427a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 12434ba319b5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 12447a984708SDavid Chisnallbool 1245aed8d94eSDimitry Andricoperator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 12467a984708SDavid Chisnall 12477a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 12484ba319b5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 12497a984708SDavid Chisnallbool 1250aed8d94eSDimitry Andricoperator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 12517a984708SDavid Chisnall 12527a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 12534ba319b5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 12547a984708SDavid Chisnallbool 1255aed8d94eSDimitry Andricoperator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 12567a984708SDavid Chisnall 12577a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 12584ba319b5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 12597a984708SDavid Chisnallbool 1260aed8d94eSDimitry Andricoperator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 12617a984708SDavid Chisnall 12627a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 12634ba319b5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 12647a984708SDavid Chisnallbool 1265aed8d94eSDimitry Andricoperator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 12667a984708SDavid Chisnall 12677c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 12687c82a1ecSDimitry Andrictemplate <class _Iter1, class _Iter2> 12694ba319b5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 12707c82a1ecSDimitry Andricauto 1271aed8d94eSDimitry Andricoperator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG 12727c82a1ecSDimitry Andric-> decltype(__x.base() - __y.base()); 12737c82a1ecSDimitry Andric#else 12747a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 1275936e9439SDimitry Andric_LIBCPP_INLINE_VISIBILITY 12767a984708SDavid Chisnalltypename __wrap_iter<_Iter1>::difference_type 1277aed8d94eSDimitry Andricoperator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 12787c82a1ecSDimitry Andric#endif 12797a984708SDavid Chisnall 12807a984708SDavid Chisnalltemplate <class _Iter> 12814ba319b5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 12827a984708SDavid Chisnall__wrap_iter<_Iter> 1283aed8d94eSDimitry Andricoperator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT_DEBUG; 12847a984708SDavid Chisnall 1285936e9439SDimitry Andrictemplate <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY copy(_Ip, _Ip, _Op); 1286936e9439SDimitry Andrictemplate <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY copy_backward(_B1, _B1, _B2); 1287936e9439SDimitry Andrictemplate <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY move(_Ip, _Ip, _Op); 1288936e9439SDimitry Andrictemplate <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY move_backward(_B1, _B1, _B2); 12897a984708SDavid Chisnall 1290aed8d94eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL < 2 1291aed8d94eSDimitry Andric 12927a984708SDavid Chisnalltemplate <class _Tp> 12934ba319b5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 12947a984708SDavid Chisnalltypename enable_if 12957a984708SDavid Chisnall< 12967a984708SDavid Chisnall is_trivially_copy_assignable<_Tp>::value, 12977a984708SDavid Chisnall _Tp* 12987a984708SDavid Chisnall>::type 12997a984708SDavid Chisnall__unwrap_iter(__wrap_iter<_Tp*>); 13007a984708SDavid Chisnall 1301aed8d94eSDimitry Andric#else 1302aed8d94eSDimitry Andric 1303aed8d94eSDimitry Andrictemplate <class _Tp> 13044ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1305aed8d94eSDimitry Andrictypename enable_if 1306aed8d94eSDimitry Andric< 1307aed8d94eSDimitry Andric is_trivially_copy_assignable<_Tp>::value, 1308aed8d94eSDimitry Andric __wrap_iter<_Tp*> 1309aed8d94eSDimitry Andric>::type 1310aed8d94eSDimitry Andric__unwrap_iter(__wrap_iter<_Tp*> __i); 1311aed8d94eSDimitry Andric 1312aed8d94eSDimitry Andric#endif 1313aed8d94eSDimitry Andric 13147a984708SDavid Chisnalltemplate <class _Iter> 13157a984708SDavid Chisnallclass __wrap_iter 13167a984708SDavid Chisnall{ 13177a984708SDavid Chisnallpublic: 13187a984708SDavid Chisnall typedef _Iter iterator_type; 13197a984708SDavid Chisnall typedef typename iterator_traits<iterator_type>::iterator_category iterator_category; 13207a984708SDavid Chisnall typedef typename iterator_traits<iterator_type>::value_type value_type; 13217a984708SDavid Chisnall typedef typename iterator_traits<iterator_type>::difference_type difference_type; 13227a984708SDavid Chisnall typedef typename iterator_traits<iterator_type>::pointer pointer; 13237a984708SDavid Chisnall typedef typename iterator_traits<iterator_type>::reference reference; 13247a984708SDavid Chisnallprivate: 13257a984708SDavid Chisnall iterator_type __i; 13267a984708SDavid Chisnallpublic: 13274ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT_DEBUG 13284f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 13294f7ab58eSDimitry Andric : __i{} 13304f7ab58eSDimitry Andric#endif 13317a984708SDavid Chisnall { 13327a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 13337a984708SDavid Chisnall __get_db()->__insert_i(this); 13347a984708SDavid Chisnall#endif 13357a984708SDavid Chisnall } 13364ba319b5SDimitry Andric template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 13374ba319b5SDimitry Andric __wrap_iter(const __wrap_iter<_Up>& __u, 1338aed8d94eSDimitry Andric typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) _NOEXCEPT_DEBUG 13397a984708SDavid Chisnall : __i(__u.base()) 13407a984708SDavid Chisnall { 13417a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 13427a984708SDavid Chisnall __get_db()->__iterator_copy(this, &__u); 13437a984708SDavid Chisnall#endif 13447a984708SDavid Chisnall } 13457a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 13464ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 13477a984708SDavid Chisnall __wrap_iter(const __wrap_iter& __x) 13487a984708SDavid Chisnall : __i(__x.base()) 13497a984708SDavid Chisnall { 13507a984708SDavid Chisnall __get_db()->__iterator_copy(this, &__x); 13517a984708SDavid Chisnall } 13524ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 13537a984708SDavid Chisnall __wrap_iter& operator=(const __wrap_iter& __x) 13547a984708SDavid Chisnall { 13557a984708SDavid Chisnall if (this != &__x) 13567a984708SDavid Chisnall { 13577a984708SDavid Chisnall __get_db()->__iterator_copy(this, &__x); 13587a984708SDavid Chisnall __i = __x.__i; 13597a984708SDavid Chisnall } 13607a984708SDavid Chisnall return *this; 13617a984708SDavid Chisnall } 13624ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 13637a984708SDavid Chisnall ~__wrap_iter() 13647a984708SDavid Chisnall { 13657a984708SDavid Chisnall __get_db()->__erase_i(this); 13667a984708SDavid Chisnall } 13677a984708SDavid Chisnall#endif 13684ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT_DEBUG 13697a984708SDavid Chisnall { 13707a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 13717a984708SDavid Chisnall _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), 13727a984708SDavid Chisnall "Attempted to dereference a non-dereferenceable iterator"); 13737a984708SDavid Chisnall#endif 13747a984708SDavid Chisnall return *__i; 13757a984708SDavid Chisnall } 13764ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT_DEBUG 13774bab9fd9SDavid Chisnall { 13784bab9fd9SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 13794bab9fd9SDavid Chisnall _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), 13804bab9fd9SDavid Chisnall "Attempted to dereference a non-dereferenceable iterator"); 13814bab9fd9SDavid Chisnall#endif 13827c82a1ecSDimitry Andric return (pointer)_VSTD::addressof(*__i); 13834bab9fd9SDavid Chisnall } 13844ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT_DEBUG 13857a984708SDavid Chisnall { 13867a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 13877a984708SDavid Chisnall _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), 13887a984708SDavid Chisnall "Attempted to increment non-incrementable iterator"); 13897a984708SDavid Chisnall#endif 13907a984708SDavid Chisnall ++__i; 13917a984708SDavid Chisnall return *this; 13927a984708SDavid Chisnall } 13934ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT_DEBUG 13947a984708SDavid Chisnall {__wrap_iter __tmp(*this); ++(*this); return __tmp;} 13954ba319b5SDimitry Andric 13964ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT_DEBUG 13977a984708SDavid Chisnall { 13987a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 13997a984708SDavid Chisnall _LIBCPP_ASSERT(__get_const_db()->__decrementable(this), 14007a984708SDavid Chisnall "Attempted to decrement non-decrementable iterator"); 14017a984708SDavid Chisnall#endif 14027a984708SDavid Chisnall --__i; 14037a984708SDavid Chisnall return *this; 14047a984708SDavid Chisnall } 14054ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT_DEBUG 14067a984708SDavid Chisnall {__wrap_iter __tmp(*this); --(*this); return __tmp;} 14074ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT_DEBUG 14087a984708SDavid Chisnall {__wrap_iter __w(*this); __w += __n; return __w;} 14094ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT_DEBUG 14107a984708SDavid Chisnall { 14117a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 14127a984708SDavid Chisnall _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n), 14137a984708SDavid Chisnall "Attempted to add/subtract iterator outside of valid range"); 14147a984708SDavid Chisnall#endif 14157a984708SDavid Chisnall __i += __n; 14167a984708SDavid Chisnall return *this; 14177a984708SDavid Chisnall } 14184ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT_DEBUG 14197a984708SDavid Chisnall {return *this + (-__n);} 14204ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT_DEBUG 14217a984708SDavid Chisnall {*this += -__n; return *this;} 14224ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT_DEBUG 14237a984708SDavid Chisnall { 14247a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 14257a984708SDavid Chisnall _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n), 14267a984708SDavid Chisnall "Attempted to subscript iterator outside of valid range"); 14277a984708SDavid Chisnall#endif 14287a984708SDavid Chisnall return __i[__n]; 14297a984708SDavid Chisnall } 14307a984708SDavid Chisnall 14314ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT_DEBUG {return __i;} 14327a984708SDavid Chisnall 14337a984708SDavid Chisnallprivate: 14347a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 14354ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x) 14367a984708SDavid Chisnall { 14377a984708SDavid Chisnall __get_db()->__insert_ic(this, __p); 14387a984708SDavid Chisnall } 14394f7ab58eSDimitry Andric#else 14404ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {} 14417a984708SDavid Chisnall#endif 14427a984708SDavid Chisnall 14437a984708SDavid Chisnall template <class _Up> friend class __wrap_iter; 14447a984708SDavid Chisnall template <class _CharT, class _Traits, class _Alloc> friend class basic_string; 1445aed8d94eSDimitry Andric template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector; 14464ba319b5SDimitry Andric template <class _Tp, ptrdiff_t> friend class _LIBCPP_TEMPLATE_VIS span; 14477a984708SDavid Chisnall 14487a984708SDavid Chisnall template <class _Iter1, class _Iter2> 14494ba319b5SDimitry Andric _LIBCPP_CONSTEXPR_IF_NODEBUG friend 14507a984708SDavid Chisnall bool 1451aed8d94eSDimitry Andric operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 14527a984708SDavid Chisnall 14537a984708SDavid Chisnall template <class _Iter1, class _Iter2> 14544ba319b5SDimitry Andric _LIBCPP_CONSTEXPR_IF_NODEBUG friend 14557a984708SDavid Chisnall bool 1456aed8d94eSDimitry Andric operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 14577a984708SDavid Chisnall 14587a984708SDavid Chisnall template <class _Iter1, class _Iter2> 14594ba319b5SDimitry Andric _LIBCPP_CONSTEXPR_IF_NODEBUG friend 14607a984708SDavid Chisnall bool 1461aed8d94eSDimitry Andric operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 14627a984708SDavid Chisnall 14637a984708SDavid Chisnall template <class _Iter1, class _Iter2> 14644ba319b5SDimitry Andric _LIBCPP_CONSTEXPR_IF_NODEBUG friend 14657a984708SDavid Chisnall bool 1466aed8d94eSDimitry Andric operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 14677a984708SDavid Chisnall 14687a984708SDavid Chisnall template <class _Iter1, class _Iter2> 14694ba319b5SDimitry Andric _LIBCPP_CONSTEXPR_IF_NODEBUG friend 14707a984708SDavid Chisnall bool 1471aed8d94eSDimitry Andric operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 14727a984708SDavid Chisnall 14737a984708SDavid Chisnall template <class _Iter1, class _Iter2> 14744ba319b5SDimitry Andric _LIBCPP_CONSTEXPR_IF_NODEBUG friend 14757a984708SDavid Chisnall bool 1476aed8d94eSDimitry Andric operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 14777a984708SDavid Chisnall 14787c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 14797c82a1ecSDimitry Andric template <class _Iter1, class _Iter2> 14804ba319b5SDimitry Andric _LIBCPP_CONSTEXPR_IF_NODEBUG friend 14817c82a1ecSDimitry Andric auto 1482aed8d94eSDimitry Andric operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG 14837c82a1ecSDimitry Andric -> decltype(__x.base() - __y.base()); 14847c82a1ecSDimitry Andric#else 14857a984708SDavid Chisnall template <class _Iter1, class _Iter2> 14864ba319b5SDimitry Andric _LIBCPP_CONSTEXPR_IF_NODEBUG friend 14877a984708SDavid Chisnall typename __wrap_iter<_Iter1>::difference_type 1488aed8d94eSDimitry Andric operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; 14897c82a1ecSDimitry Andric#endif 14907a984708SDavid Chisnall 14917a984708SDavid Chisnall template <class _Iter1> 14924ba319b5SDimitry Andric _LIBCPP_CONSTEXPR_IF_NODEBUG friend 14937a984708SDavid Chisnall __wrap_iter<_Iter1> 1494aed8d94eSDimitry Andric operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT_DEBUG; 14957a984708SDavid Chisnall 149694e3ee44SDavid Chisnall template <class _Ip, class _Op> friend _Op copy(_Ip, _Ip, _Op); 14977a984708SDavid Chisnall template <class _B1, class _B2> friend _B2 copy_backward(_B1, _B1, _B2); 149894e3ee44SDavid Chisnall template <class _Ip, class _Op> friend _Op move(_Ip, _Ip, _Op); 14997a984708SDavid Chisnall template <class _B1, class _B2> friend _B2 move_backward(_B1, _B1, _B2); 15007a984708SDavid Chisnall 1501aed8d94eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL < 2 15027a984708SDavid Chisnall template <class _Tp> 15034ba319b5SDimitry Andric _LIBCPP_CONSTEXPR_IF_NODEBUG friend 15047a984708SDavid Chisnall typename enable_if 15057a984708SDavid Chisnall < 15067a984708SDavid Chisnall is_trivially_copy_assignable<_Tp>::value, 15077a984708SDavid Chisnall _Tp* 15087a984708SDavid Chisnall >::type 15097a984708SDavid Chisnall __unwrap_iter(__wrap_iter<_Tp*>); 1510aed8d94eSDimitry Andric#else 1511aed8d94eSDimitry Andric template <class _Tp> 15124ba319b5SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1513aed8d94eSDimitry Andric typename enable_if 1514aed8d94eSDimitry Andric < 1515aed8d94eSDimitry Andric is_trivially_copy_assignable<_Tp>::value, 1516aed8d94eSDimitry Andric __wrap_iter<_Tp*> 1517aed8d94eSDimitry Andric >::type 1518aed8d94eSDimitry Andric __unwrap_iter(__wrap_iter<_Tp*> __i); 1519aed8d94eSDimitry Andric#endif 15207a984708SDavid Chisnall}; 15217a984708SDavid Chisnall 15227a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 15234ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 15247a984708SDavid Chisnallbool 1525aed8d94eSDimitry Andricoperator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG 15267a984708SDavid Chisnall{ 15277a984708SDavid Chisnall return __x.base() == __y.base(); 15287a984708SDavid Chisnall} 15297a984708SDavid Chisnall 15307a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 15314ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 15327a984708SDavid Chisnallbool 1533aed8d94eSDimitry Andricoperator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG 15347a984708SDavid Chisnall{ 15357a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 15364f7ab58eSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), 15377a984708SDavid Chisnall "Attempted to compare incomparable iterators"); 15387a984708SDavid Chisnall#endif 15397a984708SDavid Chisnall return __x.base() < __y.base(); 15407a984708SDavid Chisnall} 15417a984708SDavid Chisnall 15427a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 15434ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 15447a984708SDavid Chisnallbool 1545aed8d94eSDimitry Andricoperator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG 15467a984708SDavid Chisnall{ 15477a984708SDavid Chisnall return !(__x == __y); 15487a984708SDavid Chisnall} 15497a984708SDavid Chisnall 15507a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 15514ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 15527a984708SDavid Chisnallbool 1553aed8d94eSDimitry Andricoperator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG 15547a984708SDavid Chisnall{ 15557a984708SDavid Chisnall return __y < __x; 15567a984708SDavid Chisnall} 15577a984708SDavid Chisnall 15587a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 15594ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 15607a984708SDavid Chisnallbool 1561aed8d94eSDimitry Andricoperator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG 15627a984708SDavid Chisnall{ 15637a984708SDavid Chisnall return !(__x < __y); 15647a984708SDavid Chisnall} 15657a984708SDavid Chisnall 15667a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 15674ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 15687a984708SDavid Chisnallbool 1569aed8d94eSDimitry Andricoperator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG 15707a984708SDavid Chisnall{ 15717a984708SDavid Chisnall return !(__y < __x); 15727a984708SDavid Chisnall} 15737a984708SDavid Chisnall 1574936e9439SDimitry Andrictemplate <class _Iter1> 15754ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1576936e9439SDimitry Andricbool 1577aed8d94eSDimitry Andricoperator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG 1578936e9439SDimitry Andric{ 1579936e9439SDimitry Andric return !(__x == __y); 1580936e9439SDimitry Andric} 1581936e9439SDimitry Andric 1582936e9439SDimitry Andrictemplate <class _Iter1> 15834ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1584936e9439SDimitry Andricbool 1585aed8d94eSDimitry Andricoperator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG 1586936e9439SDimitry Andric{ 1587936e9439SDimitry Andric return __y < __x; 1588936e9439SDimitry Andric} 1589936e9439SDimitry Andric 1590936e9439SDimitry Andrictemplate <class _Iter1> 15914ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1592936e9439SDimitry Andricbool 1593aed8d94eSDimitry Andricoperator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG 1594936e9439SDimitry Andric{ 1595936e9439SDimitry Andric return !(__x < __y); 1596936e9439SDimitry Andric} 1597936e9439SDimitry Andric 1598936e9439SDimitry Andrictemplate <class _Iter1> 15994ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 1600936e9439SDimitry Andricbool 1601aed8d94eSDimitry Andricoperator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG 1602936e9439SDimitry Andric{ 1603936e9439SDimitry Andric return !(__y < __x); 1604936e9439SDimitry Andric} 1605936e9439SDimitry Andric 16067c82a1ecSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 16077c82a1ecSDimitry Andrictemplate <class _Iter1, class _Iter2> 16084ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16097c82a1ecSDimitry Andricauto 1610aed8d94eSDimitry Andricoperator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG 16117c82a1ecSDimitry Andric-> decltype(__x.base() - __y.base()) 16127c82a1ecSDimitry Andric{ 16137c82a1ecSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 16147c82a1ecSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), 16157c82a1ecSDimitry Andric "Attempted to subtract incompatible iterators"); 16167c82a1ecSDimitry Andric#endif 16177c82a1ecSDimitry Andric return __x.base() - __y.base(); 16187c82a1ecSDimitry Andric} 16197c82a1ecSDimitry Andric#else 16207a984708SDavid Chisnalltemplate <class _Iter1, class _Iter2> 16214ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16227a984708SDavid Chisnalltypename __wrap_iter<_Iter1>::difference_type 1623aed8d94eSDimitry Andricoperator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG 16247a984708SDavid Chisnall{ 16257a984708SDavid Chisnall#if _LIBCPP_DEBUG_LEVEL >= 2 16264f7ab58eSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), 16277a984708SDavid Chisnall "Attempted to subtract incompatible iterators"); 16287a984708SDavid Chisnall#endif 16297a984708SDavid Chisnall return __x.base() - __y.base(); 16307a984708SDavid Chisnall} 16317c82a1ecSDimitry Andric#endif 16327a984708SDavid Chisnall 16337a984708SDavid Chisnalltemplate <class _Iter> 16344ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG 16357a984708SDavid Chisnall__wrap_iter<_Iter> 16367a984708SDavid Chisnalloperator+(typename __wrap_iter<_Iter>::difference_type __n, 1637aed8d94eSDimitry Andric __wrap_iter<_Iter> __x) _NOEXCEPT_DEBUG 16387a984708SDavid Chisnall{ 16397a984708SDavid Chisnall __x += __n; 16407a984708SDavid Chisnall return __x; 16417a984708SDavid Chisnall} 16427a984708SDavid Chisnall 16439729cf09SDimitry Andrictemplate <class _Iter> 16449729cf09SDimitry Andricstruct __libcpp_is_trivial_iterator 16459729cf09SDimitry Andric : public _LIBCPP_BOOL_CONSTANT(is_pointer<_Iter>::value) {}; 16469729cf09SDimitry Andric 16479729cf09SDimitry Andrictemplate <class _Iter> 16489729cf09SDimitry Andricstruct __libcpp_is_trivial_iterator<move_iterator<_Iter> > 16499729cf09SDimitry Andric : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {}; 16509729cf09SDimitry Andric 16519729cf09SDimitry Andrictemplate <class _Iter> 16529729cf09SDimitry Andricstruct __libcpp_is_trivial_iterator<reverse_iterator<_Iter> > 16539729cf09SDimitry Andric : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {}; 16549729cf09SDimitry Andric 16559729cf09SDimitry Andrictemplate <class _Iter> 16569729cf09SDimitry Andricstruct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> > 16579729cf09SDimitry Andric : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {}; 16589729cf09SDimitry Andric 16599729cf09SDimitry Andric 16604f7ab58eSDimitry Andrictemplate <class _Tp, size_t _Np> 1661d72607e9SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 16624f7ab58eSDimitry Andric_Tp* 16634f7ab58eSDimitry Andricbegin(_Tp (&__array)[_Np]) 16647a984708SDavid Chisnall{ 16654f7ab58eSDimitry Andric return __array; 16667a984708SDavid Chisnall} 16677a984708SDavid Chisnall 16684f7ab58eSDimitry Andrictemplate <class _Tp, size_t _Np> 1669d72607e9SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 16704f7ab58eSDimitry Andric_Tp* 16714f7ab58eSDimitry Andricend(_Tp (&__array)[_Np]) 16727a984708SDavid Chisnall{ 16734f7ab58eSDimitry Andric return __array + _Np; 16747a984708SDavid Chisnall} 16757a984708SDavid Chisnall 1676aed8d94eSDimitry Andric#if !defined(_LIBCPP_CXX03_LANG) 16777a984708SDavid Chisnall 167894e3ee44SDavid Chisnalltemplate <class _Cp> 1679aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 16807a984708SDavid Chisnallauto 168194e3ee44SDavid Chisnallbegin(_Cp& __c) -> decltype(__c.begin()) 16827a984708SDavid Chisnall{ 16837a984708SDavid Chisnall return __c.begin(); 16847a984708SDavid Chisnall} 16857a984708SDavid Chisnall 168694e3ee44SDavid Chisnalltemplate <class _Cp> 1687aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 16887a984708SDavid Chisnallauto 168994e3ee44SDavid Chisnallbegin(const _Cp& __c) -> decltype(__c.begin()) 16907a984708SDavid Chisnall{ 16917a984708SDavid Chisnall return __c.begin(); 16927a984708SDavid Chisnall} 16937a984708SDavid Chisnall 169494e3ee44SDavid Chisnalltemplate <class _Cp> 1695aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 16967a984708SDavid Chisnallauto 169794e3ee44SDavid Chisnallend(_Cp& __c) -> decltype(__c.end()) 16987a984708SDavid Chisnall{ 16997a984708SDavid Chisnall return __c.end(); 17007a984708SDavid Chisnall} 17017a984708SDavid Chisnall 170294e3ee44SDavid Chisnalltemplate <class _Cp> 1703aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17047a984708SDavid Chisnallauto 170594e3ee44SDavid Chisnallend(const _Cp& __c) -> decltype(__c.end()) 17067a984708SDavid Chisnall{ 17077a984708SDavid Chisnall return __c.end(); 17087a984708SDavid Chisnall} 17097a984708SDavid Chisnall 17104f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 17114f7ab58eSDimitry Andric 17124f7ab58eSDimitry Andrictemplate <class _Tp, size_t _Np> 1713aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17144f7ab58eSDimitry Andricreverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) 17154f7ab58eSDimitry Andric{ 17164f7ab58eSDimitry Andric return reverse_iterator<_Tp*>(__array + _Np); 17174f7ab58eSDimitry Andric} 17184f7ab58eSDimitry Andric 17194f7ab58eSDimitry Andrictemplate <class _Tp, size_t _Np> 1720aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17214f7ab58eSDimitry Andricreverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) 17224f7ab58eSDimitry Andric{ 17234f7ab58eSDimitry Andric return reverse_iterator<_Tp*>(__array); 17244f7ab58eSDimitry Andric} 17254f7ab58eSDimitry Andric 17264f7ab58eSDimitry Andrictemplate <class _Ep> 1727aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17284f7ab58eSDimitry Andricreverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il) 17294f7ab58eSDimitry Andric{ 17304f7ab58eSDimitry Andric return reverse_iterator<const _Ep*>(__il.end()); 17314f7ab58eSDimitry Andric} 17324f7ab58eSDimitry Andric 17334f7ab58eSDimitry Andrictemplate <class _Ep> 1734aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17354f7ab58eSDimitry Andricreverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il) 17364f7ab58eSDimitry Andric{ 17374f7ab58eSDimitry Andric return reverse_iterator<const _Ep*>(__il.begin()); 17384f7ab58eSDimitry Andric} 17394f7ab58eSDimitry Andric 17404f7ab58eSDimitry Andrictemplate <class _Cp> 1741d72607e9SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 17427c82a1ecSDimitry Andricauto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c)) 17434f7ab58eSDimitry Andric{ 17447c82a1ecSDimitry Andric return _VSTD::begin(__c); 17454f7ab58eSDimitry Andric} 17464f7ab58eSDimitry Andric 17474f7ab58eSDimitry Andrictemplate <class _Cp> 1748d72607e9SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 17497c82a1ecSDimitry Andricauto cend(const _Cp& __c) -> decltype(_VSTD::end(__c)) 17504f7ab58eSDimitry Andric{ 17517c82a1ecSDimitry Andric return _VSTD::end(__c); 17524f7ab58eSDimitry Andric} 17534f7ab58eSDimitry Andric 17544f7ab58eSDimitry Andrictemplate <class _Cp> 1755aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17564f7ab58eSDimitry Andricauto rbegin(_Cp& __c) -> decltype(__c.rbegin()) 17574f7ab58eSDimitry Andric{ 17584f7ab58eSDimitry Andric return __c.rbegin(); 17594f7ab58eSDimitry Andric} 17604f7ab58eSDimitry Andric 17614f7ab58eSDimitry Andrictemplate <class _Cp> 1762aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17634f7ab58eSDimitry Andricauto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) 17644f7ab58eSDimitry Andric{ 17654f7ab58eSDimitry Andric return __c.rbegin(); 17664f7ab58eSDimitry Andric} 17674f7ab58eSDimitry Andric 17684f7ab58eSDimitry Andrictemplate <class _Cp> 1769aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17704f7ab58eSDimitry Andricauto rend(_Cp& __c) -> decltype(__c.rend()) 17714f7ab58eSDimitry Andric{ 17724f7ab58eSDimitry Andric return __c.rend(); 17734f7ab58eSDimitry Andric} 17744f7ab58eSDimitry Andric 17754f7ab58eSDimitry Andrictemplate <class _Cp> 1776aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17774f7ab58eSDimitry Andricauto rend(const _Cp& __c) -> decltype(__c.rend()) 17784f7ab58eSDimitry Andric{ 17794f7ab58eSDimitry Andric return __c.rend(); 17804f7ab58eSDimitry Andric} 17814f7ab58eSDimitry Andric 17824f7ab58eSDimitry Andrictemplate <class _Cp> 1783aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17847c82a1ecSDimitry Andricauto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c)) 17854f7ab58eSDimitry Andric{ 17867c82a1ecSDimitry Andric return _VSTD::rbegin(__c); 17874f7ab58eSDimitry Andric} 17884f7ab58eSDimitry Andric 17894f7ab58eSDimitry Andrictemplate <class _Cp> 1790aed8d94eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 17917c82a1ecSDimitry Andricauto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c)) 17924f7ab58eSDimitry Andric{ 17937c82a1ecSDimitry Andric return _VSTD::rend(__c); 17944f7ab58eSDimitry Andric} 17954f7ab58eSDimitry Andric 17964f7ab58eSDimitry Andric#endif 17974f7ab58eSDimitry Andric 17984f7ab58eSDimitry Andric 1799aed8d94eSDimitry Andric#else // defined(_LIBCPP_CXX03_LANG) 18007a984708SDavid Chisnall 180194e3ee44SDavid Chisnalltemplate <class _Cp> 18027a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 180394e3ee44SDavid Chisnalltypename _Cp::iterator 180494e3ee44SDavid Chisnallbegin(_Cp& __c) 18057a984708SDavid Chisnall{ 18067a984708SDavid Chisnall return __c.begin(); 18077a984708SDavid Chisnall} 18087a984708SDavid Chisnall 180994e3ee44SDavid Chisnalltemplate <class _Cp> 18107a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 181194e3ee44SDavid Chisnalltypename _Cp::const_iterator 181294e3ee44SDavid Chisnallbegin(const _Cp& __c) 18137a984708SDavid Chisnall{ 18147a984708SDavid Chisnall return __c.begin(); 18157a984708SDavid Chisnall} 18167a984708SDavid Chisnall 181794e3ee44SDavid Chisnalltemplate <class _Cp> 18187a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 181994e3ee44SDavid Chisnalltypename _Cp::iterator 182094e3ee44SDavid Chisnallend(_Cp& __c) 18217a984708SDavid Chisnall{ 18227a984708SDavid Chisnall return __c.end(); 18237a984708SDavid Chisnall} 18247a984708SDavid Chisnall 182594e3ee44SDavid Chisnalltemplate <class _Cp> 18267a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 182794e3ee44SDavid Chisnalltypename _Cp::const_iterator 182894e3ee44SDavid Chisnallend(const _Cp& __c) 18297a984708SDavid Chisnall{ 18307a984708SDavid Chisnall return __c.end(); 18317a984708SDavid Chisnall} 18327a984708SDavid Chisnall 1833aed8d94eSDimitry Andric#endif // !defined(_LIBCPP_CXX03_LANG) 18347a984708SDavid Chisnall 1835d72607e9SDimitry Andric#if _LIBCPP_STD_VER > 14 1836b2c7081bSDimitry Andric 1837b2c7081bSDimitry Andric// #if _LIBCPP_STD_VER > 11 1838b2c7081bSDimitry Andric// template <> 1839b2c7081bSDimitry Andric// struct _LIBCPP_TEMPLATE_VIS plus<void> 1840b2c7081bSDimitry Andric// { 1841b2c7081bSDimitry Andric// template <class _T1, class _T2> 1842b2c7081bSDimitry Andric// _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1843b2c7081bSDimitry Andric// auto operator()(_T1&& __t, _T2&& __u) const 1844b2c7081bSDimitry Andric// _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) 1845b2c7081bSDimitry Andric// -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) 1846b2c7081bSDimitry Andric// { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } 1847b2c7081bSDimitry Andric// typedef void is_transparent; 1848b2c7081bSDimitry Andric// }; 1849b2c7081bSDimitry Andric// #endif 1850b2c7081bSDimitry Andric 1851854fa44bSDimitry Andrictemplate <class _Cont> 1852b2c7081bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1853b2c7081bSDimitry Andricconstexpr auto size(const _Cont& __c) 1854b2c7081bSDimitry Andric_NOEXCEPT_(noexcept(__c.size())) 1855b2c7081bSDimitry Andric-> decltype (__c.size()) 1856b2c7081bSDimitry Andric{ return __c.size(); } 1857d72607e9SDimitry Andric 1858854fa44bSDimitry Andrictemplate <class _Tp, size_t _Sz> 1859b2c7081bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1860aed8d94eSDimitry Andricconstexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; } 1861d72607e9SDimitry Andric 1862854fa44bSDimitry Andrictemplate <class _Cont> 1863b2c7081bSDimitry Andric_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY 1864b2c7081bSDimitry Andricconstexpr auto empty(const _Cont& __c) 1865b2c7081bSDimitry Andric_NOEXCEPT_(noexcept(__c.empty())) 1866b2c7081bSDimitry Andric-> decltype (__c.empty()) 1867b2c7081bSDimitry Andric{ return __c.empty(); } 1868d72607e9SDimitry Andric 1869854fa44bSDimitry Andrictemplate <class _Tp, size_t _Sz> 1870b2c7081bSDimitry Andric_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY 1871aed8d94eSDimitry Andricconstexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; } 1872d72607e9SDimitry Andric 1873d72607e9SDimitry Andrictemplate <class _Ep> 1874b2c7081bSDimitry Andric_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY 1875d72607e9SDimitry Andricconstexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; } 1876d72607e9SDimitry Andric 1877854fa44bSDimitry Andrictemplate <class _Cont> constexpr 1878b2c7081bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1879b2c7081bSDimitry Andricauto data(_Cont& __c) 1880b2c7081bSDimitry Andric_NOEXCEPT_(noexcept(__c.data())) 1881b2c7081bSDimitry Andric-> decltype (__c.data()) 1882b2c7081bSDimitry Andric{ return __c.data(); } 1883d72607e9SDimitry Andric 1884854fa44bSDimitry Andrictemplate <class _Cont> constexpr 1885b2c7081bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1886b2c7081bSDimitry Andricauto data(const _Cont& __c) 1887b2c7081bSDimitry Andric_NOEXCEPT_(noexcept(__c.data())) 1888b2c7081bSDimitry Andric-> decltype (__c.data()) 1889b2c7081bSDimitry Andric{ return __c.data(); } 1890d72607e9SDimitry Andric 1891854fa44bSDimitry Andrictemplate <class _Tp, size_t _Sz> 1892b2c7081bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1893854fa44bSDimitry Andricconstexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; } 1894d72607e9SDimitry Andric 1895d72607e9SDimitry Andrictemplate <class _Ep> 1896b2c7081bSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1897d72607e9SDimitry Andricconstexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); } 1898d72607e9SDimitry Andric#endif 1899d72607e9SDimitry Andric 1900d72607e9SDimitry Andric 19017a984708SDavid Chisnall_LIBCPP_END_NAMESPACE_STD 19027a984708SDavid Chisnall 19037a984708SDavid Chisnall#endif // _LIBCPP_ITERATOR 1904