| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- | 
 | 2 | //===--------------------------- string -----------------------------------===// | 
 | 3 | // | 
| Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | //                     The LLVM Compiler Infrastructure | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // | 
 | 6 | // This file is distributed under the University of Illinois Open Source | 
 | 7 | // License. See LICENSE.TXT for details. | 
 | 8 | // | 
 | 9 | //===----------------------------------------------------------------------===// | 
 | 10 |  | 
 | 11 | #ifndef _LIBCPP_STRING | 
 | 12 | #define _LIBCPP_STRING | 
 | 13 |  | 
 | 14 | /* | 
 | 15 |     string synopsis | 
 | 16 |  | 
 | 17 | namespace std | 
 | 18 | { | 
 | 19 |  | 
 | 20 | template <class stateT> | 
 | 21 | class fpos | 
 | 22 | { | 
 | 23 | private: | 
 | 24 |     stateT st; | 
 | 25 | public: | 
 | 26 |     fpos(streamoff = streamoff()); | 
 | 27 |  | 
 | 28 |     operator streamoff() const; | 
 | 29 |  | 
 | 30 |     stateT state() const; | 
 | 31 |     void state(stateT); | 
 | 32 |  | 
 | 33 |     fpos& operator+=(streamoff); | 
 | 34 |     fpos  operator+ (streamoff) const; | 
 | 35 |     fpos& operator-=(streamoff); | 
 | 36 |     fpos  operator- (streamoff) const; | 
 | 37 | }; | 
 | 38 |  | 
 | 39 | template <class stateT> streamoff operator-(const fpos<stateT>& x, const fpos<stateT>& y); | 
 | 40 |  | 
 | 41 | template <class stateT> bool operator==(const fpos<stateT>& x, const fpos<stateT>& y); | 
 | 42 | template <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT>& y); | 
 | 43 |  | 
 | 44 | template <class charT> | 
 | 45 | struct char_traits | 
 | 46 | { | 
 | 47 |     typedef charT     char_type; | 
 | 48 |     typedef ...       int_type; | 
 | 49 |     typedef streamoff off_type; | 
 | 50 |     typedef streampos pos_type; | 
 | 51 |     typedef mbstate_t state_type; | 
 | 52 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 53 |     static void assign(char_type& c1, const char_type& c2) noexcept; | 
| Howard Hinnant | 03d7181 | 2012-07-20 19:09:12 +0000 | [diff] [blame] | 54 |     static constexpr bool eq(char_type c1, char_type c2) noexcept; | 
 | 55 |     static constexpr bool lt(char_type c1, char_type c2) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 56 |  | 
 | 57 |     static int              compare(const char_type* s1, const char_type* s2, size_t n); | 
 | 58 |     static size_t           length(const char_type* s); | 
 | 59 |     static const char_type* find(const char_type* s, size_t n, const char_type& a); | 
 | 60 |     static char_type*       move(char_type* s1, const char_type* s2, size_t n); | 
 | 61 |     static char_type*       copy(char_type* s1, const char_type* s2, size_t n); | 
 | 62 |     static char_type*       assign(char_type* s, size_t n, char_type a); | 
 | 63 |  | 
| Howard Hinnant | 03d7181 | 2012-07-20 19:09:12 +0000 | [diff] [blame] | 64 |     static constexpr int_type  not_eof(int_type c) noexcept; | 
 | 65 |     static constexpr char_type to_char_type(int_type c) noexcept; | 
 | 66 |     static constexpr int_type  to_int_type(char_type c) noexcept; | 
 | 67 |     static constexpr bool      eq_int_type(int_type c1, int_type c2) noexcept; | 
 | 68 |     static constexpr int_type  eof() noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 69 | }; | 
 | 70 |  | 
 | 71 | template <> struct char_traits<char>; | 
 | 72 | template <> struct char_traits<wchar_t>; | 
 | 73 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 74 | template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 75 | class basic_string | 
 | 76 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 77 | public: | 
 | 78 | // types: | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 79 |     typedef traits traits_type; | 
 | 80 |     typedef typename traits_type::char_type value_type; | 
 | 81 |     typedef Allocator allocator_type; | 
 | 82 |     typedef typename allocator_type::size_type size_type; | 
 | 83 |     typedef typename allocator_type::difference_type difference_type; | 
 | 84 |     typedef typename allocator_type::reference reference; | 
 | 85 |     typedef typename allocator_type::const_reference const_reference; | 
 | 86 |     typedef typename allocator_type::pointer pointer; | 
 | 87 |     typedef typename allocator_type::const_pointer const_pointer; | 
 | 88 |     typedef implementation-defined iterator; | 
 | 89 |     typedef implementation-defined const_iterator; | 
 | 90 |     typedef std::reverse_iterator<iterator> reverse_iterator; | 
 | 91 |     typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 
 | 92 |  | 
 | 93 |     static const size_type npos = -1; | 
 | 94 |  | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 95 |     basic_string() | 
 | 96 |         noexcept(is_nothrow_default_constructible<allocator_type>::value); | 
 | 97 |     explicit basic_string(const allocator_type& a); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 98 |     basic_string(const basic_string& str); | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 99 |     basic_string(basic_string&& str) | 
 | 100 |         noexcept(is_nothrow_move_constructible<allocator_type>::value); | 
| Marshall Clow | f4f7d8f | 2016-04-07 18:13:41 +0000 | [diff] [blame] | 101 |     basic_string(const basic_string& str, size_type pos, | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 102 |                  const allocator_type& a = allocator_type()); | 
| Marshall Clow | f4f7d8f | 2016-04-07 18:13:41 +0000 | [diff] [blame] | 103 |     basic_string(const basic_string& str, size_type pos, size_type n, | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 104 |                  const Allocator& a = Allocator()); | 
| Marshall Clow | db7fa11 | 2016-11-14 18:22:19 +0000 | [diff] [blame] | 105 |     template<class T> | 
 | 106 |         basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17 | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 107 |     template <class T> | 
 | 108 |         explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 109 |     basic_string(const value_type* s, const allocator_type& a = allocator_type()); | 
 | 110 |     basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 111 |     basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); | 
 | 112 |     template<class InputIterator> | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 113 |         basic_string(InputIterator begin, InputIterator end, | 
 | 114 |                      const allocator_type& a = allocator_type()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 115 |     basic_string(initializer_list<value_type>, const Allocator& = Allocator()); | 
 | 116 |     basic_string(const basic_string&, const Allocator&); | 
 | 117 |     basic_string(basic_string&&, const Allocator&); | 
 | 118 |  | 
 | 119 |     ~basic_string(); | 
 | 120 |  | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 121 |     operator basic_string_view<charT, traits>() const noexcept; | 
 | 122 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 123 |     basic_string& operator=(const basic_string& str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 124 |     template <class T> | 
 | 125 |         basic_string& operator=(const T& t); // C++17 | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 126 |     basic_string& operator=(basic_string&& str) | 
 | 127 |         noexcept( | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 +0000 | [diff] [blame] | 128 |              allocator_type::propagate_on_container_move_assignment::value || | 
 | 129 |              allocator_type::is_always_equal::value ); // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 130 |     basic_string& operator=(const value_type* s); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 131 |     basic_string& operator=(value_type c); | 
 | 132 |     basic_string& operator=(initializer_list<value_type>); | 
 | 133 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 134 |     iterator       begin() noexcept; | 
 | 135 |     const_iterator begin() const noexcept; | 
 | 136 |     iterator       end() noexcept; | 
 | 137 |     const_iterator end() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 138 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 139 |     reverse_iterator       rbegin() noexcept; | 
 | 140 |     const_reverse_iterator rbegin() const noexcept; | 
 | 141 |     reverse_iterator       rend() noexcept; | 
 | 142 |     const_reverse_iterator rend() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 143 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 144 |     const_iterator         cbegin() const noexcept; | 
 | 145 |     const_iterator         cend() const noexcept; | 
 | 146 |     const_reverse_iterator crbegin() const noexcept; | 
 | 147 |     const_reverse_iterator crend() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 148 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 149 |     size_type size() const noexcept; | 
 | 150 |     size_type length() const noexcept; | 
 | 151 |     size_type max_size() const noexcept; | 
 | 152 |     size_type capacity() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 153 |  | 
 | 154 |     void resize(size_type n, value_type c); | 
 | 155 |     void resize(size_type n); | 
 | 156 |  | 
 | 157 |     void reserve(size_type res_arg = 0); | 
 | 158 |     void shrink_to_fit(); | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 159 |     void clear() noexcept; | 
 | 160 |     bool empty() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 161 |  | 
 | 162 |     const_reference operator[](size_type pos) const; | 
 | 163 |     reference       operator[](size_type pos); | 
 | 164 |  | 
 | 165 |     const_reference at(size_type n) const; | 
 | 166 |     reference       at(size_type n); | 
 | 167 |  | 
 | 168 |     basic_string& operator+=(const basic_string& str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 169 |     template <class T> | 
 | 170 |         basic_string& operator+=(const T& t);              // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 171 |     basic_string& operator+=(const value_type* s); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 172 |     basic_string& operator+=(value_type c); | 
 | 173 |     basic_string& operator+=(initializer_list<value_type>); | 
 | 174 |  | 
 | 175 |     basic_string& append(const basic_string& str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 176 |     template <class T> | 
 | 177 |         basic_string& append(const T& t);                 // C++17 | 
| Marshall Clow | a93b5e2 | 2014-03-04 19:17:19 +0000 | [diff] [blame] | 178 |     basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14 | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 179 |     template <class T> | 
 | 180 |         basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 181 |     basic_string& append(const value_type* s, size_type n); | 
 | 182 |     basic_string& append(const value_type* s); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 183 |     basic_string& append(size_type n, value_type c); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 184 |     template<class InputIterator> | 
 | 185 |         basic_string& append(InputIterator first, InputIterator last); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 186 |     basic_string& append(initializer_list<value_type>); | 
 | 187 |  | 
 | 188 |     void push_back(value_type c); | 
 | 189 |     void pop_back(); | 
 | 190 |     reference       front(); | 
 | 191 |     const_reference front() const; | 
 | 192 |     reference       back(); | 
 | 193 |     const_reference back() const; | 
 | 194 |  | 
 | 195 |     basic_string& assign(const basic_string& str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 196 |     template <class T> | 
 | 197 |         basic_string& assign(const T& t);  // C++17 | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 198 |     basic_string& assign(basic_string&& str); | 
| Marshall Clow | a93b5e2 | 2014-03-04 19:17:19 +0000 | [diff] [blame] | 199 |     basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14 | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 200 |     template <class T> | 
 | 201 |         basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 202 |     basic_string& assign(const value_type* s, size_type n); | 
 | 203 |     basic_string& assign(const value_type* s); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 204 |     basic_string& assign(size_type n, value_type c); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 205 |     template<class InputIterator> | 
 | 206 |         basic_string& assign(InputIterator first, InputIterator last); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 207 |     basic_string& assign(initializer_list<value_type>); | 
 | 208 |  | 
 | 209 |     basic_string& insert(size_type pos1, const basic_string& str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 210 |     template <class T> | 
 | 211 |         basic_string& insert(size_type pos1, const T& t); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 212 |     basic_string& insert(size_type pos1, const basic_string& str, | 
 | 213 |                          size_type pos2, size_type n); | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 214 |     template <class T> | 
 | 215 |         basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17 | 
| Marshall Clow | a93b5e2 | 2014-03-04 19:17:19 +0000 | [diff] [blame] | 216 |     basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 217 |     basic_string& insert(size_type pos, const value_type* s); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 218 |     basic_string& insert(size_type pos, size_type n, value_type c); | 
 | 219 |     iterator      insert(const_iterator p, value_type c); | 
 | 220 |     iterator      insert(const_iterator p, size_type n, value_type c); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 221 |     template<class InputIterator> | 
 | 222 |         iterator insert(const_iterator p, InputIterator first, InputIterator last); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 223 |     iterator      insert(const_iterator p, initializer_list<value_type>); | 
 | 224 |  | 
 | 225 |     basic_string& erase(size_type pos = 0, size_type n = npos); | 
 | 226 |     iterator      erase(const_iterator position); | 
 | 227 |     iterator      erase(const_iterator first, const_iterator last); | 
 | 228 |  | 
 | 229 |     basic_string& replace(size_type pos1, size_type n1, const basic_string& str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 230 |     template <class T> | 
 | 231 |     basic_string& replace(size_type pos1, size_type n1, const T& t);  // C++17 | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 232 |     basic_string& replace(size_type pos1, size_type n1, const basic_string& str, | 
| Marshall Clow | a93b5e2 | 2014-03-04 19:17:19 +0000 | [diff] [blame] | 233 |                           size_type pos2, size_type n2=npos); // C++14 | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 234 |     template <class T> | 
 | 235 |         basic_string& replace(size_type pos1, size_type n1, const T& t, | 
 | 236 |                               size_type pos2, size_type n); // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 237 |     basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); | 
 | 238 |     basic_string& replace(size_type pos, size_type n1, const value_type* s); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 239 |     basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); | 
| Howard Hinnant | 7b2cb48 | 2010-11-17 21:11:40 +0000 | [diff] [blame] | 240 |     basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 241 |     template <class T> | 
 | 242 |         basic_string& replace(const_iterator i1, const_iterator i2, const T& t);  // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 243 |     basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n); | 
 | 244 |     basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s); | 
| Howard Hinnant | 7b2cb48 | 2010-11-17 21:11:40 +0000 | [diff] [blame] | 245 |     basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 246 |     template<class InputIterator> | 
| Howard Hinnant | 7b2cb48 | 2010-11-17 21:11:40 +0000 | [diff] [blame] | 247 |         basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); | 
 | 248 |     basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 249 |  | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 250 |     size_type copy(value_type* s, size_type n, size_type pos = 0) const; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 251 |     basic_string substr(size_type pos = 0, size_type n = npos) const; | 
 | 252 |  | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 253 |     void swap(basic_string& str) | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 254 |         noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || | 
 | 255 |                  allocator_traits<allocator_type>::is_always_equal::value);  // C++17 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 256 |  | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 257 |     const value_type* c_str() const noexcept; | 
 | 258 |     const value_type* data() const noexcept; | 
| Marshall Clow | f532a70 | 2016-03-08 15:44:30 +0000 | [diff] [blame] | 259 |           value_type* data()       noexcept;   // C++17 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 260 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 261 |     allocator_type get_allocator() const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 262 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 263 |     size_type find(const basic_string& str, size_type pos = 0) const noexcept; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 264 |     template <class T> | 
 | 265 |         size_type find(const T& t, size_type pos = 0) const;  // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 266 |     size_type find(const value_type* s, size_type pos, size_type n) const noexcept; | 
 | 267 |     size_type find(const value_type* s, size_type pos = 0) const noexcept; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 268 |     size_type find(value_type c, size_type pos = 0) const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 269 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 270 |     size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 271 |     template <class T> | 
 | 272 |         size_type rfind(const T& t, size_type pos = npos) const;  // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 273 |     size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; | 
 | 274 |     size_type rfind(const value_type* s, size_type pos = npos) const noexcept; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 275 |     size_type rfind(value_type c, size_type pos = npos) const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 276 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 277 |     size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 278 |     template <class T> | 
 | 279 |         size_type find_first_of(const T& t, size_type pos = 0) const; // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 280 |     size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept; | 
 | 281 |     size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 282 |     size_type find_first_of(value_type c, size_type pos = 0) const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 283 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 284 |     size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 285 |     template <class T> | 
 | 286 |         size_type find_last_of(const T& t, size_type pos = npos) const noexcept;  // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 287 |     size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; | 
 | 288 |     size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 289 |     size_type find_last_of(value_type c, size_type pos = npos) const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 290 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 291 |     size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 292 |     template <class T> | 
 | 293 |         size_type find_first_not_of(const T& t, size_type pos = 0) const; // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 294 |     size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept; | 
 | 295 |     size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 296 |     size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 297 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 298 |     size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 299 |     template <class T> | 
 | 300 |         size_type find_last_not_of(const T& t, size_type pos = npos) const; // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 301 |     size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; | 
 | 302 |     size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 303 |     size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 304 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 305 |     int compare(const basic_string& str) const noexcept; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 306 |     template <class T> | 
 | 307 |         int compare(const T& t) const noexcept;  // C++17 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 308 |     int compare(size_type pos1, size_type n1, const basic_string& str) const; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 309 |     template <class T> | 
 | 310 |         int compare(size_type pos1, size_type n1, const T& t) const;  // C++17 | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 311 |     int compare(size_type pos1, size_type n1, const basic_string& str, | 
| Marshall Clow | a93b5e2 | 2014-03-04 19:17:19 +0000 | [diff] [blame] | 312 |                 size_type pos2, size_type n2=npos) const; // C++14 | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 313 |     template <class T> | 
 | 314 |         int compare(size_type pos1, size_type n1, const T& t, | 
 | 315 |                     size_type pos2, size_type n2=npos) const; // C++17 | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 316 |     int compare(const value_type* s) const noexcept; | 
 | 317 |     int compare(size_type pos1, size_type n1, const value_type* s) const; | 
 | 318 |     int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 319 |  | 
| Marshall Clow | 46b4ad5 | 2017-12-04 20:11:38 +0000 | [diff] [blame] | 320 |     bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++2a | 
 | 321 |     bool starts_with(charT c) const noexcept;                             // C++2a | 
 | 322 |     bool starts_with(const charT* s) const;                               // C++2a | 
 | 323 |     bool ends_with(basic_string_view<charT, traits> sv) const noexcept;   // C++2a | 
 | 324 |     bool ends_with(charT c) const noexcept;                               // C++2a | 
 | 325 |     bool ends_with(const charT* s) const;                                 // C++2a | 
 | 326 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 327 |     bool __invariants() const; | 
 | 328 | }; | 
 | 329 |  | 
| Marshall Clow | 5b1e87e | 2018-02-08 06:34:03 +0000 | [diff] [blame] | 330 | template<class InputIterator, | 
 | 331 |          class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> | 
 | 332 | basic_string(InputIterator, InputIterator, Allocator = Allocator()) | 
 | 333 |    -> basic_string<typename iterator_traits<InputIterator>::value_type, | 
 | 334 |                   char_traits<typename iterator_traits<InputIterator>::value_type>, | 
 | 335 |                   Allocator>;   // C++17 | 
 | 336 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 337 | template<class charT, class traits, class Allocator> | 
 | 338 | basic_string<charT, traits, Allocator> | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 339 | operator+(const basic_string<charT, traits, Allocator>& lhs, | 
 | 340 |           const basic_string<charT, traits, Allocator>& rhs); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 341 |  | 
 | 342 | template<class charT, class traits, class Allocator> | 
 | 343 | basic_string<charT, traits, Allocator> | 
 | 344 | operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs); | 
 | 345 |  | 
 | 346 | template<class charT, class traits, class Allocator> | 
 | 347 | basic_string<charT, traits, Allocator> | 
 | 348 | operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); | 
 | 349 |  | 
 | 350 | template<class charT, class traits, class Allocator> | 
 | 351 | basic_string<charT, traits, Allocator> | 
 | 352 | operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); | 
 | 353 |  | 
 | 354 | template<class charT, class traits, class Allocator> | 
 | 355 | basic_string<charT, traits, Allocator> | 
 | 356 | operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); | 
 | 357 |  | 
 | 358 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 359 | bool operator==(const basic_string<charT, traits, Allocator>& lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 360 |                 const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 361 |  | 
 | 362 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 363 | bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 364 |  | 
 | 365 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 366 | bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 367 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 368 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 369 | bool operator!=(const basic_string<charT,traits,Allocator>& lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 370 |                 const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 371 |  | 
 | 372 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 373 | bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 374 |  | 
 | 375 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 376 | bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 377 |  | 
 | 378 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 379 | bool operator< (const basic_string<charT, traits, Allocator>& lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 380 |                 const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 381 |  | 
 | 382 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 383 | bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 384 |  | 
 | 385 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 386 | bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 387 |  | 
 | 388 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 389 | bool operator> (const basic_string<charT, traits, Allocator>& lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 390 |                 const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 391 |  | 
 | 392 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 393 | bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 394 |  | 
 | 395 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 396 | bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 397 |  | 
 | 398 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 399 | bool operator<=(const basic_string<charT, traits, Allocator>& lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 400 |                 const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 401 |  | 
 | 402 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 403 | bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 404 |  | 
 | 405 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 406 | bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 407 |  | 
 | 408 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 409 | bool operator>=(const basic_string<charT, traits, Allocator>& lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 410 |                 const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 411 |  | 
 | 412 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 413 | bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 414 |  | 
 | 415 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 416 | bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 417 |  | 
 | 418 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 419 | void swap(basic_string<charT, traits, Allocator>& lhs, | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 420 |           basic_string<charT, traits, Allocator>& rhs) | 
 | 421 |             noexcept(noexcept(lhs.swap(rhs))); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 422 |  | 
 | 423 | template<class charT, class traits, class Allocator> | 
 | 424 | basic_istream<charT, traits>& | 
 | 425 | operator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); | 
 | 426 |  | 
 | 427 | template<class charT, class traits, class Allocator> | 
 | 428 | basic_ostream<charT, traits>& | 
 | 429 | operator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str); | 
 | 430 |  | 
 | 431 | template<class charT, class traits, class Allocator> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 432 | basic_istream<charT, traits>& | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 433 | getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str, | 
 | 434 |         charT delim); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 435 |  | 
 | 436 | template<class charT, class traits, class Allocator> | 
 | 437 | basic_istream<charT, traits>& | 
 | 438 | getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); | 
 | 439 |  | 
 | 440 | typedef basic_string<char>    string; | 
 | 441 | typedef basic_string<wchar_t> wstring; | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 442 | typedef basic_string<char16_t> u16string; | 
 | 443 | typedef basic_string<char32_t> u32string; | 
 | 444 |  | 
 | 445 | int                stoi  (const string& str, size_t* idx = 0, int base = 10); | 
 | 446 | long               stol  (const string& str, size_t* idx = 0, int base = 10); | 
 | 447 | unsigned long      stoul (const string& str, size_t* idx = 0, int base = 10); | 
 | 448 | long long          stoll (const string& str, size_t* idx = 0, int base = 10); | 
 | 449 | unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10); | 
 | 450 |  | 
 | 451 | float       stof (const string& str, size_t* idx = 0); | 
 | 452 | double      stod (const string& str, size_t* idx = 0); | 
 | 453 | long double stold(const string& str, size_t* idx = 0); | 
 | 454 |  | 
 | 455 | string to_string(int val); | 
 | 456 | string to_string(unsigned val); | 
 | 457 | string to_string(long val); | 
 | 458 | string to_string(unsigned long val); | 
 | 459 | string to_string(long long val); | 
 | 460 | string to_string(unsigned long long val); | 
 | 461 | string to_string(float val); | 
 | 462 | string to_string(double val); | 
 | 463 | string to_string(long double val); | 
 | 464 |  | 
 | 465 | int                stoi  (const wstring& str, size_t* idx = 0, int base = 10); | 
 | 466 | long               stol  (const wstring& str, size_t* idx = 0, int base = 10); | 
 | 467 | unsigned long      stoul (const wstring& str, size_t* idx = 0, int base = 10); | 
 | 468 | long long          stoll (const wstring& str, size_t* idx = 0, int base = 10); | 
 | 469 | unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10); | 
 | 470 |  | 
 | 471 | float       stof (const wstring& str, size_t* idx = 0); | 
 | 472 | double      stod (const wstring& str, size_t* idx = 0); | 
 | 473 | long double stold(const wstring& str, size_t* idx = 0); | 
 | 474 |  | 
 | 475 | wstring to_wstring(int val); | 
 | 476 | wstring to_wstring(unsigned val); | 
 | 477 | wstring to_wstring(long val); | 
 | 478 | wstring to_wstring(unsigned long val); | 
 | 479 | wstring to_wstring(long long val); | 
 | 480 | wstring to_wstring(unsigned long long val); | 
 | 481 | wstring to_wstring(float val); | 
 | 482 | wstring to_wstring(double val); | 
 | 483 | wstring to_wstring(long double val); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 484 |  | 
 | 485 | template <> struct hash<string>; | 
 | 486 | template <> struct hash<u16string>; | 
 | 487 | template <> struct hash<u32string>; | 
 | 488 | template <> struct hash<wstring>; | 
 | 489 |  | 
| Marshall Clow | 1523432 | 2013-07-23 17:05:24 +0000 | [diff] [blame] | 490 | basic_string<char>     operator "" s( const char *str,     size_t len ); // C++14 | 
 | 491 | basic_string<wchar_t>  operator "" s( const wchar_t *str,  size_t len ); // C++14 | 
 | 492 | basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14 | 
 | 493 | basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14 | 
 | 494 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 495 | }  // std | 
 | 496 |  | 
 | 497 | */ | 
 | 498 |  | 
 | 499 | #include <__config> | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 500 | #include <string_view> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 501 | #include <iosfwd> | 
 | 502 | #include <cstring> | 
| Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 503 | #include <cstdio>  // For EOF. | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 504 | #include <cwchar> | 
 | 505 | #include <algorithm> | 
 | 506 | #include <iterator> | 
 | 507 | #include <utility> | 
 | 508 | #include <memory> | 
 | 509 | #include <stdexcept> | 
 | 510 | #include <type_traits> | 
 | 511 | #include <initializer_list> | 
 | 512 | #include <__functional_base> | 
| Marshall Clow | e3973fd | 2018-09-12 19:41:40 +0000 | [diff] [blame] | 513 | #include <version> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 514 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | 
 | 515 | #include <cstdint> | 
 | 516 | #endif | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 517 |  | 
| Eric Fiselier | b953610 | 2014-08-10 23:53:08 +0000 | [diff] [blame] | 518 | #include <__debug> | 
 | 519 |  | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 520 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 521 | #pragma GCC system_header | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 522 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 523 |  | 
| Eric Fiselier | 018a3d5 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 524 | _LIBCPP_PUSH_MACROS | 
 | 525 | #include <__undef_macros> | 
 | 526 |  | 
 | 527 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 528 | _LIBCPP_BEGIN_NAMESPACE_STD | 
 | 529 |  | 
 | 530 | // fpos | 
 | 531 |  | 
 | 532 | template <class _StateT> | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 533 | class _LIBCPP_TEMPLATE_VIS fpos | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 534 | { | 
 | 535 | private: | 
 | 536 |     _StateT __st_; | 
 | 537 |     streamoff __off_; | 
 | 538 | public: | 
 | 539 |     _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {} | 
 | 540 |  | 
 | 541 |     _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;} | 
 | 542 |  | 
 | 543 |     _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;} | 
 | 544 |     _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;} | 
 | 545 |  | 
 | 546 |     _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;} | 
 | 547 |     _LIBCPP_INLINE_VISIBILITY fpos  operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;} | 
 | 548 |     _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;} | 
 | 549 |     _LIBCPP_INLINE_VISIBILITY fpos  operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;} | 
 | 550 | }; | 
 | 551 |  | 
 | 552 | template <class _StateT> | 
 | 553 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 554 | streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) | 
 | 555 |     {return streamoff(__x) - streamoff(__y);} | 
 | 556 |  | 
 | 557 | template <class _StateT> | 
 | 558 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 559 | bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) | 
 | 560 |     {return streamoff(__x) == streamoff(__y);} | 
 | 561 |  | 
 | 562 | template <class _StateT> | 
 | 563 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 564 | bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) | 
 | 565 |     {return streamoff(__x) != streamoff(__y);} | 
 | 566 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 567 | // basic_string | 
 | 568 |  | 
 | 569 | template<class _CharT, class _Traits, class _Allocator> | 
 | 570 | basic_string<_CharT, _Traits, _Allocator> | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 571 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, | 
 | 572 |           const basic_string<_CharT, _Traits, _Allocator>& __y); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 573 |  | 
 | 574 | template<class _CharT, class _Traits, class _Allocator> | 
 | 575 | basic_string<_CharT, _Traits, _Allocator> | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 576 | operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 577 |  | 
 | 578 | template<class _CharT, class _Traits, class _Allocator> | 
 | 579 | basic_string<_CharT, _Traits, _Allocator> | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 580 | operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 581 |  | 
 | 582 | template<class _CharT, class _Traits, class _Allocator> | 
 | 583 | basic_string<_CharT, _Traits, _Allocator> | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 584 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 585 |  | 
 | 586 | template<class _CharT, class _Traits, class _Allocator> | 
 | 587 | basic_string<_CharT, _Traits, _Allocator> | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 588 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 589 |  | 
| Shoaib Meenai | 487562f | 2017-07-29 02:54:41 +0000 | [diff] [blame] | 590 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&)) | 
 | 591 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 592 | template <bool> | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 593 | class _LIBCPP_TEMPLATE_VIS __basic_string_common | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 594 | { | 
 | 595 | protected: | 
| Marshall Clow | 14c09a2 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 596 |     _LIBCPP_NORETURN void __throw_length_error() const; | 
 | 597 |     _LIBCPP_NORETURN void __throw_out_of_range() const; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 598 | }; | 
 | 599 |  | 
 | 600 | template <bool __b> | 
 | 601 | void | 
 | 602 | __basic_string_common<__b>::__throw_length_error() const | 
 | 603 | { | 
| Marshall Clow | 14c09a2 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 604 |     _VSTD::__throw_length_error("basic_string"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 605 | } | 
 | 606 |  | 
 | 607 | template <bool __b> | 
 | 608 | void | 
 | 609 | __basic_string_common<__b>::__throw_out_of_range() const | 
 | 610 | { | 
| Marshall Clow | 14c09a2 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 611 |     _VSTD::__throw_out_of_range("basic_string"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 612 | } | 
 | 613 |  | 
| Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 614 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __basic_string_common<true>) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 615 |  | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 616 | #ifdef _LIBCPP_NO_EXCEPTIONS | 
 | 617 | template <class _Iter> | 
 | 618 | struct __libcpp_string_gets_noexcept_iterator_impl : public true_type {}; | 
 | 619 | #elif defined(_LIBCPP_HAS_NO_NOEXCEPT) | 
 | 620 | template <class _Iter> | 
 | 621 | struct __libcpp_string_gets_noexcept_iterator_impl : public false_type {}; | 
 | 622 | #else | 
 | 623 | template <class _Iter, bool = __is_forward_iterator<_Iter>::value> | 
 | 624 | struct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT(( | 
 | 625 |     noexcept(++(declval<_Iter&>())) &&  | 
 | 626 |     is_nothrow_assignable<_Iter&, _Iter>::value &&  | 
 | 627 |     noexcept(declval<_Iter>() == declval<_Iter>()) &&  | 
 | 628 |     noexcept(*declval<_Iter>()) | 
 | 629 | )) {}; | 
 | 630 |  | 
 | 631 | template <class _Iter>  | 
 | 632 | struct __libcpp_string_gets_noexcept_iterator_impl<_Iter, false> : public false_type {}; | 
 | 633 | #endif | 
 | 634 |  | 
 | 635 |  | 
 | 636 | template <class _Iter> | 
 | 637 | struct __libcpp_string_gets_noexcept_iterator | 
 | 638 |     : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {}; | 
 | 639 |  | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 640 | template <class _CharT, class _Traits, class _Tp> | 
 | 641 | struct __can_be_converted_to_string_view : public _LIBCPP_BOOL_CONSTANT( | 
| Marshall Clow | f1729d9 | 2017-11-15 20:02:27 +0000 | [diff] [blame] | 642 |     ( is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value && | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 643 |      !is_convertible<const _Tp&, const _CharT*>::value)) {}; | 
 | 644 |  | 
| Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 645 | #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 646 |  | 
 | 647 | template <class _CharT, size_t = sizeof(_CharT)> | 
 | 648 | struct __padding | 
 | 649 | { | 
 | 650 |     unsigned char __xx[sizeof(_CharT)-1]; | 
 | 651 | }; | 
 | 652 |  | 
 | 653 | template <class _CharT> | 
 | 654 | struct __padding<_CharT, 1> | 
 | 655 | { | 
 | 656 | }; | 
 | 657 |  | 
| Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 658 | #endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 659 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 660 | template<class _CharT, class _Traits, class _Allocator> | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 661 | class _LIBCPP_TEMPLATE_VIS basic_string | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 662 |     : private __basic_string_common<true> | 
 | 663 | { | 
 | 664 | public: | 
 | 665 |     typedef basic_string                                 __self; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 666 |     typedef basic_string_view<_CharT, _Traits>           __self_view; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 667 |     typedef _Traits                                      traits_type; | 
| Marshall Clow | 2d4c3fa | 2017-03-15 18:41:11 +0000 | [diff] [blame] | 668 |     typedef _CharT                                       value_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 669 |     typedef _Allocator                                   allocator_type; | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 670 |     typedef allocator_traits<allocator_type>             __alloc_traits; | 
 | 671 |     typedef typename __alloc_traits::size_type           size_type; | 
 | 672 |     typedef typename __alloc_traits::difference_type     difference_type; | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 673 |     typedef value_type&                                  reference; | 
 | 674 |     typedef const value_type&                            const_reference; | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 675 |     typedef typename __alloc_traits::pointer             pointer; | 
 | 676 |     typedef typename __alloc_traits::const_pointer       const_pointer; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 677 |  | 
| Marshall Clow | 256f187 | 2018-03-21 00:36:05 +0000 | [diff] [blame] | 678 |     static_assert((!is_array<value_type>::value), "Character type of basic_string must not be an array"); | 
 | 679 |     static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string must be standard-layout"); | 
 | 680 |     static_assert(( is_trivial<value_type>::value), "Character type of basic_string must be trivial"); | 
 | 681 |     static_assert(( is_same<_CharT, typename traits_type::char_type>::value), | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 682 |                   "traits_type::char_type must be the same type as CharT"); | 
| Marshall Clow | 256f187 | 2018-03-21 00:36:05 +0000 | [diff] [blame] | 683 |     static_assert(( is_same<typename allocator_type::value_type, value_type>::value), | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 684 |                   "Allocator::value_type must be same type as value_type"); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 685 |  | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 686 | #if defined(_LIBCPP_RAW_ITERATORS) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 687 |     typedef pointer                                      iterator; | 
 | 688 |     typedef const_pointer                                const_iterator; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 689 | #else  // defined(_LIBCPP_RAW_ITERATORS) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 690 |     typedef __wrap_iter<pointer>                         iterator; | 
 | 691 |     typedef __wrap_iter<const_pointer>                   const_iterator; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 692 | #endif  // defined(_LIBCPP_RAW_ITERATORS) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 693 |     typedef _VSTD::reverse_iterator<iterator>             reverse_iterator; | 
 | 694 |     typedef _VSTD::reverse_iterator<const_iterator>       const_reverse_iterator; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 695 |  | 
 | 696 | private: | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 697 |  | 
| Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 698 | #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 699 |  | 
 | 700 |     struct __long | 
 | 701 |     { | 
 | 702 |         pointer   __data_; | 
 | 703 |         size_type __size_; | 
 | 704 |         size_type __cap_; | 
 | 705 |     }; | 
 | 706 |  | 
| Eric Fiselier | 5ccf043 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 707 | #ifdef _LIBCPP_BIG_ENDIAN | 
| Ben Craig | de79ab6 | 2017-07-12 01:45:13 +0000 | [diff] [blame] | 708 |     static const size_type __short_mask = 0x01; | 
 | 709 |     static const size_type __long_mask  = 0x1ul; | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 710 | #else  // _LIBCPP_BIG_ENDIAN | 
| Ben Craig | de79ab6 | 2017-07-12 01:45:13 +0000 | [diff] [blame] | 711 |     static const size_type __short_mask = 0x80; | 
 | 712 |     static const size_type __long_mask  = ~(size_type(~0) >> 1); | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 713 | #endif  // _LIBCPP_BIG_ENDIAN | 
 | 714 |  | 
 | 715 |     enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? | 
 | 716 |                       (sizeof(__long) - 1)/sizeof(value_type) : 2}; | 
 | 717 |  | 
 | 718 |     struct __short | 
 | 719 |     { | 
 | 720 |         value_type __data_[__min_cap]; | 
 | 721 |         struct | 
 | 722 |             : __padding<value_type> | 
 | 723 |         { | 
 | 724 |             unsigned char __size_; | 
 | 725 |         }; | 
 | 726 |     }; | 
 | 727 |  | 
 | 728 | #else | 
 | 729 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 730 |     struct __long | 
 | 731 |     { | 
 | 732 |         size_type __cap_; | 
 | 733 |         size_type __size_; | 
 | 734 |         pointer   __data_; | 
 | 735 |     }; | 
 | 736 |  | 
| Eric Fiselier | 5ccf043 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 737 | #ifdef _LIBCPP_BIG_ENDIAN | 
| Ben Craig | de79ab6 | 2017-07-12 01:45:13 +0000 | [diff] [blame] | 738 |     static const size_type __short_mask = 0x80; | 
 | 739 |     static const size_type __long_mask  = ~(size_type(~0) >> 1); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 740 | #else  // _LIBCPP_BIG_ENDIAN | 
| Ben Craig | de79ab6 | 2017-07-12 01:45:13 +0000 | [diff] [blame] | 741 |     static const size_type __short_mask = 0x01; | 
 | 742 |     static const size_type __long_mask  = 0x1ul; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 743 | #endif  // _LIBCPP_BIG_ENDIAN | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 744 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 745 |     enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? | 
 | 746 |                       (sizeof(__long) - 1)/sizeof(value_type) : 2}; | 
 | 747 |  | 
 | 748 |     struct __short | 
 | 749 |     { | 
 | 750 |         union | 
 | 751 |         { | 
 | 752 |             unsigned char __size_; | 
| Howard Hinnant | 9c0df14 | 2012-10-30 19:06:59 +0000 | [diff] [blame] | 753 |             value_type __lx; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 754 |         }; | 
 | 755 |         value_type __data_[__min_cap]; | 
 | 756 |     }; | 
 | 757 |  | 
| Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 758 | #endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 759 |  | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 760 |     union __ulx{__long __lx; __short __lxx;}; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 761 |  | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 762 |     enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 763 |  | 
 | 764 |     struct __raw | 
 | 765 |     { | 
 | 766 |         size_type __words[__n_words]; | 
 | 767 |     }; | 
 | 768 |  | 
 | 769 |     struct __rep | 
 | 770 |     { | 
 | 771 |         union | 
 | 772 |         { | 
 | 773 |             __long  __l; | 
 | 774 |             __short __s; | 
 | 775 |             __raw   __r; | 
 | 776 |         }; | 
 | 777 |     }; | 
 | 778 |  | 
 | 779 |     __compressed_pair<__rep, allocator_type> __r_; | 
 | 780 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 781 | public: | 
 | 782 |     static const size_type npos = -1; | 
 | 783 |  | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 784 |     _LIBCPP_INLINE_VISIBILITY basic_string() | 
 | 785 |         _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); | 
| Marshall Clow | 7b193f7 | 2015-06-03 19:56:43 +0000 | [diff] [blame] | 786 |  | 
 | 787 |     _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) | 
 | 788 | #if _LIBCPP_STD_VER <= 14 | 
 | 789 |         _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); | 
 | 790 | #else | 
 | 791 |         _NOEXCEPT; | 
 | 792 | #endif | 
 | 793 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 794 |     basic_string(const basic_string& __str); | 
 | 795 |     basic_string(const basic_string& __str, const allocator_type& __a); | 
| Marshall Clow | 7b193f7 | 2015-06-03 19:56:43 +0000 | [diff] [blame] | 796 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 797 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 9f193f2 | 2011-01-26 00:06:59 +0000 | [diff] [blame] | 798 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 799 |     basic_string(basic_string&& __str) | 
| Marshall Clow | 7b193f7 | 2015-06-03 19:56:43 +0000 | [diff] [blame] | 800 | #if _LIBCPP_STD_VER <= 14 | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 801 |         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | 
| Marshall Clow | 7b193f7 | 2015-06-03 19:56:43 +0000 | [diff] [blame] | 802 | #else | 
 | 803 |         _NOEXCEPT; | 
 | 804 | #endif | 
 | 805 |  | 
| Howard Hinnant | 9f193f2 | 2011-01-26 00:06:59 +0000 | [diff] [blame] | 806 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 807 |     basic_string(basic_string&& __str, const allocator_type& __a); | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 808 | #endif  // _LIBCPP_CXX03_LANG | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 809 |  | 
| Marshall Clow | 7e3ab17 | 2018-10-16 16:02:18 +0000 | [diff] [blame] | 810 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 811 |     template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type> | 
| Marshall Clow | 7e3ab17 | 2018-10-16 16:02:18 +0000 | [diff] [blame] | 812 | #endif | 
| Eric Fiselier | ffbb91b | 2018-07-17 05:48:48 +0000 | [diff] [blame] | 813 |     _LIBCPP_INLINE_VISIBILITY | 
 | 814 |     basic_string(const _CharT* __s) { | 
 | 815 |       _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); | 
 | 816 |       __init(__s, traits_type::length(__s)); | 
 | 817 | #   if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 818 |       __get_db()->__insert_c(this); | 
 | 819 | #   endif | 
 | 820 |     } | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 821 |  | 
| Marshall Clow | 7e3ab17 | 2018-10-16 16:02:18 +0000 | [diff] [blame] | 822 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 823 |     template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type> | 
| Marshall Clow | 7e3ab17 | 2018-10-16 16:02:18 +0000 | [diff] [blame] | 824 | #endif | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 825 |         _LIBCPP_INLINE_VISIBILITY | 
 | 826 |         basic_string(const _CharT* __s, const _Allocator& __a); | 
 | 827 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 828 |     _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 829 |     basic_string(const _CharT* __s, size_type __n); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 830 |     _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 831 |     basic_string(const _CharT* __s, size_type __n, const _Allocator& __a); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 832 |     _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 833 |     basic_string(size_type __n, _CharT __c); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 834 |  | 
| Marshall Clow | 7e3ab17 | 2018-10-16 16:02:18 +0000 | [diff] [blame] | 835 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 836 |     template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type> | 
| Marshall Clow | 7e3ab17 | 2018-10-16 16:02:18 +0000 | [diff] [blame] | 837 | #endif | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 838 |         _LIBCPP_INLINE_VISIBILITY | 
 | 839 |         basic_string(size_type __n, _CharT __c, const _Allocator& __a); | 
 | 840 |  | 
| Marshall Clow | f4f7d8f | 2016-04-07 18:13:41 +0000 | [diff] [blame] | 841 |     basic_string(const basic_string& __str, size_type __pos, size_type __n, | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 842 |                  const _Allocator& __a = _Allocator()); | 
| Marshall Clow | f4f7d8f | 2016-04-07 18:13:41 +0000 | [diff] [blame] | 843 |     _LIBCPP_INLINE_VISIBILITY | 
 | 844 |     basic_string(const basic_string& __str, size_type __pos, | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 845 |                  const _Allocator& __a = _Allocator()); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 846 |  | 
 | 847 |     template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 848 |         _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 849 |         basic_string(const _Tp& __t, size_type __pos, size_type __n, | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 850 |                               const allocator_type& __a = allocator_type()); | 
 | 851 |  | 
 | 852 |     template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> | 
 | 853 |         _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 854 |         explicit basic_string(const _Tp& __t); | 
 | 855 |  | 
 | 856 |     template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> | 
 | 857 |         _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 858 |         explicit basic_string(const _Tp& __t, const allocator_type& __a); | 
 | 859 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 860 |     template<class _InputIterator> | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 861 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 862 |         basic_string(_InputIterator __first, _InputIterator __last); | 
 | 863 |     template<class _InputIterator> | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 864 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 865 |         basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 866 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 867 |     _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 868 |     basic_string(initializer_list<_CharT> __il); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 869 |     _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 870 |     basic_string(initializer_list<_CharT> __il, const _Allocator& __a); | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 871 | #endif  // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 872 |  | 
| Eric Fiselier | 51eb1d5 | 2016-10-31 03:42:50 +0000 | [diff] [blame] | 873 |     inline ~basic_string(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 874 |  | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 875 |     _LIBCPP_INLINE_VISIBILITY | 
 | 876 |     operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); } | 
 | 877 |  | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 878 |     basic_string& operator=(const basic_string& __str); | 
| Eric Fiselier | f472d6c | 2017-01-23 21:24:58 +0000 | [diff] [blame] | 879 |  | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 880 |     template <class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> | 
 | 881 |     basic_string& operator=(const _Tp& __t) | 
 | 882 |         {__self_view __sv = __t; return assign(__sv);} | 
 | 883 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 884 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 885 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 886 |     basic_string& operator=(basic_string&& __str) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 +0000 | [diff] [blame] | 887 |         _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 888 |      _LIBCPP_INLINE_VISIBILITY | 
 | 889 |     basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 890 | #endif | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 891 |     _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 892 |     basic_string& operator=(value_type __c); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 893 |  | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 894 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 895 |     _LIBCPP_INLINE_VISIBILITY | 
 | 896 |     iterator begin() _NOEXCEPT | 
 | 897 |         {return iterator(this, __get_pointer());} | 
 | 898 |     _LIBCPP_INLINE_VISIBILITY | 
 | 899 |     const_iterator begin() const _NOEXCEPT | 
 | 900 |         {return const_iterator(this, __get_pointer());} | 
 | 901 |     _LIBCPP_INLINE_VISIBILITY | 
 | 902 |     iterator end() _NOEXCEPT | 
 | 903 |         {return iterator(this, __get_pointer() + size());} | 
 | 904 |     _LIBCPP_INLINE_VISIBILITY | 
 | 905 |     const_iterator end() const _NOEXCEPT | 
 | 906 |         {return const_iterator(this, __get_pointer() + size());} | 
 | 907 | #else | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 908 |     _LIBCPP_INLINE_VISIBILITY | 
 | 909 |     iterator begin() _NOEXCEPT | 
 | 910 |         {return iterator(__get_pointer());} | 
 | 911 |     _LIBCPP_INLINE_VISIBILITY | 
 | 912 |     const_iterator begin() const _NOEXCEPT | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 913 |         {return const_iterator(__get_pointer());} | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 914 |     _LIBCPP_INLINE_VISIBILITY | 
 | 915 |     iterator end() _NOEXCEPT | 
 | 916 |         {return iterator(__get_pointer() + size());} | 
 | 917 |     _LIBCPP_INLINE_VISIBILITY | 
 | 918 |     const_iterator end() const _NOEXCEPT | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 919 |         {return const_iterator(__get_pointer() + size());} | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 920 | #endif  // _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 921 |     _LIBCPP_INLINE_VISIBILITY | 
 | 922 |     reverse_iterator rbegin() _NOEXCEPT | 
 | 923 |         {return reverse_iterator(end());} | 
 | 924 |     _LIBCPP_INLINE_VISIBILITY | 
 | 925 |     const_reverse_iterator rbegin() const _NOEXCEPT | 
 | 926 |         {return const_reverse_iterator(end());} | 
 | 927 |     _LIBCPP_INLINE_VISIBILITY | 
 | 928 |     reverse_iterator rend() _NOEXCEPT | 
 | 929 |         {return reverse_iterator(begin());} | 
 | 930 |     _LIBCPP_INLINE_VISIBILITY | 
 | 931 |     const_reverse_iterator rend() const _NOEXCEPT | 
 | 932 |         {return const_reverse_iterator(begin());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 933 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 934 |     _LIBCPP_INLINE_VISIBILITY | 
 | 935 |     const_iterator cbegin() const _NOEXCEPT | 
 | 936 |         {return begin();} | 
 | 937 |     _LIBCPP_INLINE_VISIBILITY | 
 | 938 |     const_iterator cend() const _NOEXCEPT | 
 | 939 |         {return end();} | 
 | 940 |     _LIBCPP_INLINE_VISIBILITY | 
 | 941 |     const_reverse_iterator crbegin() const _NOEXCEPT | 
 | 942 |         {return rbegin();} | 
 | 943 |     _LIBCPP_INLINE_VISIBILITY | 
 | 944 |     const_reverse_iterator crend() const _NOEXCEPT | 
 | 945 |         {return rend();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 946 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 947 |     _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 948 |         {return __is_long() ? __get_long_size() : __get_short_size();} | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 949 |     _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();} | 
 | 950 |     _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT; | 
 | 951 |     _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT | 
| Eric Fiselier | e2d4892 | 2015-08-28 07:02:42 +0000 | [diff] [blame] | 952 |         {return (__is_long() ? __get_long_cap() | 
 | 953 |                              : static_cast<size_type>(__min_cap)) - 1;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 954 |  | 
 | 955 |     void resize(size_type __n, value_type __c); | 
 | 956 |     _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} | 
 | 957 |  | 
| Eric Fiselier | 59e24fe | 2017-06-01 02:29:37 +0000 | [diff] [blame] | 958 |     void reserve(size_type __res_arg = 0); | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 959 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 960 |     void shrink_to_fit() _NOEXCEPT {reserve();} | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 961 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 962 |     void clear() _NOEXCEPT; | 
| Marshall Clow | f1729d9 | 2017-11-15 20:02:27 +0000 | [diff] [blame] | 963 |     _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | 
 | 964 |     bool empty() const _NOEXCEPT {return size() == 0;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 965 |  | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 966 |     _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT; | 
 | 967 |     _LIBCPP_INLINE_VISIBILITY reference       operator[](size_type __pos)       _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 968 |  | 
 | 969 |     const_reference at(size_type __n) const; | 
 | 970 |     reference       at(size_type __n); | 
 | 971 |  | 
 | 972 |     _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);} | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 973 |  | 
 | 974 |     template <class _Tp> | 
 | 975 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 976 |     typename enable_if | 
 | 977 |         < | 
 | 978 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 979 |             basic_string& | 
 | 980 |         >::type | 
 | 981 |                                             operator+=(const _Tp& __t)            {__self_view __sv = __t; return append(__sv);} | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 982 |     _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s)     {return append(__s);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 983 |     _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c)            {push_back(__c); return *this;} | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 984 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 985 |     _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);} | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 986 | #endif  // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 987 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 988 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 989 |     basic_string& append(const basic_string& __str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 990 |  | 
 | 991 |     template <class _Tp> | 
 | 992 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 993 |     typename enable_if | 
 | 994 |         < | 
 | 995 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 996 |             basic_string& | 
 | 997 |         >::type | 
 | 998 |                   append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); } | 
| Marshall Clow | a93b5e2 | 2014-03-04 19:17:19 +0000 | [diff] [blame] | 999 |     basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1000 |  | 
| Marshall Clow | 42a87db | 2016-10-03 23:40:48 +0000 | [diff] [blame] | 1001 |     template <class _Tp> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1002 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1003 |     typename enable_if | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 1004 |         < | 
 | 1005 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1006 |             basic_string& | 
 | 1007 |         >::type | 
 | 1008 |                   append(const _Tp& __t, size_type __pos, size_type __n=npos); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1009 |     basic_string& append(const value_type* __s, size_type __n); | 
 | 1010 |     basic_string& append(const value_type* __s); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1011 |     basic_string& append(size_type __n, value_type __c); | 
| Eric Fiselier | 026d38e | 2016-10-31 02:46:25 +0000 | [diff] [blame] | 1012 |     template <class _ForwardIterator> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1013 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1014 |     basic_string& __append_forward_unsafe(_ForwardIterator, _ForwardIterator); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1015 |     template<class _InputIterator> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1016 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1017 |     typename enable_if | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1018 |         < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 1019 |             __is_exactly_input_iterator<_InputIterator>::value | 
 | 1020 |                 || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1021 |             basic_string& | 
 | 1022 |         >::type | 
| Eric Fiselier | 026d38e | 2016-10-31 02:46:25 +0000 | [diff] [blame] | 1023 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1024 |     append(_InputIterator __first, _InputIterator __last) { | 
 | 1025 |       const basic_string __temp (__first, __last, __alloc()); | 
 | 1026 |       append(__temp.data(), __temp.size()); | 
 | 1027 |       return *this; | 
 | 1028 |     } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1029 |     template<class _ForwardIterator> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1030 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1031 |     typename enable_if | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1032 |         < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 1033 |             __is_forward_iterator<_ForwardIterator>::value | 
 | 1034 |                 && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1035 |             basic_string& | 
 | 1036 |         >::type | 
| Eric Fiselier | 026d38e | 2016-10-31 02:46:25 +0000 | [diff] [blame] | 1037 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1038 |     append(_ForwardIterator __first, _ForwardIterator __last) { | 
 | 1039 |       return __append_forward_unsafe(__first, __last); | 
 | 1040 |     } | 
 | 1041 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1042 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 1043 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1044 |     basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());} | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1045 | #endif  // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1046 |  | 
 | 1047 |     void push_back(value_type __c); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1048 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1049 |     void pop_back(); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1050 |     _LIBCPP_INLINE_VISIBILITY reference       front(); | 
 | 1051 |     _LIBCPP_INLINE_VISIBILITY const_reference front() const; | 
 | 1052 |     _LIBCPP_INLINE_VISIBILITY reference       back(); | 
 | 1053 |     _LIBCPP_INLINE_VISIBILITY const_reference back() const; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1054 |  | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1055 |     template <class _Tp> | 
 | 1056 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1057 |     typename enable_if | 
 | 1058 |         < | 
 | 1059 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1060 |             basic_string& | 
 | 1061 |         >::type | 
 | 1062 |                  assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); } | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 1063 |     _LIBCPP_INLINE_VISIBILITY | 
| Marshall Clow | f40ec90 | 2016-03-09 18:08:29 +0000 | [diff] [blame] | 1064 |     basic_string& assign(const basic_string& __str) { return *this = __str; } | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1065 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1066 |     _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 59e24fe | 2017-06-01 02:29:37 +0000 | [diff] [blame] | 1067 |     basic_string& assign(basic_string&& __str) | 
| Marshall Clow | 7ed093b | 2015-10-05 16:17:34 +0000 | [diff] [blame] | 1068 |         _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) | 
| Eric Fiselier | 59e24fe | 2017-06-01 02:29:37 +0000 | [diff] [blame] | 1069 |         {*this = _VSTD::move(__str); return *this;} | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1070 | #endif | 
| Marshall Clow | a93b5e2 | 2014-03-04 19:17:19 +0000 | [diff] [blame] | 1071 |     basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); | 
| Marshall Clow | 42a87db | 2016-10-03 23:40:48 +0000 | [diff] [blame] | 1072 |     template <class _Tp> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1073 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1074 |     typename enable_if | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 1075 |         < | 
 | 1076 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1077 |             basic_string& | 
 | 1078 |         >::type | 
| Eric Fiselier | 59e24fe | 2017-06-01 02:29:37 +0000 | [diff] [blame] | 1079 |                   assign(const _Tp & __t, size_type __pos, size_type __n=npos); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1080 |     basic_string& assign(const value_type* __s, size_type __n); | 
 | 1081 |     basic_string& assign(const value_type* __s); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1082 |     basic_string& assign(size_type __n, value_type __c); | 
 | 1083 |     template<class _InputIterator> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1084 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1085 |     typename enable_if | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1086 |         < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 1087 |            __is_exactly_input_iterator<_InputIterator>::value | 
 | 1088 |                 || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1089 |             basic_string& | 
 | 1090 |         >::type | 
 | 1091 |         assign(_InputIterator __first, _InputIterator __last); | 
 | 1092 |     template<class _ForwardIterator> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1093 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1094 |     typename enable_if | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1095 |         < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 1096 |             __is_forward_iterator<_ForwardIterator>::value | 
 | 1097 |                  && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1098 |             basic_string& | 
 | 1099 |         >::type | 
 | 1100 |         assign(_ForwardIterator __first, _ForwardIterator __last); | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1101 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 1102 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1103 |     basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());} | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1104 | #endif  // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1105 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1106 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1107 |     basic_string& insert(size_type __pos1, const basic_string& __str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1108 |  | 
 | 1109 |     template <class _Tp> | 
 | 1110 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1111 |     typename enable_if | 
 | 1112 |         < | 
 | 1113 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1114 |             basic_string& | 
 | 1115 |         >::type | 
 | 1116 |                  insert(size_type __pos1, const _Tp& __t) | 
 | 1117 |     { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); } | 
 | 1118 |  | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 1119 |     template <class _Tp> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1120 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1121 |     typename enable_if | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 1122 |         < | 
 | 1123 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1124 |             basic_string& | 
 | 1125 |         >::type | 
 | 1126 |                   insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos); | 
| Marshall Clow | a93b5e2 | 2014-03-04 19:17:19 +0000 | [diff] [blame] | 1127 |     basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1128 |     basic_string& insert(size_type __pos, const value_type* __s, size_type __n); | 
 | 1129 |     basic_string& insert(size_type __pos, const value_type* __s); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1130 |     basic_string& insert(size_type __pos, size_type __n, value_type __c); | 
 | 1131 |     iterator      insert(const_iterator __pos, value_type __c); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1132 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1133 |     iterator      insert(const_iterator __pos, size_type __n, value_type __c); | 
 | 1134 |     template<class _InputIterator> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1135 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1136 |     typename enable_if | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1137 |         < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 1138 |            __is_exactly_input_iterator<_InputIterator>::value | 
 | 1139 |                 || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1140 |             iterator | 
 | 1141 |         >::type | 
 | 1142 |         insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); | 
 | 1143 |     template<class _ForwardIterator> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1144 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1145 |     typename enable_if | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1146 |         < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 1147 |             __is_forward_iterator<_ForwardIterator>::value | 
 | 1148 |                  && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1149 |             iterator | 
 | 1150 |         >::type | 
 | 1151 |         insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1152 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 1153 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1154 |     iterator insert(const_iterator __pos, initializer_list<value_type> __il) | 
 | 1155 |                     {return insert(__pos, __il.begin(), __il.end());} | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1156 | #endif  // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1157 |  | 
 | 1158 |     basic_string& erase(size_type __pos = 0, size_type __n = npos); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1159 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1160 |     iterator      erase(const_iterator __pos); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1161 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1162 |     iterator      erase(const_iterator __first, const_iterator __last); | 
 | 1163 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1164 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1165 |     basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1166 |  | 
 | 1167 |     template <class _Tp> | 
 | 1168 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1169 |     typename enable_if | 
 | 1170 |         < | 
 | 1171 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1172 |             basic_string& | 
 | 1173 |         >::type | 
 | 1174 |                   replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); } | 
| Marshall Clow | a93b5e2 | 2014-03-04 19:17:19 +0000 | [diff] [blame] | 1175 |     basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 1176 |     template <class _Tp> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1177 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1178 |     typename enable_if | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 1179 |         < | 
 | 1180 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1181 |             basic_string& | 
 | 1182 |         >::type | 
 | 1183 |                   replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1184 |     basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); | 
 | 1185 |     basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1186 |     basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1187 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7b2cb48 | 2010-11-17 21:11:40 +0000 | [diff] [blame] | 1188 |     basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str); | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1189 |  | 
 | 1190 |     template <class _Tp> | 
 | 1191 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1192 |     typename enable_if | 
 | 1193 |         < | 
 | 1194 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1195 |             basic_string& | 
 | 1196 |         >::type | 
 | 1197 |                   replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); } | 
 | 1198 |  | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 1199 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1200 |     basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1201 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1202 |     basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1203 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7b2cb48 | 2010-11-17 21:11:40 +0000 | [diff] [blame] | 1204 |     basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1205 |     template<class _InputIterator> | 
| Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 1206 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1207 |     typename enable_if | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1208 |         < | 
 | 1209 |             __is_input_iterator<_InputIterator>::value, | 
 | 1210 |             basic_string& | 
 | 1211 |         >::type | 
| Howard Hinnant | 7b2cb48 | 2010-11-17 21:11:40 +0000 | [diff] [blame] | 1212 |         replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1213 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 1214 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7b2cb48 | 2010-11-17 21:11:40 +0000 | [diff] [blame] | 1215 |     basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1216 |         {return replace(__i1, __i2, __il.begin(), __il.end());} | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1217 | #endif  // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1218 |  | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1219 |     size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1220 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1221 |     basic_string substr(size_type __pos = 0, size_type __n = npos) const; | 
 | 1222 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1223 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 1224 |     void swap(basic_string& __str) | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 1225 | #if _LIBCPP_STD_VER >= 14 | 
| Eric Fiselier | 47257c4 | 2016-12-28 05:53:01 +0000 | [diff] [blame] | 1226 |         _NOEXCEPT_DEBUG; | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 1227 | #else | 
| Eric Fiselier | 47257c4 | 2016-12-28 05:53:01 +0000 | [diff] [blame] | 1228 |         _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value || | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 1229 |                     __is_nothrow_swappable<allocator_type>::value); | 
 | 1230 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1231 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1232 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1233 |     const value_type* c_str() const _NOEXCEPT {return data();} | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1234 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1235 |     const value_type* data() const _NOEXCEPT  {return _VSTD::__to_raw_pointer(__get_pointer());} | 
| Eric Fiselier | 10bebe2 | 2017-11-20 20:23:27 +0000 | [diff] [blame] | 1236 | #if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY) | 
| Marshall Clow | f532a70 | 2016-03-08 15:44:30 +0000 | [diff] [blame] | 1237 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1238 |     value_type* data()             _NOEXCEPT  {return _VSTD::__to_raw_pointer(__get_pointer());} | 
 | 1239 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1240 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1241 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1242 |     allocator_type get_allocator() const _NOEXCEPT {return __alloc();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1243 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1244 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1245 |     size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1246 |  | 
 | 1247 |     template <class _Tp> | 
 | 1248 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1249 |     typename enable_if | 
 | 1250 |         < | 
 | 1251 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1252 |             size_type | 
 | 1253 |         >::type | 
 | 1254 |               find(const _Tp& __t, size_type __pos = 0) const; | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1255 |     size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1256 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1257 |     size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1258 |     size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1259 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1260 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1261 |     size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1262 |  | 
 | 1263 |     template <class _Tp> | 
 | 1264 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1265 |     typename enable_if | 
 | 1266 |         < | 
 | 1267 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1268 |             size_type | 
 | 1269 |         >::type | 
 | 1270 |               rfind(const _Tp& __t, size_type __pos = npos) const; | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1271 |     size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1272 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1273 |     size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1274 |     size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1275 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1276 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1277 |     size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1278 |  | 
 | 1279 |     template <class _Tp> | 
 | 1280 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1281 |     typename enable_if | 
 | 1282 |         < | 
 | 1283 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1284 |             size_type | 
 | 1285 |         >::type | 
 | 1286 |               find_first_of(const _Tp& __t, size_type __pos = 0) const; | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1287 |     size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1288 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1289 |     size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1290 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1291 |     size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1292 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1293 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1294 |     size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1295 |  | 
 | 1296 |     template <class _Tp> | 
 | 1297 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1298 |     typename enable_if | 
 | 1299 |         < | 
 | 1300 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1301 |             size_type | 
 | 1302 |         >::type | 
 | 1303 |               find_last_of(const _Tp& __t, size_type __pos = npos) const; | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1304 |     size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1305 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1306 |     size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1307 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1308 |     size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1309 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1310 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1311 |     size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1312 |  | 
 | 1313 |     template <class _Tp> | 
 | 1314 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1315 |     typename enable_if | 
 | 1316 |         < | 
 | 1317 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1318 |             size_type | 
 | 1319 |         >::type | 
 | 1320 |               find_first_not_of(const _Tp &__t, size_type __pos = 0) const; | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1321 |     size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1322 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1323 |     size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1324 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1325 |     size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; | 
 | 1326 |  | 
 | 1327 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1328 |     size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1329 |  | 
 | 1330 |     template <class _Tp> | 
 | 1331 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1332 |     typename enable_if | 
 | 1333 |         < | 
 | 1334 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1335 |             size_type | 
 | 1336 |         >::type | 
 | 1337 |               find_last_not_of(const _Tp& __t, size_type __pos = npos) const; | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1338 |     size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1339 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1340 |     size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1341 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1342 |     size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; | 
 | 1343 |  | 
 | 1344 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1345 |     int compare(const basic_string& __str) const _NOEXCEPT; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1346 |  | 
 | 1347 |     template <class _Tp> | 
 | 1348 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1349 |     typename enable_if | 
 | 1350 |         < | 
 | 1351 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1352 |             int | 
 | 1353 |         >::type | 
 | 1354 |         compare(const _Tp &__t) const; | 
 | 1355 |  | 
 | 1356 |     template <class _Tp> | 
 | 1357 |     _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 
 | 1358 |     typename enable_if | 
 | 1359 |         < | 
 | 1360 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1361 |             int | 
 | 1362 |         >::type | 
 | 1363 |          compare(size_type __pos1, size_type __n1, const _Tp& __t) const; | 
 | 1364 |  | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 1365 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1366 |     int compare(size_type __pos1, size_type __n1, const basic_string& __str) const; | 
| Marshall Clow | a93b5e2 | 2014-03-04 19:17:19 +0000 | [diff] [blame] | 1367 |     int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1368 |  | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 1369 |     template <class _Tp> | 
| Eric Fiselier | 9dbc053 | 2016-10-14 05:29:46 +0000 | [diff] [blame] | 1370 |     inline _LIBCPP_INLINE_VISIBILITY | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 1371 |         typename enable_if | 
 | 1372 |         < | 
 | 1373 |             __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 1374 |             int | 
 | 1375 |         >::type | 
 | 1376 |         compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const; | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1377 |     int compare(const value_type* __s) const _NOEXCEPT; | 
 | 1378 |     int compare(size_type __pos1, size_type __n1, const value_type* __s) const; | 
 | 1379 |     int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1380 |  | 
| Marshall Clow | 46b4ad5 | 2017-12-04 20:11:38 +0000 | [diff] [blame] | 1381 | #if _LIBCPP_STD_VER > 17 | 
 | 1382 |     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | 
 | 1383 |     bool starts_with(__self_view __sv) const _NOEXCEPT | 
 | 1384 |     { return __self_view(data(), size()).starts_with(__sv); } | 
 | 1385 |  | 
 | 1386 |     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | 
 | 1387 |     bool starts_with(value_type __c) const _NOEXCEPT | 
 | 1388 |     { return !empty() && _Traits::eq(front(), __c); } | 
 | 1389 |  | 
 | 1390 |     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | 
 | 1391 |     bool starts_with(const value_type* __s) const _NOEXCEPT | 
 | 1392 |     { return starts_with(__self_view(__s)); } | 
 | 1393 |  | 
 | 1394 |     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | 
 | 1395 |     bool ends_with(__self_view __sv) const _NOEXCEPT | 
 | 1396 |     { return __self_view(data(), size()).ends_with( __sv); } | 
 | 1397 |  | 
 | 1398 |     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | 
 | 1399 |     bool ends_with(value_type __c) const _NOEXCEPT | 
 | 1400 |     { return !empty() && _Traits::eq(back(), __c); } | 
 | 1401 |  | 
 | 1402 |     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | 
 | 1403 |     bool ends_with(const value_type* __s) const _NOEXCEPT | 
 | 1404 |     { return ends_with(__self_view(__s)); } | 
 | 1405 | #endif | 
 | 1406 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1407 |     _LIBCPP_INLINE_VISIBILITY bool __invariants() const; | 
| Howard Hinnant | 08dd253 | 2013-04-22 23:55:13 +0000 | [diff] [blame] | 1408 |  | 
| Marshall Clow | ab343bb | 2018-05-29 17:04:37 +0000 | [diff] [blame] | 1409 |     _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT; | 
| Vedant Kumar | 2b588cb | 2018-03-08 21:15:26 +0000 | [diff] [blame] | 1410 |      | 
| Howard Hinnant | 08dd253 | 2013-04-22 23:55:13 +0000 | [diff] [blame] | 1411 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1412 |     bool __is_long() const _NOEXCEPT | 
 | 1413 |         {return bool(__r_.first().__s.__size_ & __short_mask);} | 
 | 1414 |  | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1415 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1416 |  | 
 | 1417 |     bool __dereferenceable(const const_iterator* __i) const; | 
 | 1418 |     bool __decrementable(const const_iterator* __i) const; | 
 | 1419 |     bool __addable(const const_iterator* __i, ptrdiff_t __n) const; | 
 | 1420 |     bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; | 
 | 1421 |  | 
 | 1422 | #endif  // _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1423 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1424 | private: | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1425 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1426 |     allocator_type& __alloc() _NOEXCEPT | 
 | 1427 |         {return __r_.second();} | 
 | 1428 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1429 |     const allocator_type& __alloc() const _NOEXCEPT | 
 | 1430 |         {return __r_.second();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1431 |  | 
| Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 1432 | #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 1433 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1434 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1435 |     void __set_short_size(size_type __s) _NOEXCEPT | 
| Eric Fiselier | 5ccf043 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 1436 | #   ifdef _LIBCPP_BIG_ENDIAN | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1437 |         {__r_.first().__s.__size_ = (unsigned char)(__s << 1);} | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 1438 | #   else | 
 | 1439 |         {__r_.first().__s.__size_ = (unsigned char)(__s);} | 
 | 1440 | #   endif | 
 | 1441 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1442 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1443 |     size_type __get_short_size() const _NOEXCEPT | 
| Eric Fiselier | 5ccf043 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 1444 | #   ifdef _LIBCPP_BIG_ENDIAN | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1445 |         {return __r_.first().__s.__size_ >> 1;} | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 1446 | #   else | 
 | 1447 |         {return __r_.first().__s.__size_;} | 
 | 1448 | #   endif | 
 | 1449 |  | 
| Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 1450 | #else  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 1451 |  | 
 | 1452 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1453 |     void __set_short_size(size_type __s) _NOEXCEPT | 
| Eric Fiselier | 5ccf043 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 1454 | #   ifdef _LIBCPP_BIG_ENDIAN | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 1455 |         {__r_.first().__s.__size_ = (unsigned char)(__s);} | 
 | 1456 | #   else | 
 | 1457 |         {__r_.first().__s.__size_ = (unsigned char)(__s << 1);} | 
 | 1458 | #   endif | 
 | 1459 |  | 
 | 1460 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1461 |     size_type __get_short_size() const _NOEXCEPT | 
| Eric Fiselier | 5ccf043 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 1462 | #   ifdef _LIBCPP_BIG_ENDIAN | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 1463 |         {return __r_.first().__s.__size_;} | 
 | 1464 | #   else | 
 | 1465 |         {return __r_.first().__s.__size_ >> 1;} | 
 | 1466 | #   endif | 
 | 1467 |  | 
| Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 1468 | #endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 1469 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1470 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1471 |     void __set_long_size(size_type __s) _NOEXCEPT | 
 | 1472 |         {__r_.first().__l.__size_ = __s;} | 
 | 1473 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1474 |     size_type __get_long_size() const _NOEXCEPT | 
 | 1475 |         {return __r_.first().__l.__size_;} | 
 | 1476 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1477 |     void __set_size(size_type __s) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1478 |         {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);} | 
 | 1479 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1480 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1481 |     void __set_long_cap(size_type __s) _NOEXCEPT | 
 | 1482 |         {__r_.first().__l.__cap_  = __long_mask | __s;} | 
 | 1483 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1484 |     size_type __get_long_cap() const _NOEXCEPT | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 1485 |         {return __r_.first().__l.__cap_ & size_type(~__long_mask);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1486 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1487 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1488 |     void __set_long_pointer(pointer __p) _NOEXCEPT | 
 | 1489 |         {__r_.first().__l.__data_ = __p;} | 
 | 1490 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1491 |     pointer __get_long_pointer() _NOEXCEPT | 
 | 1492 |         {return __r_.first().__l.__data_;} | 
 | 1493 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1494 |     const_pointer __get_long_pointer() const _NOEXCEPT | 
 | 1495 |         {return __r_.first().__l.__data_;} | 
 | 1496 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1497 |     pointer __get_short_pointer() _NOEXCEPT | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1498 |         {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);} | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1499 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1500 |     const_pointer __get_short_pointer() const _NOEXCEPT | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1501 |         {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);} | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1502 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1503 |     pointer __get_pointer() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1504 |         {return __is_long() ? __get_long_pointer() : __get_short_pointer();} | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1505 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1506 |     const_pointer __get_pointer() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1507 |         {return __is_long() ? __get_long_pointer() : __get_short_pointer();} | 
 | 1508 |  | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1509 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1510 |     void __zero() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1511 |         { | 
 | 1512 |             size_type (&__a)[__n_words] = __r_.first().__r.__words; | 
 | 1513 |             for (unsigned __i = 0; __i < __n_words; ++__i) | 
 | 1514 |                 __a[__i] = 0; | 
 | 1515 |         } | 
 | 1516 |  | 
 | 1517 |     template <size_type __a> static | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1518 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7f76450 | 2013-08-14 18:00:20 +0000 | [diff] [blame] | 1519 |         size_type __align_it(size_type __s) _NOEXCEPT | 
| Eric Fiselier | e2d4892 | 2015-08-28 07:02:42 +0000 | [diff] [blame] | 1520 |             {return (__s + (__a-1)) & ~(__a-1);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1521 |     enum {__alignment = 16}; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 1522 |     static _LIBCPP_INLINE_VISIBILITY | 
 | 1523 |     size_type __recommend(size_type __s) _NOEXCEPT | 
| Marshall Clow | 088e601 | 2018-02-07 21:30:17 +0000 | [diff] [blame] | 1524 |         { | 
 | 1525 |         if (__s < __min_cap) return static_cast<size_type>(__min_cap) - 1; | 
 | 1526 |         size_type __guess = __align_it<sizeof(value_type) < __alignment ? | 
 | 1527 |                      __alignment/sizeof(value_type) : 1 > (__s+1) - 1; | 
 | 1528 |         if (__guess == __min_cap) ++__guess; | 
 | 1529 |         return __guess; | 
 | 1530 |         } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1531 |  | 
| Duncan P. N. Exon Smith | ed3c0e6 | 2017-04-01 03:20:48 +0000 | [diff] [blame] | 1532 |     inline | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1533 |     void __init(const value_type* __s, size_type __sz, size_type __reserve); | 
| Duncan P. N. Exon Smith | ed3c0e6 | 2017-04-01 03:20:48 +0000 | [diff] [blame] | 1534 |     inline | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1535 |     void __init(const value_type* __s, size_type __sz); | 
| Duncan P. N. Exon Smith | ed3c0e6 | 2017-04-01 03:20:48 +0000 | [diff] [blame] | 1536 |     inline | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1537 |     void __init(size_type __n, value_type __c); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1538 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1539 |     template <class _InputIterator> | 
| Duncan P. N. Exon Smith | ed3c0e6 | 2017-04-01 03:20:48 +0000 | [diff] [blame] | 1540 |     inline | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1541 |     typename enable_if | 
 | 1542 |     < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 1543 |         __is_exactly_input_iterator<_InputIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1544 |         void | 
 | 1545 |     >::type | 
 | 1546 |     __init(_InputIterator __first, _InputIterator __last); | 
 | 1547 |  | 
 | 1548 |     template <class _ForwardIterator> | 
| Duncan P. N. Exon Smith | ed3c0e6 | 2017-04-01 03:20:48 +0000 | [diff] [blame] | 1549 |     inline | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1550 |     typename enable_if | 
 | 1551 |     < | 
 | 1552 |         __is_forward_iterator<_ForwardIterator>::value, | 
 | 1553 |         void | 
 | 1554 |     >::type | 
 | 1555 |     __init(_ForwardIterator __first, _ForwardIterator __last); | 
 | 1556 |  | 
 | 1557 |     void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1558 |                    size_type __n_copy,  size_type __n_del,     size_type __n_add = 0); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1559 |     void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz, | 
 | 1560 |                                size_type __n_copy,  size_type __n_del, | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1561 |                                size_type __n_add, const value_type* __p_new_stuff); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1562 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1563 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1564 |     void __erase_to_end(size_type __pos); | 
 | 1565 |  | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 1566 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1567 |     void __copy_assign_alloc(const basic_string& __str) | 
 | 1568 |         {__copy_assign_alloc(__str, integral_constant<bool, | 
 | 1569 |                       __alloc_traits::propagate_on_container_copy_assignment::value>());} | 
 | 1570 |  | 
 | 1571 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1572 |     void __copy_assign_alloc(const basic_string& __str, true_type) | 
 | 1573 |         { | 
| Marshall Clow | 9247fd2 | 2017-01-31 03:40:52 +0000 | [diff] [blame] | 1574 |             if (__alloc() == __str.__alloc()) | 
 | 1575 |                 __alloc() = __str.__alloc(); | 
 | 1576 |             else | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 1577 |             { | 
| Marshall Clow | 9247fd2 | 2017-01-31 03:40:52 +0000 | [diff] [blame] | 1578 |                 if (!__str.__is_long()) | 
 | 1579 |                 { | 
| Vedant Kumar | 2b588cb | 2018-03-08 21:15:26 +0000 | [diff] [blame] | 1580 |                     __clear_and_shrink(); | 
| Marshall Clow | 9247fd2 | 2017-01-31 03:40:52 +0000 | [diff] [blame] | 1581 |                     __alloc() = __str.__alloc(); | 
 | 1582 |                 } | 
 | 1583 |                 else | 
 | 1584 |                 { | 
 | 1585 |                     allocator_type __a = __str.__alloc(); | 
 | 1586 |                     pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap()); | 
| Vedant Kumar | 2b588cb | 2018-03-08 21:15:26 +0000 | [diff] [blame] | 1587 |                     __clear_and_shrink(); | 
| Marshall Clow | 9247fd2 | 2017-01-31 03:40:52 +0000 | [diff] [blame] | 1588 |                     __alloc() = _VSTD::move(__a); | 
 | 1589 |                     __set_long_pointer(__p); | 
 | 1590 |                     __set_long_cap(__str.__get_long_cap()); | 
 | 1591 |                     __set_long_size(__str.size()); | 
 | 1592 |                 } | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 1593 |             } | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 1594 |         } | 
 | 1595 |  | 
 | 1596 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 1597 |     void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 1598 |         {} | 
 | 1599 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1600 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1601 |     _LIBCPP_INLINE_VISIBILITY | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 +0000 | [diff] [blame] | 1602 |     void __move_assign(basic_string& __str, false_type) | 
 | 1603 |         _NOEXCEPT_(__alloc_traits::is_always_equal::value); | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1604 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 1605 |     void __move_assign(basic_string& __str, true_type) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 +0000 | [diff] [blame] | 1606 | #if _LIBCPP_STD_VER > 14 | 
 | 1607 |         _NOEXCEPT; | 
 | 1608 | #else | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 1609 |         _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 1610 | #endif | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 +0000 | [diff] [blame] | 1611 | #endif | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 1612 |  | 
 | 1613 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3fdbbd2 | 2011-08-17 20:36:18 +0000 | [diff] [blame] | 1614 |     void | 
| Howard Hinnant | 9cbee43 | 2011-09-02 20:42:31 +0000 | [diff] [blame] | 1615 |     __move_assign_alloc(basic_string& __str) | 
| Howard Hinnant | 3fdbbd2 | 2011-08-17 20:36:18 +0000 | [diff] [blame] | 1616 |         _NOEXCEPT_( | 
 | 1617 |             !__alloc_traits::propagate_on_container_move_assignment::value || | 
 | 1618 |             is_nothrow_move_assignable<allocator_type>::value) | 
 | 1619 |     {__move_assign_alloc(__str, integral_constant<bool, | 
 | 1620 |                       __alloc_traits::propagate_on_container_move_assignment::value>());} | 
 | 1621 |  | 
 | 1622 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9cbee43 | 2011-09-02 20:42:31 +0000 | [diff] [blame] | 1623 |     void __move_assign_alloc(basic_string& __c, true_type) | 
| Howard Hinnant | 3fdbbd2 | 2011-08-17 20:36:18 +0000 | [diff] [blame] | 1624 |         _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | 
 | 1625 |         { | 
 | 1626 |             __alloc() = _VSTD::move(__c.__alloc()); | 
 | 1627 |         } | 
 | 1628 |  | 
 | 1629 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 1630 |     void __move_assign_alloc(basic_string&, false_type) | 
| Howard Hinnant | 3fdbbd2 | 2011-08-17 20:36:18 +0000 | [diff] [blame] | 1631 |         _NOEXCEPT | 
 | 1632 |         {} | 
 | 1633 |  | 
| Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 1634 |     _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); | 
 | 1635 |     _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1636 |  | 
 | 1637 |     friend basic_string operator+<>(const basic_string&, const basic_string&); | 
 | 1638 |     friend basic_string operator+<>(const value_type*, const basic_string&); | 
 | 1639 |     friend basic_string operator+<>(value_type, const basic_string&); | 
 | 1640 |     friend basic_string operator+<>(const basic_string&, const value_type*); | 
 | 1641 |     friend basic_string operator+<>(const basic_string&, value_type); | 
 | 1642 | }; | 
 | 1643 |  | 
| Marshall Clow | 5b1e87e | 2018-02-08 06:34:03 +0000 | [diff] [blame] | 1644 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | 
 | 1645 | template<class _InputIterator, | 
 | 1646 |          class _CharT = typename iterator_traits<_InputIterator>::value_type, | 
 | 1647 |          class _Allocator = allocator<_CharT>, | 
 | 1648 |          class = typename enable_if<__is_input_iterator<_InputIterator>::value, void>::type, | 
 | 1649 |          class = typename enable_if<__is_allocator<_Allocator>::value, void>::type | 
 | 1650 |          > | 
 | 1651 | basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) | 
 | 1652 |   -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1653 |  | 
 | 1654 | template<class _CharT, | 
 | 1655 |          class _Traits, | 
 | 1656 |          class _Allocator = allocator<_CharT>, | 
 | 1657 |          class = typename enable_if<__is_allocator<_Allocator>::value, void>::type | 
 | 1658 |          > | 
 | 1659 | explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) | 
 | 1660 |   -> basic_string<_CharT, _Traits, _Allocator>; | 
 | 1661 |  | 
 | 1662 | template<class _CharT, | 
 | 1663 |          class _Traits, | 
 | 1664 |          class _Allocator = allocator<_CharT>, | 
 | 1665 |          class = typename enable_if<__is_allocator<_Allocator>::value, void>::type, | 
 | 1666 |          class _Sz = typename allocator_traits<_Allocator>::size_type | 
 | 1667 |          > | 
 | 1668 | basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) | 
 | 1669 |   -> basic_string<_CharT, _Traits, _Allocator>; | 
| Marshall Clow | 5b1e87e | 2018-02-08 06:34:03 +0000 | [diff] [blame] | 1670 | #endif | 
 | 1671 |  | 
 | 1672 |                    | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1673 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 1674 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1675 | void | 
 | 1676 | basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() | 
 | 1677 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1678 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1679 |     __get_db()->__invalidate_all(this); | 
 | 1680 | #endif  // _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1681 | } | 
 | 1682 |  | 
 | 1683 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 1684 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1685 | void | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 1686 | basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1687 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 1688 |                                                                         __pos | 
 | 1689 | #endif | 
 | 1690 |                                                                       ) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1691 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1692 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1693 |     __c_node* __c = __get_db()->__find_c_and_lock(this); | 
 | 1694 |     if (__c) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1695 |     { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1696 |         const_pointer __new_last = __get_pointer() + __pos; | 
 | 1697 |         for (__i_node** __p = __c->end_; __p != __c->beg_; ) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1698 |         { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1699 |             --__p; | 
 | 1700 |             const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); | 
 | 1701 |             if (__i->base() > __new_last) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1702 |             { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1703 |                 (*__p)->__c_ = nullptr; | 
 | 1704 |                 if (--__c->end_ != __p) | 
 | 1705 |                     memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1706 |             } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1707 |         } | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1708 |         __get_db()->unlock(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1709 |     } | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1710 | #endif  // _LIBCPP_DEBUG_LEVEL >= 2 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1711 | } | 
 | 1712 |  | 
 | 1713 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 1714 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 1715 | basic_string<_CharT, _Traits, _Allocator>::basic_string() | 
| Marshall Clow | c912c0c | 2015-06-04 02:05:41 +0000 | [diff] [blame] | 1716 |     _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1717 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1718 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1719 |     __get_db()->__insert_c(this); | 
 | 1720 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1721 |     __zero(); | 
 | 1722 | } | 
 | 1723 |  | 
 | 1724 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 1725 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1726 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) | 
| Eric Fiselier | 692177d | 2015-07-18 20:40:46 +0000 | [diff] [blame] | 1727 | #if _LIBCPP_STD_VER <= 14 | 
 | 1728 |         _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) | 
 | 1729 | #else | 
 | 1730 |         _NOEXCEPT | 
 | 1731 | #endif | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1732 | : __r_(__second_tag(), __a) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1733 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1734 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1735 |     __get_db()->__insert_c(this); | 
 | 1736 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1737 |     __zero(); | 
 | 1738 | } | 
 | 1739 |  | 
 | 1740 | template <class _CharT, class _Traits, class _Allocator> | 
| Eric Fiselier | 6dbed46 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 1741 | void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, | 
 | 1742 |                                                        size_type __sz, | 
 | 1743 |                                                        size_type __reserve) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1744 | { | 
 | 1745 |     if (__reserve > max_size()) | 
 | 1746 |         this->__throw_length_error(); | 
 | 1747 |     pointer __p; | 
 | 1748 |     if (__reserve < __min_cap) | 
 | 1749 |     { | 
 | 1750 |         __set_short_size(__sz); | 
 | 1751 |         __p = __get_short_pointer(); | 
 | 1752 |     } | 
 | 1753 |     else | 
 | 1754 |     { | 
 | 1755 |         size_type __cap = __recommend(__reserve); | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 1756 |         __p = __alloc_traits::allocate(__alloc(), __cap+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1757 |         __set_long_pointer(__p); | 
 | 1758 |         __set_long_cap(__cap+1); | 
 | 1759 |         __set_long_size(__sz); | 
 | 1760 |     } | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1761 |     traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1762 |     traits_type::assign(__p[__sz], value_type()); | 
 | 1763 | } | 
 | 1764 |  | 
 | 1765 | template <class _CharT, class _Traits, class _Allocator> | 
 | 1766 | void | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1767 | basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1768 | { | 
 | 1769 |     if (__sz > max_size()) | 
 | 1770 |         this->__throw_length_error(); | 
 | 1771 |     pointer __p; | 
 | 1772 |     if (__sz < __min_cap) | 
 | 1773 |     { | 
 | 1774 |         __set_short_size(__sz); | 
 | 1775 |         __p = __get_short_pointer(); | 
 | 1776 |     } | 
 | 1777 |     else | 
 | 1778 |     { | 
 | 1779 |         size_type __cap = __recommend(__sz); | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 1780 |         __p = __alloc_traits::allocate(__alloc(), __cap+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1781 |         __set_long_pointer(__p); | 
 | 1782 |         __set_long_cap(__cap+1); | 
 | 1783 |         __set_long_size(__sz); | 
 | 1784 |     } | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1785 |     traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1786 |     traits_type::assign(__p[__sz], value_type()); | 
 | 1787 | } | 
 | 1788 |  | 
 | 1789 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 7e3ab17 | 2018-10-16 16:02:18 +0000 | [diff] [blame] | 1790 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1791 | template <class> | 
| Marshall Clow | 7e3ab17 | 2018-10-16 16:02:18 +0000 | [diff] [blame] | 1792 | #endif | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 1793 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1794 |     : __r_(__second_tag(), __a) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1795 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1796 |     _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1797 |     __init(__s, traits_type::length(__s)); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1798 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1799 |     __get_db()->__insert_c(this); | 
 | 1800 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1801 | } | 
 | 1802 |  | 
 | 1803 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 1804 | inline _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 1805 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1806 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1807 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1808 |     __init(__s, __n); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1809 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1810 |     __get_db()->__insert_c(this); | 
 | 1811 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1812 | } | 
 | 1813 |  | 
 | 1814 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 1815 | inline _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 1816 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1817 |     : __r_(__second_tag(), __a) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1818 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1819 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1820 |     __init(__s, __n); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1821 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1822 |     __get_db()->__insert_c(this); | 
 | 1823 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1824 | } | 
 | 1825 |  | 
 | 1826 | template <class _CharT, class _Traits, class _Allocator> | 
 | 1827 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1828 |     : __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1829 | { | 
 | 1830 |     if (!__str.__is_long()) | 
 | 1831 |         __r_.first().__r = __str.__r_.first().__r; | 
 | 1832 |     else | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1833 |         __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1834 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1835 |     __get_db()->__insert_c(this); | 
 | 1836 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1837 | } | 
 | 1838 |  | 
 | 1839 | template <class _CharT, class _Traits, class _Allocator> | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 1840 | basic_string<_CharT, _Traits, _Allocator>::basic_string( | 
 | 1841 |     const basic_string& __str, const allocator_type& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1842 |     : __r_(__second_tag(), __a) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1843 | { | 
 | 1844 |     if (!__str.__is_long()) | 
 | 1845 |         __r_.first().__r = __str.__r_.first().__r; | 
 | 1846 |     else | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1847 |         __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1848 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1849 |     __get_db()->__insert_c(this); | 
 | 1850 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1851 | } | 
 | 1852 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1853 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1854 |  | 
 | 1855 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 1856 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 1857 | basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) | 
| Marshall Clow | 7b193f7 | 2015-06-03 19:56:43 +0000 | [diff] [blame] | 1858 | #if _LIBCPP_STD_VER <= 14 | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 1859 |         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | 
| Marshall Clow | 7b193f7 | 2015-06-03 19:56:43 +0000 | [diff] [blame] | 1860 | #else | 
 | 1861 |         _NOEXCEPT | 
 | 1862 | #endif | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1863 |     : __r_(_VSTD::move(__str.__r_)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1864 | { | 
 | 1865 |     __str.__zero(); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1866 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1867 |     __get_db()->__insert_c(this); | 
 | 1868 |     if (__is_long()) | 
 | 1869 |         __get_db()->swap(this, &__str); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1870 | #endif | 
 | 1871 | } | 
 | 1872 |  | 
 | 1873 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 1874 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1875 | basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1876 |     : __r_(__second_tag(), __a) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1877 | { | 
| Marshall Clow | d5549cc | 2014-07-17 15:32:20 +0000 | [diff] [blame] | 1878 |     if (__str.__is_long() && __a != __str.__alloc()) // copy, not move | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1879 |         __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); | 
| Marshall Clow | d5549cc | 2014-07-17 15:32:20 +0000 | [diff] [blame] | 1880 |     else | 
 | 1881 |     { | 
 | 1882 |         __r_.first().__r = __str.__r_.first().__r; | 
 | 1883 |         __str.__zero(); | 
 | 1884 |     } | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1885 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1886 |     __get_db()->__insert_c(this); | 
 | 1887 |     if (__is_long()) | 
 | 1888 |         __get_db()->swap(this, &__str); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1889 | #endif | 
 | 1890 | } | 
 | 1891 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 1892 | #endif  // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1893 |  | 
 | 1894 | template <class _CharT, class _Traits, class _Allocator> | 
 | 1895 | void | 
 | 1896 | basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) | 
 | 1897 | { | 
 | 1898 |     if (__n > max_size()) | 
 | 1899 |         this->__throw_length_error(); | 
 | 1900 |     pointer __p; | 
 | 1901 |     if (__n < __min_cap) | 
 | 1902 |     { | 
 | 1903 |         __set_short_size(__n); | 
 | 1904 |         __p = __get_short_pointer(); | 
 | 1905 |     } | 
 | 1906 |     else | 
 | 1907 |     { | 
 | 1908 |         size_type __cap = __recommend(__n); | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 1909 |         __p = __alloc_traits::allocate(__alloc(), __cap+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1910 |         __set_long_pointer(__p); | 
 | 1911 |         __set_long_cap(__cap+1); | 
 | 1912 |         __set_long_size(__n); | 
 | 1913 |     } | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 1914 |     traits_type::assign(_VSTD::__to_raw_pointer(__p), __n, __c); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1915 |     traits_type::assign(__p[__n], value_type()); | 
 | 1916 | } | 
 | 1917 |  | 
 | 1918 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 1919 | inline _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 1920 | basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1921 | { | 
 | 1922 |     __init(__n, __c); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1923 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1924 |     __get_db()->__insert_c(this); | 
 | 1925 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1926 | } | 
 | 1927 |  | 
 | 1928 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 7e3ab17 | 2018-10-16 16:02:18 +0000 | [diff] [blame] | 1929 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1930 | template <class> | 
| Marshall Clow | 7e3ab17 | 2018-10-16 16:02:18 +0000 | [diff] [blame] | 1931 | #endif | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 1932 | basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1933 |     : __r_(__second_tag(), __a) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1934 | { | 
 | 1935 |     __init(__n, __c); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1936 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1937 |     __get_db()->__insert_c(this); | 
 | 1938 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1939 | } | 
 | 1940 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1941 | template <class _CharT, class _Traits, class _Allocator> | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 1942 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, | 
 | 1943 |                                                         size_type __pos, size_type __n, | 
 | 1944 |                                                         const _Allocator& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1945 |     : __r_(__second_tag(), __a) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1946 | { | 
 | 1947 |     size_type __str_sz = __str.size(); | 
 | 1948 |     if (__pos > __str_sz) | 
 | 1949 |         this->__throw_out_of_range(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1950 |     __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos)); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 1951 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1952 |     __get_db()->__insert_c(this); | 
 | 1953 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1954 | } | 
 | 1955 |  | 
 | 1956 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | f4f7d8f | 2016-04-07 18:13:41 +0000 | [diff] [blame] | 1957 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 1958 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 1959 |                                                         const _Allocator& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1960 |     : __r_(__second_tag(), __a) | 
| Marshall Clow | f4f7d8f | 2016-04-07 18:13:41 +0000 | [diff] [blame] | 1961 | { | 
 | 1962 |     size_type __str_sz = __str.size(); | 
 | 1963 |     if (__pos > __str_sz) | 
 | 1964 |         this->__throw_out_of_range(); | 
 | 1965 |     __init(__str.data() + __pos, __str_sz - __pos); | 
 | 1966 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1967 |     __get_db()->__insert_c(this); | 
 | 1968 | #endif | 
 | 1969 | } | 
 | 1970 |  | 
 | 1971 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1972 | template <class _Tp, class> | 
| Marshall Clow | db7fa11 | 2016-11-14 18:22:19 +0000 | [diff] [blame] | 1973 | basic_string<_CharT, _Traits, _Allocator>::basic_string( | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1974 |              const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1975 |     : __r_(__second_tag(), __a) | 
| Marshall Clow | db7fa11 | 2016-11-14 18:22:19 +0000 | [diff] [blame] | 1976 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1977 |     __self_view __sv0 = __t; | 
 | 1978 |     __self_view __sv = __sv0.substr(__pos, __n); | 
| Marshall Clow | db7fa11 | 2016-11-14 18:22:19 +0000 | [diff] [blame] | 1979 |     __init(__sv.data(), __sv.size()); | 
 | 1980 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1981 |     __get_db()->__insert_c(this); | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 1982 | #endif | 
| Marshall Clow | db7fa11 | 2016-11-14 18:22:19 +0000 | [diff] [blame] | 1983 | } | 
 | 1984 |  | 
 | 1985 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1986 | template <class _Tp, class> | 
 | 1987 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t) | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 1988 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1989 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 1990 |     __init(__sv.data(), __sv.size()); | 
 | 1991 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 1992 |     __get_db()->__insert_c(this); | 
 | 1993 | #endif | 
 | 1994 | } | 
 | 1995 |  | 
 | 1996 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 1997 | template <class _Tp, class> | 
 | 1998 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 1999 |     : __r_(__second_tag(), __a) | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 2000 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 2001 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 2002 |     __init(__sv.data(), __sv.size()); | 
 | 2003 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 2004 |     __get_db()->__insert_c(this); | 
 | 2005 | #endif | 
 | 2006 | } | 
 | 2007 |  | 
 | 2008 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2009 | template <class _InputIterator> | 
 | 2010 | typename enable_if | 
 | 2011 | < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 2012 |     __is_exactly_input_iterator<_InputIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2013 |     void | 
 | 2014 | >::type | 
 | 2015 | basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) | 
 | 2016 | { | 
 | 2017 |     __zero(); | 
 | 2018 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 2019 |     try | 
 | 2020 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2021 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2022 |     for (; __first != __last; ++__first) | 
 | 2023 |         push_back(*__first); | 
 | 2024 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 2025 |     } | 
 | 2026 |     catch (...) | 
 | 2027 |     { | 
 | 2028 |         if (__is_long()) | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2029 |             __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2030 |         throw; | 
 | 2031 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2032 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2033 | } | 
 | 2034 |  | 
 | 2035 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2036 | template <class _ForwardIterator> | 
 | 2037 | typename enable_if | 
 | 2038 | < | 
 | 2039 |     __is_forward_iterator<_ForwardIterator>::value, | 
 | 2040 |     void | 
 | 2041 | >::type | 
 | 2042 | basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last) | 
 | 2043 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2044 |     size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2045 |     if (__sz > max_size()) | 
 | 2046 |         this->__throw_length_error(); | 
 | 2047 |     pointer __p; | 
 | 2048 |     if (__sz < __min_cap) | 
 | 2049 |     { | 
 | 2050 |         __set_short_size(__sz); | 
 | 2051 |         __p = __get_short_pointer(); | 
 | 2052 |     } | 
 | 2053 |     else | 
 | 2054 |     { | 
 | 2055 |         size_type __cap = __recommend(__sz); | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2056 |         __p = __alloc_traits::allocate(__alloc(), __cap+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2057 |         __set_long_pointer(__p); | 
 | 2058 |         __set_long_cap(__cap+1); | 
 | 2059 |         __set_long_size(__sz); | 
 | 2060 |     } | 
| Eric Fiselier | b991975 | 2014-10-27 19:28:20 +0000 | [diff] [blame] | 2061 |     for (; __first != __last; ++__first, (void) ++__p) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2062 |         traits_type::assign(*__p, *__first); | 
 | 2063 |     traits_type::assign(*__p, value_type()); | 
 | 2064 | } | 
 | 2065 |  | 
 | 2066 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2067 | template<class _InputIterator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2068 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2069 | basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last) | 
 | 2070 | { | 
 | 2071 |     __init(__first, __last); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 2072 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 2073 |     __get_db()->__insert_c(this); | 
 | 2074 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2075 | } | 
 | 2076 |  | 
 | 2077 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2078 | template<class _InputIterator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2079 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2080 | basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, | 
 | 2081 |                                                         const allocator_type& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 2082 |     : __r_(__second_tag(), __a) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2083 | { | 
 | 2084 |     __init(__first, __last); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 2085 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 2086 |     __get_db()->__insert_c(this); | 
 | 2087 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2088 | } | 
 | 2089 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 2090 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 2091 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2092 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2093 | inline _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 2094 | basic_string<_CharT, _Traits, _Allocator>::basic_string( | 
 | 2095 |     initializer_list<_CharT> __il) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2096 | { | 
 | 2097 |     __init(__il.begin(), __il.end()); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 2098 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 2099 |     __get_db()->__insert_c(this); | 
 | 2100 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2101 | } | 
 | 2102 |  | 
 | 2103 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2104 | inline _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 2105 |  | 
| Eric Fiselier | 0eaf2e8 | 2017-02-17 01:17:10 +0000 | [diff] [blame] | 2106 | basic_string<_CharT, _Traits, _Allocator>::basic_string( | 
 | 2107 |     initializer_list<_CharT> __il, const _Allocator& __a) | 
| Eric Fiselier | db14bcc | 2017-04-12 23:45:53 +0000 | [diff] [blame] | 2108 |     : __r_(__second_tag(), __a) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2109 | { | 
 | 2110 |     __init(__il.begin(), __il.end()); | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 2111 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 2112 |     __get_db()->__insert_c(this); | 
 | 2113 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2114 | } | 
 | 2115 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 2116 | #endif  // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 2117 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2118 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2119 | basic_string<_CharT, _Traits, _Allocator>::~basic_string() | 
 | 2120 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 2121 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 2122 |     __get_db()->__erase_c(this); | 
 | 2123 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2124 |     if (__is_long()) | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2125 |         __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2126 | } | 
 | 2127 |  | 
 | 2128 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2129 | void | 
 | 2130 | basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace | 
 | 2131 |     (size_type __old_cap, size_type __delta_cap, size_type __old_sz, | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2132 |      size_type __n_copy,  size_type __n_del,     size_type __n_add, const value_type* __p_new_stuff) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2133 | { | 
 | 2134 |     size_type __ms = max_size(); | 
 | 2135 |     if (__delta_cap > __ms - __old_cap - 1) | 
 | 2136 |         this->__throw_length_error(); | 
 | 2137 |     pointer __old_p = __get_pointer(); | 
 | 2138 |     size_type __cap = __old_cap < __ms / 2 - __alignment ? | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2139 |                           __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2140 |                           __ms - 1; | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2141 |     pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2142 |     __invalidate_all_iterators(); | 
 | 2143 |     if (__n_copy != 0) | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2144 |         traits_type::copy(_VSTD::__to_raw_pointer(__p), | 
 | 2145 |                           _VSTD::__to_raw_pointer(__old_p), __n_copy); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2146 |     if (__n_add != 0) | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2147 |         traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy, __p_new_stuff, __n_add); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2148 |     size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; | 
 | 2149 |     if (__sec_cp_sz != 0) | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2150 |         traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add, | 
 | 2151 |                           _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, __sec_cp_sz); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2152 |     if (__old_cap+1 != __min_cap) | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2153 |         __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2154 |     __set_long_pointer(__p); | 
 | 2155 |     __set_long_cap(__cap+1); | 
 | 2156 |     __old_sz = __n_copy + __n_add + __sec_cp_sz; | 
 | 2157 |     __set_long_size(__old_sz); | 
 | 2158 |     traits_type::assign(__p[__old_sz], value_type()); | 
 | 2159 | } | 
 | 2160 |  | 
 | 2161 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2162 | void | 
 | 2163 | basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, | 
 | 2164 |                                                      size_type __n_copy,  size_type __n_del,     size_type __n_add) | 
 | 2165 | { | 
 | 2166 |     size_type __ms = max_size(); | 
| Marshall Clow | ecc8d7b | 2013-11-06 14:24:38 +0000 | [diff] [blame] | 2167 |     if (__delta_cap > __ms - __old_cap) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2168 |         this->__throw_length_error(); | 
 | 2169 |     pointer __old_p = __get_pointer(); | 
 | 2170 |     size_type __cap = __old_cap < __ms / 2 - __alignment ? | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2171 |                           __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2172 |                           __ms - 1; | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2173 |     pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2174 |     __invalidate_all_iterators(); | 
 | 2175 |     if (__n_copy != 0) | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2176 |         traits_type::copy(_VSTD::__to_raw_pointer(__p), | 
 | 2177 |                           _VSTD::__to_raw_pointer(__old_p), __n_copy); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2178 |     size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; | 
 | 2179 |     if (__sec_cp_sz != 0) | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2180 |         traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add, | 
 | 2181 |                           _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, | 
 | 2182 |                           __sec_cp_sz); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2183 |     if (__old_cap+1 != __min_cap) | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2184 |         __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2185 |     __set_long_pointer(__p); | 
 | 2186 |     __set_long_cap(__cap+1); | 
 | 2187 | } | 
 | 2188 |  | 
 | 2189 | // assign | 
 | 2190 |  | 
 | 2191 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2192 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2193 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2194 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 2195 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2196 |     size_type __cap = capacity(); | 
 | 2197 |     if (__cap >= __n) | 
 | 2198 |     { | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2199 |         value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2200 |         traits_type::move(__p, __s, __n); | 
 | 2201 |         traits_type::assign(__p[__n], value_type()); | 
 | 2202 |         __set_size(__n); | 
 | 2203 |         __invalidate_iterators_past(__n); | 
 | 2204 |     } | 
 | 2205 |     else | 
 | 2206 |     { | 
 | 2207 |         size_type __sz = size(); | 
 | 2208 |         __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s); | 
 | 2209 |     } | 
 | 2210 |     return *this; | 
 | 2211 | } | 
 | 2212 |  | 
 | 2213 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2214 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2215 | basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) | 
 | 2216 | { | 
 | 2217 |     size_type __cap = capacity(); | 
 | 2218 |     if (__cap < __n) | 
 | 2219 |     { | 
 | 2220 |         size_type __sz = size(); | 
 | 2221 |         __grow_by(__cap, __n - __cap, __sz, 0, __sz); | 
 | 2222 |     } | 
 | 2223 |     else | 
 | 2224 |         __invalidate_iterators_past(__n); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2225 |     value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2226 |     traits_type::assign(__p, __n, __c); | 
 | 2227 |     traits_type::assign(__p[__n], value_type()); | 
 | 2228 |     __set_size(__n); | 
 | 2229 |     return *this; | 
 | 2230 | } | 
 | 2231 |  | 
 | 2232 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2233 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2234 | basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) | 
 | 2235 | { | 
 | 2236 |     pointer __p; | 
 | 2237 |     if (__is_long()) | 
 | 2238 |     { | 
 | 2239 |         __p = __get_long_pointer(); | 
 | 2240 |         __set_long_size(1); | 
 | 2241 |     } | 
 | 2242 |     else | 
 | 2243 |     { | 
 | 2244 |         __p = __get_short_pointer(); | 
 | 2245 |         __set_short_size(1); | 
 | 2246 |     } | 
 | 2247 |     traits_type::assign(*__p, __c); | 
 | 2248 |     traits_type::assign(*++__p, value_type()); | 
 | 2249 |     __invalidate_iterators_past(1); | 
 | 2250 |     return *this; | 
 | 2251 | } | 
 | 2252 |  | 
 | 2253 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2254 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2255 | basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) | 
 | 2256 | { | 
 | 2257 |     if (this != &__str) | 
 | 2258 |     { | 
 | 2259 |         __copy_assign_alloc(__str); | 
| Marshall Clow | f40ec90 | 2016-03-09 18:08:29 +0000 | [diff] [blame] | 2260 |         assign(__str.data(), __str.size()); | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2261 |     } | 
 | 2262 |     return *this; | 
 | 2263 | } | 
 | 2264 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 2265 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2266 |  | 
 | 2267 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2268 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2269 | void | 
 | 2270 | basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 +0000 | [diff] [blame] | 2271 |     _NOEXCEPT_(__alloc_traits::is_always_equal::value) | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2272 | { | 
 | 2273 |     if (__alloc() != __str.__alloc()) | 
 | 2274 |         assign(__str); | 
 | 2275 |     else | 
 | 2276 |         __move_assign(__str, true_type()); | 
 | 2277 | } | 
 | 2278 |  | 
 | 2279 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2280 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2281 | void | 
 | 2282 | basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 +0000 | [diff] [blame] | 2283 | #if _LIBCPP_STD_VER > 14 | 
 | 2284 |     _NOEXCEPT | 
 | 2285 | #else | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 2286 |     _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 +0000 | [diff] [blame] | 2287 | #endif | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2288 | { | 
| Vedant Kumar | 2b588cb | 2018-03-08 21:15:26 +0000 | [diff] [blame] | 2289 |     __clear_and_shrink(); | 
| Howard Hinnant | 3fdbbd2 | 2011-08-17 20:36:18 +0000 | [diff] [blame] | 2290 |     __r_.first() = __str.__r_.first(); | 
 | 2291 |     __move_assign_alloc(__str); | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2292 |     __str.__zero(); | 
 | 2293 | } | 
 | 2294 |  | 
 | 2295 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2296 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2297 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2298 | basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) | 
| Marshall Clow | af961ed | 2015-08-18 18:57:00 +0000 | [diff] [blame] | 2299 |     _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 2300 | { | 
 | 2301 |     __move_assign(__str, integral_constant<bool, | 
 | 2302 |           __alloc_traits::propagate_on_container_move_assignment::value>()); | 
 | 2303 |     return *this; | 
 | 2304 | } | 
 | 2305 |  | 
 | 2306 | #endif | 
 | 2307 |  | 
 | 2308 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2309 | template<class _InputIterator> | 
 | 2310 | typename enable_if | 
 | 2311 | < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 2312 |      __is_exactly_input_iterator <_InputIterator>::value | 
 | 2313 |           || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2314 |     basic_string<_CharT, _Traits, _Allocator>& | 
 | 2315 | >::type | 
 | 2316 | basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) | 
 | 2317 | { | 
| Marshall Clow | d979eed | 2016-09-05 01:54:30 +0000 | [diff] [blame] | 2318 |     const basic_string __temp(__first, __last, __alloc()); | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 2319 |     assign(__temp.data(), __temp.size()); | 
| Argyrios Kyrtzidis | 1dc6f7a | 2012-10-13 02:03:45 +0000 | [diff] [blame] | 2320 |     return *this; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2321 | } | 
 | 2322 |  | 
 | 2323 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2324 | template<class _ForwardIterator> | 
 | 2325 | typename enable_if | 
 | 2326 | < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 2327 |     __is_forward_iterator<_ForwardIterator>::value | 
 | 2328 |          && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2329 |     basic_string<_CharT, _Traits, _Allocator>& | 
 | 2330 | >::type | 
 | 2331 | basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) | 
 | 2332 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2333 |     size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2334 |     size_type __cap = capacity(); | 
 | 2335 |     if (__cap < __n) | 
 | 2336 |     { | 
 | 2337 |         size_type __sz = size(); | 
 | 2338 |         __grow_by(__cap, __n - __cap, __sz, 0, __sz); | 
 | 2339 |     } | 
 | 2340 |     else | 
 | 2341 |         __invalidate_iterators_past(__n); | 
 | 2342 |     pointer __p = __get_pointer(); | 
 | 2343 |     for (; __first != __last; ++__first, ++__p) | 
 | 2344 |         traits_type::assign(*__p, *__first); | 
 | 2345 |     traits_type::assign(*__p, value_type()); | 
 | 2346 |     __set_size(__n); | 
 | 2347 |     return *this; | 
 | 2348 | } | 
 | 2349 |  | 
 | 2350 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2351 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2352 | basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) | 
 | 2353 | { | 
 | 2354 |     size_type __sz = __str.size(); | 
 | 2355 |     if (__pos > __sz) | 
 | 2356 |         this->__throw_out_of_range(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2357 |     return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2358 | } | 
 | 2359 |  | 
 | 2360 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2361 | template <class _Tp> | 
 | 2362 | typename enable_if | 
 | 2363 | < | 
 | 2364 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
| Marshall Clow | f1729d9 | 2017-11-15 20:02:27 +0000 | [diff] [blame] | 2365 |     basic_string<_CharT, _Traits, _Allocator>& | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2366 | >::type | 
 | 2367 | basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n) | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 2368 | { | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2369 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 2370 |     size_type __sz = __sv.size(); | 
 | 2371 |     if (__pos > __sz) | 
 | 2372 |         this->__throw_out_of_range(); | 
 | 2373 |     return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos)); | 
 | 2374 | } | 
 | 2375 |  | 
 | 2376 |  | 
 | 2377 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2378 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2379 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2380 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 2381 |     _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2382 |     return assign(__s, traits_type::length(__s)); | 
 | 2383 | } | 
 | 2384 |  | 
 | 2385 | // append | 
 | 2386 |  | 
 | 2387 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2388 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2389 | basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2390 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 2391 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2392 |     size_type __cap = capacity(); | 
 | 2393 |     size_type __sz = size(); | 
 | 2394 |     if (__cap - __sz >= __n) | 
 | 2395 |     { | 
 | 2396 |         if (__n) | 
 | 2397 |         { | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2398 |             value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2399 |             traits_type::copy(__p + __sz, __s, __n); | 
 | 2400 |             __sz += __n; | 
 | 2401 |             __set_size(__sz); | 
 | 2402 |             traits_type::assign(__p[__sz], value_type()); | 
 | 2403 |         } | 
 | 2404 |     } | 
 | 2405 |     else | 
 | 2406 |         __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s); | 
 | 2407 |     return *this; | 
 | 2408 | } | 
 | 2409 |  | 
 | 2410 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2411 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2412 | basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) | 
 | 2413 | { | 
 | 2414 |     if (__n) | 
 | 2415 |     { | 
 | 2416 |         size_type __cap = capacity(); | 
 | 2417 |         size_type __sz = size(); | 
 | 2418 |         if (__cap - __sz < __n) | 
 | 2419 |             __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); | 
 | 2420 |         pointer __p = __get_pointer(); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2421 |         traits_type::assign(_VSTD::__to_raw_pointer(__p) + __sz, __n, __c); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2422 |         __sz += __n; | 
 | 2423 |         __set_size(__sz); | 
 | 2424 |         traits_type::assign(__p[__sz], value_type()); | 
 | 2425 |     } | 
 | 2426 |     return *this; | 
 | 2427 | } | 
 | 2428 |  | 
 | 2429 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2430 | void | 
 | 2431 | basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) | 
 | 2432 | { | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 2433 |     bool __is_short = !__is_long(); | 
 | 2434 |     size_type __cap; | 
 | 2435 |     size_type __sz; | 
 | 2436 |     if (__is_short) | 
 | 2437 |     { | 
 | 2438 |         __cap = __min_cap - 1; | 
 | 2439 |         __sz = __get_short_size(); | 
 | 2440 |     } | 
 | 2441 |     else | 
 | 2442 |     { | 
 | 2443 |         __cap = __get_long_cap() - 1; | 
 | 2444 |         __sz = __get_long_size(); | 
 | 2445 |     } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2446 |     if (__sz == __cap) | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 2447 |     { | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2448 |         __grow_by(__cap, 1, __sz, __sz, 0); | 
| Howard Hinnant | 1546718 | 2013-04-30 21:44:48 +0000 | [diff] [blame] | 2449 |         __is_short = !__is_long(); | 
 | 2450 |     } | 
 | 2451 |     pointer __p; | 
 | 2452 |     if (__is_short) | 
 | 2453 |     { | 
 | 2454 |         __p = __get_short_pointer() + __sz; | 
 | 2455 |         __set_short_size(__sz+1); | 
 | 2456 |     } | 
 | 2457 |     else | 
 | 2458 |     { | 
 | 2459 |         __p = __get_long_pointer() + __sz; | 
 | 2460 |         __set_long_size(__sz+1); | 
 | 2461 |     } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2462 |     traits_type::assign(*__p, __c); | 
 | 2463 |     traits_type::assign(*++__p, value_type()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2464 | } | 
 | 2465 |  | 
| Marshall Clow | ac655ef | 2016-09-07 03:32:06 +0000 | [diff] [blame] | 2466 | template <class _Tp> | 
| Marshall Clow | d979eed | 2016-09-05 01:54:30 +0000 | [diff] [blame] | 2467 | bool __ptr_in_range (const _Tp* __p, const _Tp* __first, const _Tp* __last) | 
 | 2468 | { | 
 | 2469 |     return __first <= __p && __p < __last; | 
 | 2470 | } | 
 | 2471 |  | 
| Marshall Clow | ac655ef | 2016-09-07 03:32:06 +0000 | [diff] [blame] | 2472 | template <class _Tp1, class _Tp2> | 
| Eric Fiselier | 0e5ebbc | 2016-12-23 23:37:52 +0000 | [diff] [blame] | 2473 | bool __ptr_in_range (const _Tp1*, const _Tp2*, const _Tp2*) | 
| Marshall Clow | ac655ef | 2016-09-07 03:32:06 +0000 | [diff] [blame] | 2474 | { | 
 | 2475 |     return false; | 
 | 2476 | } | 
 | 2477 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2478 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2479 | template<class _ForwardIterator> | 
| Eric Fiselier | 026d38e | 2016-10-31 02:46:25 +0000 | [diff] [blame] | 2480 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2481 | basic_string<_CharT, _Traits, _Allocator>::__append_forward_unsafe( | 
 | 2482 |     _ForwardIterator __first, _ForwardIterator __last) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2483 | { | 
| Eric Fiselier | 026d38e | 2016-10-31 02:46:25 +0000 | [diff] [blame] | 2484 |     static_assert(__is_forward_iterator<_ForwardIterator>::value, | 
 | 2485 |                   "function requires a ForwardIterator"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2486 |     size_type __sz = size(); | 
 | 2487 |     size_type __cap = capacity(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2488 |     size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2489 |     if (__n) | 
 | 2490 |     { | 
| Eric Fiselier | 622c7d5 | 2017-04-15 06:49:02 +0000 | [diff] [blame] | 2491 |         typedef typename iterator_traits<_ForwardIterator>::reference _CharRef; | 
 | 2492 |         _CharRef __tmp_ref = *__first; | 
 | 2493 |         if (__ptr_in_range(_VSTD::addressof(__tmp_ref), data(), data() + size())) | 
| Marshall Clow | d979eed | 2016-09-05 01:54:30 +0000 | [diff] [blame] | 2494 |         { | 
 | 2495 |             const basic_string __temp (__first, __last, __alloc()); | 
 | 2496 |             append(__temp.data(), __temp.size()); | 
 | 2497 |         } | 
 | 2498 |         else  | 
 | 2499 |         { | 
 | 2500 |             if (__cap - __sz < __n) | 
 | 2501 |                 __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); | 
 | 2502 |             pointer __p = __get_pointer() + __sz; | 
 | 2503 |             for (; __first != __last; ++__p, ++__first) | 
 | 2504 |                 traits_type::assign(*__p, *__first); | 
 | 2505 |             traits_type::assign(*__p, value_type()); | 
 | 2506 |             __set_size(__sz + __n); | 
 | 2507 |         } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2508 |     } | 
 | 2509 |     return *this; | 
 | 2510 | } | 
 | 2511 |  | 
 | 2512 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2513 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2514 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2515 | basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) | 
 | 2516 | { | 
 | 2517 |     return append(__str.data(), __str.size()); | 
 | 2518 | } | 
 | 2519 |  | 
 | 2520 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2521 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2522 | basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) | 
 | 2523 | { | 
 | 2524 |     size_type __sz = __str.size(); | 
 | 2525 |     if (__pos > __sz) | 
 | 2526 |         this->__throw_out_of_range(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2527 |     return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2528 | } | 
 | 2529 |  | 
 | 2530 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 42a87db | 2016-10-03 23:40:48 +0000 | [diff] [blame] | 2531 | template <class _Tp> | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2532 |     typename enable_if | 
 | 2533 |     < | 
 | 2534 |         __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 2535 |         basic_string<_CharT, _Traits, _Allocator>& | 
 | 2536 |     >::type | 
 | 2537 | basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __pos, size_type __n) | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 2538 | { | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2539 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 2540 |     size_type __sz = __sv.size(); | 
 | 2541 |     if (__pos > __sz) | 
 | 2542 |         this->__throw_out_of_range(); | 
 | 2543 |     return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos)); | 
 | 2544 | } | 
 | 2545 |  | 
 | 2546 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2547 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2548 | basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2549 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 2550 |     _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2551 |     return append(__s, traits_type::length(__s)); | 
 | 2552 | } | 
 | 2553 |  | 
 | 2554 | // insert | 
 | 2555 |  | 
 | 2556 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2557 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2558 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2559 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 2560 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2561 |     size_type __sz = size(); | 
 | 2562 |     if (__pos > __sz) | 
 | 2563 |         this->__throw_out_of_range(); | 
 | 2564 |     size_type __cap = capacity(); | 
 | 2565 |     if (__cap - __sz >= __n) | 
 | 2566 |     { | 
 | 2567 |         if (__n) | 
 | 2568 |         { | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2569 |             value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2570 |             size_type __n_move = __sz - __pos; | 
 | 2571 |             if (__n_move != 0) | 
 | 2572 |             { | 
 | 2573 |                 if (__p + __pos <= __s && __s < __p + __sz) | 
 | 2574 |                     __s += __n; | 
 | 2575 |                 traits_type::move(__p + __pos + __n, __p + __pos, __n_move); | 
 | 2576 |             } | 
 | 2577 |             traits_type::move(__p + __pos, __s, __n); | 
 | 2578 |             __sz += __n; | 
 | 2579 |             __set_size(__sz); | 
 | 2580 |             traits_type::assign(__p[__sz], value_type()); | 
 | 2581 |         } | 
 | 2582 |     } | 
 | 2583 |     else | 
 | 2584 |         __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); | 
 | 2585 |     return *this; | 
 | 2586 | } | 
 | 2587 |  | 
 | 2588 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2589 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2590 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) | 
 | 2591 | { | 
 | 2592 |     size_type __sz = size(); | 
 | 2593 |     if (__pos > __sz) | 
 | 2594 |         this->__throw_out_of_range(); | 
 | 2595 |     if (__n) | 
 | 2596 |     { | 
 | 2597 |         size_type __cap = capacity(); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2598 |         value_type* __p; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2599 |         if (__cap - __sz >= __n) | 
 | 2600 |         { | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2601 |             __p = _VSTD::__to_raw_pointer(__get_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2602 |             size_type __n_move = __sz - __pos; | 
 | 2603 |             if (__n_move != 0) | 
 | 2604 |                 traits_type::move(__p + __pos + __n, __p + __pos, __n_move); | 
 | 2605 |         } | 
 | 2606 |         else | 
 | 2607 |         { | 
 | 2608 |             __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2609 |             __p = _VSTD::__to_raw_pointer(__get_long_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2610 |         } | 
 | 2611 |         traits_type::assign(__p + __pos, __n, __c); | 
 | 2612 |         __sz += __n; | 
 | 2613 |         __set_size(__sz); | 
 | 2614 |         traits_type::assign(__p[__sz], value_type()); | 
 | 2615 |     } | 
 | 2616 |     return *this; | 
 | 2617 | } | 
 | 2618 |  | 
 | 2619 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2620 | template<class _InputIterator> | 
 | 2621 | typename enable_if | 
 | 2622 | < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 2623 |    __is_exactly_input_iterator<_InputIterator>::value | 
 | 2624 |         || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, | 
 | 2625 |    typename basic_string<_CharT, _Traits, _Allocator>::iterator | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2626 | >::type | 
 | 2627 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) | 
 | 2628 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 2629 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 2630 |     _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | 
 | 2631 |         "string::insert(iterator, range) called with an iterator not" | 
 | 2632 |         " referring to this string"); | 
 | 2633 | #endif | 
| Marshall Clow | d979eed | 2016-09-05 01:54:30 +0000 | [diff] [blame] | 2634 |     const basic_string __temp(__first, __last, __alloc()); | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 2635 |     return insert(__pos, __temp.data(), __temp.data() + __temp.size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2636 | } | 
 | 2637 |  | 
 | 2638 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2639 | template<class _ForwardIterator> | 
 | 2640 | typename enable_if | 
 | 2641 | < | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 2642 |     __is_forward_iterator<_ForwardIterator>::value | 
 | 2643 |         && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2644 |     typename basic_string<_CharT, _Traits, _Allocator>::iterator | 
 | 2645 | >::type | 
 | 2646 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) | 
 | 2647 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 2648 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 2649 |     _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | 
 | 2650 |         "string::insert(iterator, range) called with an iterator not" | 
 | 2651 |         " referring to this string"); | 
 | 2652 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2653 |     size_type __ip = static_cast<size_type>(__pos - begin()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2654 |     size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2655 |     if (__n) | 
 | 2656 |     { | 
| Eric Fiselier | 622c7d5 | 2017-04-15 06:49:02 +0000 | [diff] [blame] | 2657 |         typedef typename iterator_traits<_ForwardIterator>::reference _CharRef; | 
 | 2658 |         _CharRef __tmp_char = *__first; | 
 | 2659 |         if (__ptr_in_range(_VSTD::addressof(__tmp_char), data(), data() + size())) | 
| Marshall Clow | d979eed | 2016-09-05 01:54:30 +0000 | [diff] [blame] | 2660 |         { | 
 | 2661 |             const basic_string __temp(__first, __last, __alloc()); | 
 | 2662 |             return insert(__pos, __temp.data(), __temp.data() + __temp.size()); | 
 | 2663 |         } | 
 | 2664 |  | 
 | 2665 |         size_type __sz = size(); | 
 | 2666 |         size_type __cap = capacity(); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2667 |         value_type* __p; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2668 |         if (__cap - __sz >= __n) | 
 | 2669 |         { | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2670 |             __p = _VSTD::__to_raw_pointer(__get_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2671 |             size_type __n_move = __sz - __ip; | 
 | 2672 |             if (__n_move != 0) | 
 | 2673 |                 traits_type::move(__p + __ip + __n, __p + __ip, __n_move); | 
 | 2674 |         } | 
 | 2675 |         else | 
 | 2676 |         { | 
 | 2677 |             __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2678 |             __p = _VSTD::__to_raw_pointer(__get_long_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2679 |         } | 
 | 2680 |         __sz += __n; | 
 | 2681 |         __set_size(__sz); | 
 | 2682 |         traits_type::assign(__p[__sz], value_type()); | 
 | 2683 |         for (__p += __ip; __first != __last; ++__p, ++__first) | 
 | 2684 |             traits_type::assign(*__p, *__first); | 
 | 2685 |     } | 
 | 2686 |     return begin() + __ip; | 
 | 2687 | } | 
 | 2688 |  | 
 | 2689 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2690 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2691 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2692 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str) | 
 | 2693 | { | 
 | 2694 |     return insert(__pos1, __str.data(), __str.size()); | 
 | 2695 | } | 
 | 2696 |  | 
 | 2697 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2698 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2699 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str, | 
 | 2700 |                                                   size_type __pos2, size_type __n) | 
 | 2701 | { | 
 | 2702 |     size_type __str_sz = __str.size(); | 
 | 2703 |     if (__pos2 > __str_sz) | 
 | 2704 |         this->__throw_out_of_range(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2705 |     return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2706 | } | 
 | 2707 |  | 
 | 2708 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2709 | template <class _Tp> | 
 | 2710 | typename enable_if | 
 | 2711 | < | 
 | 2712 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
| Marshall Clow | f1729d9 | 2017-11-15 20:02:27 +0000 | [diff] [blame] | 2713 |     basic_string<_CharT, _Traits, _Allocator>& | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2714 | >::type | 
 | 2715 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 2716 |                                                   size_type __pos2, size_type __n) | 
 | 2717 | { | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2718 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 2719 |     size_type __str_sz = __sv.size(); | 
 | 2720 |     if (__pos2 > __str_sz) | 
 | 2721 |         this->__throw_out_of_range(); | 
 | 2722 |     return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); | 
 | 2723 | } | 
 | 2724 |  | 
 | 2725 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2726 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2727 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2728 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 2729 |     _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2730 |     return insert(__pos, __s, traits_type::length(__s)); | 
 | 2731 | } | 
 | 2732 |  | 
 | 2733 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2734 | typename basic_string<_CharT, _Traits, _Allocator>::iterator | 
 | 2735 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c) | 
 | 2736 | { | 
 | 2737 |     size_type __ip = static_cast<size_type>(__pos - begin()); | 
 | 2738 |     size_type __sz = size(); | 
 | 2739 |     size_type __cap = capacity(); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2740 |     value_type* __p; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2741 |     if (__cap == __sz) | 
 | 2742 |     { | 
 | 2743 |         __grow_by(__cap, 1, __sz, __ip, 0, 1); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2744 |         __p = _VSTD::__to_raw_pointer(__get_long_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2745 |     } | 
 | 2746 |     else | 
 | 2747 |     { | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2748 |         __p = _VSTD::__to_raw_pointer(__get_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2749 |         size_type __n_move = __sz - __ip; | 
 | 2750 |         if (__n_move != 0) | 
 | 2751 |             traits_type::move(__p + __ip + 1, __p + __ip, __n_move); | 
 | 2752 |     } | 
 | 2753 |     traits_type::assign(__p[__ip], __c); | 
 | 2754 |     traits_type::assign(__p[++__sz], value_type()); | 
 | 2755 |     __set_size(__sz); | 
 | 2756 |     return begin() + static_cast<difference_type>(__ip); | 
 | 2757 | } | 
 | 2758 |  | 
 | 2759 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2760 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2761 | typename basic_string<_CharT, _Traits, _Allocator>::iterator | 
 | 2762 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) | 
 | 2763 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 2764 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 2765 |     _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | 
 | 2766 |         "string::insert(iterator, n, value) called with an iterator not" | 
 | 2767 |         " referring to this string"); | 
 | 2768 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2769 |     difference_type __p = __pos - begin(); | 
 | 2770 |     insert(static_cast<size_type>(__p), __n, __c); | 
 | 2771 |     return begin() + __p; | 
 | 2772 | } | 
 | 2773 |  | 
 | 2774 | // replace | 
 | 2775 |  | 
 | 2776 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2777 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2778 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) | 
| Eric Fiselier | 3b7c134 | 2017-03-09 01:54:13 +0000 | [diff] [blame] | 2779 |     _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2780 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 2781 |     _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2782 |     size_type __sz = size(); | 
 | 2783 |     if (__pos > __sz) | 
 | 2784 |         this->__throw_out_of_range(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2785 |     __n1 = _VSTD::min(__n1, __sz - __pos); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2786 |     size_type __cap = capacity(); | 
 | 2787 |     if (__cap - __sz + __n1 >= __n2) | 
 | 2788 |     { | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2789 |         value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2790 |         if (__n1 != __n2) | 
 | 2791 |         { | 
 | 2792 |             size_type __n_move = __sz - __pos - __n1; | 
 | 2793 |             if (__n_move != 0) | 
 | 2794 |             { | 
 | 2795 |                 if (__n1 > __n2) | 
 | 2796 |                 { | 
 | 2797 |                     traits_type::move(__p + __pos, __s, __n2); | 
 | 2798 |                     traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); | 
 | 2799 |                     goto __finish; | 
 | 2800 |                 } | 
 | 2801 |                 if (__p + __pos < __s && __s < __p + __sz) | 
 | 2802 |                 { | 
 | 2803 |                     if (__p + __pos + __n1 <= __s) | 
 | 2804 |                         __s += __n2 - __n1; | 
 | 2805 |                     else // __p + __pos < __s < __p + __pos + __n1 | 
 | 2806 |                     { | 
 | 2807 |                         traits_type::move(__p + __pos, __s, __n1); | 
 | 2808 |                         __pos += __n1; | 
 | 2809 |                         __s += __n2; | 
 | 2810 |                         __n2 -= __n1; | 
 | 2811 |                         __n1 = 0; | 
 | 2812 |                     } | 
 | 2813 |                 } | 
 | 2814 |                 traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); | 
 | 2815 |             } | 
 | 2816 |         } | 
 | 2817 |         traits_type::move(__p + __pos, __s, __n2); | 
 | 2818 | __finish: | 
| Eric Fiselier | 3b7c134 | 2017-03-09 01:54:13 +0000 | [diff] [blame] | 2819 | // __sz += __n2 - __n1; in this and the below function below can cause unsigned integer overflow, | 
 | 2820 | // but this is a safe operation, so we disable the check. | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2821 |         __sz += __n2 - __n1; | 
 | 2822 |         __set_size(__sz); | 
 | 2823 |         __invalidate_iterators_past(__sz); | 
 | 2824 |         traits_type::assign(__p[__sz], value_type()); | 
 | 2825 |     } | 
 | 2826 |     else | 
 | 2827 |         __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s); | 
 | 2828 |     return *this; | 
 | 2829 | } | 
 | 2830 |  | 
 | 2831 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2832 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2833 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) | 
| Eric Fiselier | 3b7c134 | 2017-03-09 01:54:13 +0000 | [diff] [blame] | 2834 |     _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2835 | { | 
 | 2836 |     size_type __sz = size(); | 
 | 2837 |     if (__pos > __sz) | 
 | 2838 |         this->__throw_out_of_range(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2839 |     __n1 = _VSTD::min(__n1, __sz - __pos); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2840 |     size_type __cap = capacity(); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2841 |     value_type* __p; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2842 |     if (__cap - __sz + __n1 >= __n2) | 
 | 2843 |     { | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2844 |         __p = _VSTD::__to_raw_pointer(__get_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2845 |         if (__n1 != __n2) | 
 | 2846 |         { | 
 | 2847 |             size_type __n_move = __sz - __pos - __n1; | 
 | 2848 |             if (__n_move != 0) | 
 | 2849 |                 traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); | 
 | 2850 |         } | 
 | 2851 |     } | 
 | 2852 |     else | 
 | 2853 |     { | 
 | 2854 |         __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2); | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2855 |         __p = _VSTD::__to_raw_pointer(__get_long_pointer()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2856 |     } | 
 | 2857 |     traits_type::assign(__p + __pos, __n2, __c); | 
 | 2858 |     __sz += __n2 - __n1; | 
 | 2859 |     __set_size(__sz); | 
 | 2860 |     __invalidate_iterators_past(__sz); | 
 | 2861 |     traits_type::assign(__p[__sz], value_type()); | 
 | 2862 |     return *this; | 
 | 2863 | } | 
 | 2864 |  | 
 | 2865 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2866 | template<class _InputIterator> | 
 | 2867 | typename enable_if | 
 | 2868 | < | 
 | 2869 |     __is_input_iterator<_InputIterator>::value, | 
 | 2870 |     basic_string<_CharT, _Traits, _Allocator>& | 
 | 2871 | >::type | 
| Howard Hinnant | 7b2cb48 | 2010-11-17 21:11:40 +0000 | [diff] [blame] | 2872 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2873 |                                                    _InputIterator __j1, _InputIterator __j2) | 
 | 2874 | { | 
| Marshall Clow | d979eed | 2016-09-05 01:54:30 +0000 | [diff] [blame] | 2875 |     const basic_string __temp(__j1, __j2, __alloc()); | 
| Marshall Clow | df9db31 | 2016-01-13 21:54:34 +0000 | [diff] [blame] | 2876 |     return this->replace(__i1, __i2, __temp); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2877 | } | 
 | 2878 |  | 
 | 2879 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2880 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2881 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2882 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str) | 
 | 2883 | { | 
 | 2884 |     return replace(__pos1, __n1, __str.data(), __str.size()); | 
 | 2885 | } | 
 | 2886 |  | 
 | 2887 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2888 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2889 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str, | 
 | 2890 |                                                    size_type __pos2, size_type __n2) | 
 | 2891 | { | 
 | 2892 |     size_type __str_sz = __str.size(); | 
 | 2893 |     if (__pos2 > __str_sz) | 
 | 2894 |         this->__throw_out_of_range(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2895 |     return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2896 | } | 
 | 2897 |  | 
 | 2898 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2899 | template <class _Tp> | 
 | 2900 | typename enable_if | 
 | 2901 | < | 
| Marshall Clow | f1729d9 | 2017-11-15 20:02:27 +0000 | [diff] [blame] | 2902 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 2903 |     basic_string<_CharT, _Traits, _Allocator>& | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2904 | >::type | 
 | 2905 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t, | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 2906 |                                                    size_type __pos2, size_type __n2) | 
 | 2907 | { | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 2908 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 2909 |     size_type __str_sz = __sv.size(); | 
 | 2910 |     if (__pos2 > __str_sz) | 
 | 2911 |         this->__throw_out_of_range(); | 
 | 2912 |     return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); | 
 | 2913 | } | 
 | 2914 |  | 
 | 2915 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2916 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2917 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2918 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 2919 |     _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2920 |     return replace(__pos, __n1, __s, traits_type::length(__s)); | 
 | 2921 | } | 
 | 2922 |  | 
 | 2923 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2924 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2925 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 7b2cb48 | 2010-11-17 21:11:40 +0000 | [diff] [blame] | 2926 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2927 | { | 
 | 2928 |     return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), | 
 | 2929 |                    __str.data(), __str.size()); | 
 | 2930 | } | 
 | 2931 |  | 
 | 2932 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2933 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2934 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2935 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2936 | { | 
 | 2937 |     return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n); | 
 | 2938 | } | 
 | 2939 |  | 
 | 2940 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2941 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2942 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2943 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2944 | { | 
 | 2945 |     return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s); | 
 | 2946 | } | 
 | 2947 |  | 
 | 2948 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2949 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2950 | basic_string<_CharT, _Traits, _Allocator>& | 
| Howard Hinnant | 7b2cb48 | 2010-11-17 21:11:40 +0000 | [diff] [blame] | 2951 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2952 | { | 
 | 2953 |     return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c); | 
 | 2954 | } | 
 | 2955 |  | 
 | 2956 | // erase | 
 | 2957 |  | 
 | 2958 | template <class _CharT, class _Traits, class _Allocator> | 
 | 2959 | basic_string<_CharT, _Traits, _Allocator>& | 
 | 2960 | basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) | 
 | 2961 | { | 
 | 2962 |     size_type __sz = size(); | 
 | 2963 |     if (__pos > __sz) | 
 | 2964 |         this->__throw_out_of_range(); | 
 | 2965 |     if (__n) | 
 | 2966 |     { | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 2967 |         value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2968 |         __n = _VSTD::min(__n, __sz - __pos); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2969 |         size_type __n_move = __sz - __pos - __n; | 
 | 2970 |         if (__n_move != 0) | 
 | 2971 |             traits_type::move(__p + __pos, __p + __pos + __n, __n_move); | 
 | 2972 |         __sz -= __n; | 
 | 2973 |         __set_size(__sz); | 
 | 2974 |         __invalidate_iterators_past(__sz); | 
 | 2975 |         traits_type::assign(__p[__sz], value_type()); | 
 | 2976 |     } | 
 | 2977 |     return *this; | 
 | 2978 | } | 
 | 2979 |  | 
 | 2980 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2981 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2982 | typename basic_string<_CharT, _Traits, _Allocator>::iterator | 
 | 2983 | basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) | 
 | 2984 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 2985 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 2986 |     _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | 
 | 2987 |         "string::erase(iterator) called with an iterator not" | 
 | 2988 |         " referring to this string"); | 
 | 2989 | #endif | 
 | 2990 |     _LIBCPP_ASSERT(__pos != end(), | 
 | 2991 |         "string::erase(iterator) called with a non-dereferenceable iterator"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2992 |     iterator __b = begin(); | 
 | 2993 |     size_type __r = static_cast<size_type>(__pos - __b); | 
 | 2994 |     erase(__r, 1); | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 2995 |     return __b + static_cast<difference_type>(__r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2996 | } | 
 | 2997 |  | 
 | 2998 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 2999 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3000 | typename basic_string<_CharT, _Traits, _Allocator>::iterator | 
 | 3001 | basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) | 
 | 3002 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 3003 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 3004 |     _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, | 
 | 3005 |         "string::erase(iterator,  iterator) called with an iterator not" | 
 | 3006 |         " referring to this string"); | 
 | 3007 | #endif | 
 | 3008 |     _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3009 |     iterator __b = begin(); | 
 | 3010 |     size_type __r = static_cast<size_type>(__first - __b); | 
 | 3011 |     erase(__r, static_cast<size_type>(__last - __first)); | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 3012 |     return __b + static_cast<difference_type>(__r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3013 | } | 
 | 3014 |  | 
 | 3015 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3016 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3017 | void | 
 | 3018 | basic_string<_CharT, _Traits, _Allocator>::pop_back() | 
 | 3019 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 3020 |     _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3021 |     size_type __sz; | 
 | 3022 |     if (__is_long()) | 
 | 3023 |     { | 
 | 3024 |         __sz = __get_long_size() - 1; | 
 | 3025 |         __set_long_size(__sz); | 
 | 3026 |         traits_type::assign(*(__get_long_pointer() + __sz), value_type()); | 
 | 3027 |     } | 
 | 3028 |     else | 
 | 3029 |     { | 
 | 3030 |         __sz = __get_short_size() - 1; | 
 | 3031 |         __set_short_size(__sz); | 
 | 3032 |         traits_type::assign(*(__get_short_pointer() + __sz), value_type()); | 
 | 3033 |     } | 
 | 3034 |     __invalidate_iterators_past(__sz); | 
 | 3035 | } | 
 | 3036 |  | 
 | 3037 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3038 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3039 | void | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3040 | basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3041 | { | 
 | 3042 |     __invalidate_all_iterators(); | 
 | 3043 |     if (__is_long()) | 
 | 3044 |     { | 
 | 3045 |         traits_type::assign(*__get_long_pointer(), value_type()); | 
 | 3046 |         __set_long_size(0); | 
 | 3047 |     } | 
 | 3048 |     else | 
 | 3049 |     { | 
 | 3050 |         traits_type::assign(*__get_short_pointer(), value_type()); | 
 | 3051 |         __set_short_size(0); | 
 | 3052 |     } | 
 | 3053 | } | 
 | 3054 |  | 
 | 3055 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3056 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3057 | void | 
 | 3058 | basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) | 
 | 3059 | { | 
 | 3060 |     if (__is_long()) | 
 | 3061 |     { | 
 | 3062 |         traits_type::assign(*(__get_long_pointer() + __pos), value_type()); | 
 | 3063 |         __set_long_size(__pos); | 
 | 3064 |     } | 
 | 3065 |     else | 
 | 3066 |     { | 
 | 3067 |         traits_type::assign(*(__get_short_pointer() + __pos), value_type()); | 
 | 3068 |         __set_short_size(__pos); | 
 | 3069 |     } | 
 | 3070 |     __invalidate_iterators_past(__pos); | 
 | 3071 | } | 
 | 3072 |  | 
 | 3073 | template <class _CharT, class _Traits, class _Allocator> | 
 | 3074 | void | 
 | 3075 | basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) | 
 | 3076 | { | 
 | 3077 |     size_type __sz = size(); | 
 | 3078 |     if (__n > __sz) | 
 | 3079 |         append(__n - __sz, __c); | 
 | 3080 |     else | 
 | 3081 |         __erase_to_end(__n); | 
 | 3082 | } | 
 | 3083 |  | 
 | 3084 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3085 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3086 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3087 | basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3088 | { | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 3089 |     size_type __m = __alloc_traits::max_size(__alloc()); | 
| Eric Fiselier | 5ccf043 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 3090 | #ifdef _LIBCPP_BIG_ENDIAN | 
| Marshall Clow | 09f8550 | 2013-10-31 17:23:08 +0000 | [diff] [blame] | 3091 |     return (__m <= ~__long_mask ? __m : __m/2) - __alignment; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3092 | #else | 
| Marshall Clow | 09f8550 | 2013-10-31 17:23:08 +0000 | [diff] [blame] | 3093 |     return __m - __alignment; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3094 | #endif | 
 | 3095 | } | 
 | 3096 |  | 
 | 3097 | template <class _CharT, class _Traits, class _Allocator> | 
 | 3098 | void | 
 | 3099 | basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg) | 
 | 3100 | { | 
 | 3101 |     if (__res_arg > max_size()) | 
 | 3102 |         this->__throw_length_error(); | 
 | 3103 |     size_type __cap = capacity(); | 
 | 3104 |     size_type __sz = size(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3105 |     __res_arg = _VSTD::max(__res_arg, __sz); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3106 |     __res_arg = __recommend(__res_arg); | 
 | 3107 |     if (__res_arg != __cap) | 
 | 3108 |     { | 
 | 3109 |         pointer __new_data, __p; | 
 | 3110 |         bool __was_long, __now_long; | 
 | 3111 |         if (__res_arg == __min_cap - 1) | 
 | 3112 |         { | 
 | 3113 |             __was_long = true; | 
 | 3114 |             __now_long = false; | 
 | 3115 |             __new_data = __get_short_pointer(); | 
 | 3116 |             __p = __get_long_pointer(); | 
 | 3117 |         } | 
 | 3118 |         else | 
 | 3119 |         { | 
 | 3120 |             if (__res_arg > __cap) | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 3121 |                 __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3122 |             else | 
 | 3123 |             { | 
 | 3124 |             #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3125 |                 try | 
 | 3126 |                 { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3127 |             #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 3128 |                     __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3129 |             #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3130 |                 } | 
 | 3131 |                 catch (...) | 
 | 3132 |                 { | 
 | 3133 |                     return; | 
 | 3134 |                 } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3135 |             #else  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3136 |                 if (__new_data == nullptr) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3137 |                     return; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3138 |             #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3139 |             } | 
 | 3140 |             __now_long = true; | 
 | 3141 |             __was_long = __is_long(); | 
 | 3142 |             __p = __get_pointer(); | 
 | 3143 |         } | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3144 |         traits_type::copy(_VSTD::__to_raw_pointer(__new_data), | 
 | 3145 |                           _VSTD::__to_raw_pointer(__p), size()+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3146 |         if (__was_long) | 
| Howard Hinnant | e32b5e2 | 2010-11-17 17:55:08 +0000 | [diff] [blame] | 3147 |             __alloc_traits::deallocate(__alloc(), __p, __cap+1); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3148 |         if (__now_long) | 
 | 3149 |         { | 
 | 3150 |             __set_long_cap(__res_arg+1); | 
 | 3151 |             __set_long_size(__sz); | 
 | 3152 |             __set_long_pointer(__new_data); | 
 | 3153 |         } | 
 | 3154 |         else | 
 | 3155 |             __set_short_size(__sz); | 
 | 3156 |         __invalidate_all_iterators(); | 
 | 3157 |     } | 
 | 3158 | } | 
 | 3159 |  | 
 | 3160 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3161 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3162 | typename basic_string<_CharT, _Traits, _Allocator>::const_reference | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3163 | basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3164 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 3165 |     _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3166 |     return *(data() + __pos); | 
 | 3167 | } | 
 | 3168 |  | 
 | 3169 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3170 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3171 | typename basic_string<_CharT, _Traits, _Allocator>::reference | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3172 | basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3173 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 3174 |     _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3175 |     return *(__get_pointer() + __pos); | 
 | 3176 | } | 
 | 3177 |  | 
 | 3178 | template <class _CharT, class _Traits, class _Allocator> | 
 | 3179 | typename basic_string<_CharT, _Traits, _Allocator>::const_reference | 
 | 3180 | basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const | 
 | 3181 | { | 
 | 3182 |     if (__n >= size()) | 
 | 3183 |         this->__throw_out_of_range(); | 
 | 3184 |     return (*this)[__n]; | 
 | 3185 | } | 
 | 3186 |  | 
 | 3187 | template <class _CharT, class _Traits, class _Allocator> | 
 | 3188 | typename basic_string<_CharT, _Traits, _Allocator>::reference | 
 | 3189 | basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) | 
 | 3190 | { | 
 | 3191 |     if (__n >= size()) | 
 | 3192 |         this->__throw_out_of_range(); | 
 | 3193 |     return (*this)[__n]; | 
 | 3194 | } | 
 | 3195 |  | 
 | 3196 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3197 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3198 | typename basic_string<_CharT, _Traits, _Allocator>::reference | 
 | 3199 | basic_string<_CharT, _Traits, _Allocator>::front() | 
 | 3200 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 3201 |     _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3202 |     return *__get_pointer(); | 
 | 3203 | } | 
 | 3204 |  | 
 | 3205 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3206 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3207 | typename basic_string<_CharT, _Traits, _Allocator>::const_reference | 
 | 3208 | basic_string<_CharT, _Traits, _Allocator>::front() const | 
 | 3209 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 3210 |     _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3211 |     return *data(); | 
 | 3212 | } | 
 | 3213 |  | 
 | 3214 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3215 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3216 | typename basic_string<_CharT, _Traits, _Allocator>::reference | 
 | 3217 | basic_string<_CharT, _Traits, _Allocator>::back() | 
 | 3218 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 3219 |     _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3220 |     return *(__get_pointer() + size() - 1); | 
 | 3221 | } | 
 | 3222 |  | 
 | 3223 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3224 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3225 | typename basic_string<_CharT, _Traits, _Allocator>::const_reference | 
 | 3226 | basic_string<_CharT, _Traits, _Allocator>::back() const | 
 | 3227 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 3228 |     _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3229 |     return *(data() + size() - 1); | 
 | 3230 | } | 
 | 3231 |  | 
 | 3232 | template <class _CharT, class _Traits, class _Allocator> | 
 | 3233 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3234 | basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3235 | { | 
 | 3236 |     size_type __sz = size(); | 
 | 3237 |     if (__pos > __sz) | 
 | 3238 |         this->__throw_out_of_range(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3239 |     size_type __rlen = _VSTD::min(__n, __sz - __pos); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3240 |     traits_type::copy(__s, data() + __pos, __rlen); | 
 | 3241 |     return __rlen; | 
 | 3242 | } | 
 | 3243 |  | 
 | 3244 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3245 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3246 | basic_string<_CharT, _Traits, _Allocator> | 
 | 3247 | basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const | 
 | 3248 | { | 
 | 3249 |     return basic_string(*this, __pos, __n, __alloc()); | 
 | 3250 | } | 
 | 3251 |  | 
 | 3252 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3253 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3254 | void | 
 | 3255 | basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 3256 | #if _LIBCPP_STD_VER >= 14 | 
| Eric Fiselier | 47257c4 | 2016-12-28 05:53:01 +0000 | [diff] [blame] | 3257 |         _NOEXCEPT_DEBUG | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 3258 | #else | 
| Eric Fiselier | 47257c4 | 2016-12-28 05:53:01 +0000 | [diff] [blame] | 3259 |         _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value || | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 3260 |                     __is_nothrow_swappable<allocator_type>::value) | 
 | 3261 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3262 | { | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 3263 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 3264 |     if (!__is_long()) | 
 | 3265 |         __get_db()->__invalidate_all(this); | 
 | 3266 |     if (!__str.__is_long()) | 
 | 3267 |         __get_db()->__invalidate_all(&__str); | 
 | 3268 |     __get_db()->swap(this, &__str); | 
 | 3269 | #endif | 
| Eric Fiselier | 47257c4 | 2016-12-28 05:53:01 +0000 | [diff] [blame] | 3270 |     _LIBCPP_ASSERT( | 
 | 3271 |         __alloc_traits::propagate_on_container_swap::value || | 
 | 3272 |         __alloc_traits::is_always_equal::value || | 
 | 3273 |         __alloc() == __str.__alloc(), "swapping non-equal allocators"); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3274 |     _VSTD::swap(__r_.first(), __str.__r_.first()); | 
| Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 3275 |     __swap_allocator(__alloc(), __str.__alloc()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3276 | } | 
 | 3277 |  | 
 | 3278 | // find | 
 | 3279 |  | 
 | 3280 | template <class _Traits> | 
 | 3281 | struct _LIBCPP_HIDDEN __traits_eq | 
 | 3282 | { | 
 | 3283 |     typedef typename _Traits::char_type char_type; | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3284 |     _LIBCPP_INLINE_VISIBILITY | 
 | 3285 |     bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT | 
 | 3286 |         {return _Traits::eq(__x, __y);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3287 | }; | 
 | 3288 |  | 
 | 3289 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3290 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3291 | basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3292 |                                                 size_type __pos, | 
 | 3293 |                                                 size_type __n) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3294 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3295 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3296 |     return __str_find<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 360f319 | 2014-06-02 02:22:49 +0000 | [diff] [blame] | 3297 |         (data(), size(), __s, __pos, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3298 | } | 
 | 3299 |  | 
 | 3300 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3301 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3302 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3303 | basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, | 
 | 3304 |                                                 size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3305 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3306 |     return __str_find<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 360f319 | 2014-06-02 02:22:49 +0000 | [diff] [blame] | 3307 |         (data(), size(), __str.data(), __pos, __str.size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3308 | } | 
 | 3309 |  | 
 | 3310 | template<class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3311 | template <class _Tp> | 
 | 3312 | typename enable_if | 
 | 3313 | < | 
 | 3314 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 3315 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
 | 3316 | >::type | 
 | 3317 | basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t, | 
 | 3318 |                                                 size_type __pos) const | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3319 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3320 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3321 |     return __str_find<value_type, size_type, traits_type, npos> | 
 | 3322 |         (data(), size(), __sv.data(), __pos, __sv.size()); | 
 | 3323 | } | 
 | 3324 |  | 
 | 3325 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3326 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3327 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3328 | basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3329 |                                                 size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3330 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3331 |     _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3332 |     return __str_find<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 360f319 | 2014-06-02 02:22:49 +0000 | [diff] [blame] | 3333 |         (data(), size(), __s, __pos, traits_type::length(__s)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3334 | } | 
 | 3335 |  | 
 | 3336 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3337 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3338 | basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, | 
 | 3339 |                                                 size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3340 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3341 |     return __str_find<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 360f319 | 2014-06-02 02:22:49 +0000 | [diff] [blame] | 3342 |         (data(), size(), __c, __pos); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3343 | } | 
 | 3344 |  | 
 | 3345 | // rfind | 
 | 3346 |  | 
 | 3347 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3348 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3349 | basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3350 |                                                  size_type __pos, | 
 | 3351 |                                                  size_type __n) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3352 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3353 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3354 |     return __str_rfind<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 360f319 | 2014-06-02 02:22:49 +0000 | [diff] [blame] | 3355 |         (data(), size(), __s, __pos, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3356 | } | 
 | 3357 |  | 
 | 3358 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3359 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3360 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3361 | basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, | 
 | 3362 |                                                  size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3363 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3364 |     return __str_rfind<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 360f319 | 2014-06-02 02:22:49 +0000 | [diff] [blame] | 3365 |         (data(), size(), __str.data(), __pos, __str.size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3366 | } | 
 | 3367 |  | 
 | 3368 | template<class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3369 | template <class _Tp> | 
 | 3370 | typename enable_if | 
 | 3371 | < | 
 | 3372 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 3373 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
 | 3374 | >::type | 
 | 3375 | basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, | 
 | 3376 |                                                 size_type __pos) const | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3377 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3378 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3379 |     return __str_rfind<value_type, size_type, traits_type, npos> | 
 | 3380 |         (data(), size(), __sv.data(), __pos, __sv.size()); | 
 | 3381 | } | 
 | 3382 |  | 
 | 3383 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3384 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3385 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3386 | basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3387 |                                                  size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3388 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3389 |     _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3390 |     return __str_rfind<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 360f319 | 2014-06-02 02:22:49 +0000 | [diff] [blame] | 3391 |         (data(), size(), __s, __pos, traits_type::length(__s)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3392 | } | 
 | 3393 |  | 
 | 3394 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3395 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3396 | basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, | 
 | 3397 |                                                  size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3398 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3399 |     return __str_rfind<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 360f319 | 2014-06-02 02:22:49 +0000 | [diff] [blame] | 3400 |         (data(), size(), __c, __pos); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3401 | } | 
 | 3402 |  | 
 | 3403 | // find_first_of | 
 | 3404 |  | 
 | 3405 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3406 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3407 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3408 |                                                          size_type __pos, | 
 | 3409 |                                                          size_type __n) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3410 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3411 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3412 |     return __str_find_first_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3413 |         (data(), size(), __s, __pos, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3414 | } | 
 | 3415 |  | 
 | 3416 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3417 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3418 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3419 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, | 
 | 3420 |                                                          size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3421 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3422 |     return __str_find_first_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3423 |         (data(), size(), __str.data(), __pos, __str.size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3424 | } | 
 | 3425 |  | 
 | 3426 | template<class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3427 | template <class _Tp> | 
 | 3428 | typename enable_if | 
 | 3429 | < | 
 | 3430 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 3431 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
 | 3432 | >::type | 
 | 3433 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, | 
 | 3434 |                                                 size_type __pos) const | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3435 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3436 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3437 |     return __str_find_first_of<value_type, size_type, traits_type, npos> | 
 | 3438 |         (data(), size(), __sv.data(), __pos, __sv.size()); | 
 | 3439 | } | 
 | 3440 |  | 
 | 3441 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3442 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3443 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3444 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3445 |                                                          size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3446 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3447 |     _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3448 |     return __str_find_first_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3449 |         (data(), size(), __s, __pos, traits_type::length(__s)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3450 | } | 
 | 3451 |  | 
 | 3452 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3453 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3454 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3455 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, | 
 | 3456 |                                                          size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3457 | { | 
 | 3458 |     return find(__c, __pos); | 
 | 3459 | } | 
 | 3460 |  | 
 | 3461 | // find_last_of | 
 | 3462 |  | 
 | 3463 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3464 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3465 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3466 |                                                         size_type __pos, | 
 | 3467 |                                                         size_type __n) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3468 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3469 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3470 |     return __str_find_last_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3471 |         (data(), size(), __s, __pos, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3472 | } | 
 | 3473 |  | 
 | 3474 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3475 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3476 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3477 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, | 
 | 3478 |                                                         size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3479 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3480 |     return __str_find_last_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3481 |         (data(), size(), __str.data(), __pos, __str.size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3482 | } | 
 | 3483 |  | 
 | 3484 | template<class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3485 | template <class _Tp> | 
 | 3486 | typename enable_if | 
 | 3487 | < | 
 | 3488 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 3489 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
 | 3490 | >::type | 
 | 3491 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, | 
 | 3492 |                                                 size_type __pos) const | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3493 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3494 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3495 |     return __str_find_last_of<value_type, size_type, traits_type, npos> | 
 | 3496 |         (data(), size(), __sv.data(), __pos, __sv.size()); | 
 | 3497 | } | 
 | 3498 |  | 
 | 3499 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3500 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3501 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3502 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3503 |                                                         size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3504 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3505 |     _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3506 |     return __str_find_last_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3507 |         (data(), size(), __s, __pos, traits_type::length(__s)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3508 | } | 
 | 3509 |  | 
 | 3510 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3511 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3512 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3513 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, | 
 | 3514 |                                                         size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3515 | { | 
 | 3516 |     return rfind(__c, __pos); | 
 | 3517 | } | 
 | 3518 |  | 
 | 3519 | // find_first_not_of | 
 | 3520 |  | 
 | 3521 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3522 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3523 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3524 |                                                              size_type __pos, | 
 | 3525 |                                                              size_type __n) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3526 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3527 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3528 |     return __str_find_first_not_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3529 |         (data(), size(), __s, __pos, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3530 | } | 
 | 3531 |  | 
 | 3532 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3533 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3534 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3535 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, | 
 | 3536 |                                                              size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3537 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3538 |     return __str_find_first_not_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3539 |         (data(), size(), __str.data(), __pos, __str.size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3540 | } | 
 | 3541 |  | 
 | 3542 | template<class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3543 | template <class _Tp> | 
 | 3544 | typename enable_if | 
 | 3545 | < | 
 | 3546 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 3547 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
 | 3548 | >::type | 
 | 3549 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, | 
 | 3550 |                                                 size_type __pos) const | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3551 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3552 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3553 |     return __str_find_first_not_of<value_type, size_type, traits_type, npos> | 
 | 3554 |         (data(), size(), __sv.data(), __pos, __sv.size()); | 
 | 3555 | } | 
 | 3556 |  | 
 | 3557 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3558 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3559 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3560 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3561 |                                                              size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3562 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3563 |     _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3564 |     return __str_find_first_not_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3565 |         (data(), size(), __s, __pos, traits_type::length(__s)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3566 | } | 
 | 3567 |  | 
 | 3568 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3569 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3570 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3571 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, | 
 | 3572 |                                                              size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3573 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3574 |     return __str_find_first_not_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3575 |         (data(), size(), __c, __pos); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3576 | } | 
 | 3577 |  | 
 | 3578 | // find_last_not_of | 
 | 3579 |  | 
 | 3580 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3581 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3582 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3583 |                                                             size_type __pos, | 
 | 3584 |                                                             size_type __n) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3585 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3586 |     _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3587 |     return __str_find_last_not_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3588 |         (data(), size(), __s, __pos, __n); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3589 | } | 
 | 3590 |  | 
 | 3591 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3592 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3593 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3594 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, | 
 | 3595 |                                                             size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3596 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3597 |     return __str_find_last_not_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3598 |         (data(), size(), __str.data(), __pos, __str.size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3599 | } | 
 | 3600 |  | 
 | 3601 | template<class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3602 | template <class _Tp> | 
 | 3603 | typename enable_if | 
 | 3604 | < | 
 | 3605 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 3606 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
 | 3607 | >::type | 
 | 3608 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, | 
 | 3609 |                                                 size_type __pos) const | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3610 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3611 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3612 |     return __str_find_last_not_of<value_type, size_type, traits_type, npos> | 
 | 3613 |         (data(), size(), __sv.data(), __pos, __sv.size()); | 
 | 3614 | } | 
 | 3615 |  | 
 | 3616 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3617 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3618 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3619 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3620 |                                                             size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3621 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3622 |     _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr"); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3623 |     return __str_find_last_not_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3624 |         (data(), size(), __s, __pos, traits_type::length(__s)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3625 | } | 
 | 3626 |  | 
 | 3627 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3628 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3629 | typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3630 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, | 
 | 3631 |                                                             size_type __pos) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3632 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3633 |     return __str_find_last_not_of<value_type, size_type, traits_type, npos> | 
| Marshall Clow | 8eb5acc | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 3634 |         (data(), size(), __c, __pos); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3635 | } | 
 | 3636 |  | 
 | 3637 | // compare | 
 | 3638 |  | 
 | 3639 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3640 | template <class _Tp> | 
 | 3641 | typename enable_if | 
 | 3642 | < | 
 | 3643 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 3644 |     int | 
 | 3645 | >::type | 
 | 3646 | basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3647 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3648 |     __self_view __sv = __t; | 
| Howard Hinnant | fa06d75 | 2011-07-24 21:45:06 +0000 | [diff] [blame] | 3649 |     size_t __lhs_sz = size(); | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3650 |     size_t __rhs_sz = __sv.size(); | 
 | 3651 |     int __result = traits_type::compare(data(), __sv.data(), | 
| Howard Hinnant | fa06d75 | 2011-07-24 21:45:06 +0000 | [diff] [blame] | 3652 |                                         _VSTD::min(__lhs_sz, __rhs_sz)); | 
 | 3653 |     if (__result != 0) | 
 | 3654 |         return __result; | 
 | 3655 |     if (__lhs_sz < __rhs_sz) | 
 | 3656 |         return -1; | 
 | 3657 |     if (__lhs_sz > __rhs_sz) | 
 | 3658 |         return 1; | 
 | 3659 |     return 0; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3660 | } | 
 | 3661 |  | 
 | 3662 | template <class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3663 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3664 | int | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3665 | basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3666 | { | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3667 |     return compare(__self_view(__str)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3668 | } | 
 | 3669 |  | 
 | 3670 | template <class _CharT, class _Traits, class _Allocator> | 
 | 3671 | int | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3672 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, | 
 | 3673 |                                                    size_type __n1, | 
| Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 3674 |                                                    const value_type* __s, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3675 |                                                    size_type __n2) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3676 | { | 
| Alp Toker | ec34c48 | 2014-05-15 11:27:39 +0000 | [diff] [blame] | 3677 |     _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3678 |     size_type __sz = size(); | 
 | 3679 |     if (__pos1 > __sz || __n2 == npos) | 
 | 3680 |         this->__throw_out_of_range(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3681 |     size_type __rlen = _VSTD::min(__n1, __sz - __pos1); | 
 | 3682 |     int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3683 |     if (__r == 0) | 
 | 3684 |     { | 
 | 3685 |         if (__rlen < __n2) | 
 | 3686 |             __r = -1; | 
 | 3687 |         else if (__rlen > __n2) | 
 | 3688 |             __r = 1; | 
 | 3689 |     } | 
 | 3690 |     return __r; | 
 | 3691 | } | 
 | 3692 |  | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3693 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3694 | template <class _Tp> | 
 | 3695 | typename enable_if | 
 | 3696 | < | 
 | 3697 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 3698 |     int | 
 | 3699 | >::type | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3700 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, | 
 | 3701 |                                                    size_type __n1, | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3702 |                                                    const _Tp& __t) const | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3703 | { | 
| Marshall Clow | 64c10d0 | 2018-07-02 18:41:15 +0000 | [diff] [blame] | 3704 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3705 |     return compare(__pos1, __n1, __sv.data(), __sv.size()); | 
 | 3706 | } | 
 | 3707 |  | 
 | 3708 | template <class _CharT, class _Traits, class _Allocator> | 
 | 3709 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3710 | int | 
 | 3711 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, | 
 | 3712 |                                                    size_type __n1, | 
 | 3713 |                                                    const basic_string& __str) const | 
 | 3714 | { | 
 | 3715 |     return compare(__pos1, __n1, __str.data(), __str.size()); | 
 | 3716 | } | 
 | 3717 |  | 
 | 3718 | template <class _CharT, class _Traits, class _Allocator> | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 3719 | template <class _Tp> | 
 | 3720 | typename enable_if | 
 | 3721 | < | 
| Marshall Clow | f1729d9 | 2017-11-15 20:02:27 +0000 | [diff] [blame] | 3722 |     __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, | 
 | 3723 |     int | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 3724 | >::type | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3725 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, | 
 | 3726 |                                                    size_type __n1, | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 3727 |                                                    const _Tp& __t, | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3728 |                                                    size_type __pos2, | 
 | 3729 |                                                    size_type __n2) const | 
 | 3730 | { | 
| Marshall Clow | 6ac8de0 | 2016-09-24 22:45:42 +0000 | [diff] [blame] | 3731 |     __self_view __sv = __t; | 
| Marshall Clow | 1e00d6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 3732 |     return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); | 
 | 3733 | } | 
 | 3734 |  | 
 | 3735 | template <class _CharT, class _Traits, class _Allocator> | 
 | 3736 | int | 
 | 3737 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, | 
 | 3738 |                                                    size_type __n1, | 
 | 3739 |                                                    const basic_string& __str, | 
 | 3740 |                                                    size_type __pos2, | 
 | 3741 |                                                    size_type __n2) const | 
 | 3742 | { | 
 | 3743 |         return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); | 
 | 3744 | } | 
 | 3745 |  | 
 | 3746 | template <class _CharT, class _Traits, class _Allocator> | 
 | 3747 | int | 
 | 3748 | basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT | 
 | 3749 | { | 
 | 3750 |     _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); | 
 | 3751 |     return compare(0, npos, __s, traits_type::length(__s)); | 
 | 3752 | } | 
 | 3753 |  | 
 | 3754 | template <class _CharT, class _Traits, class _Allocator> | 
 | 3755 | int | 
 | 3756 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, | 
 | 3757 |                                                    size_type __n1, | 
 | 3758 |                                                    const value_type* __s) const | 
 | 3759 | { | 
 | 3760 |     _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); | 
 | 3761 |     return compare(__pos1, __n1, __s, traits_type::length(__s)); | 
 | 3762 | } | 
 | 3763 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3764 | // __invariants | 
 | 3765 |  | 
 | 3766 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3767 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3768 | bool | 
 | 3769 | basic_string<_CharT, _Traits, _Allocator>::__invariants() const | 
 | 3770 | { | 
 | 3771 |     if (size() > capacity()) | 
 | 3772 |         return false; | 
 | 3773 |     if (capacity() < __min_cap - 1) | 
 | 3774 |         return false; | 
 | 3775 |     if (data() == 0) | 
 | 3776 |         return false; | 
 | 3777 |     if (data()[size()] != value_type(0)) | 
 | 3778 |         return false; | 
 | 3779 |     return true; | 
 | 3780 | } | 
 | 3781 |  | 
| Vedant Kumar | 2b588cb | 2018-03-08 21:15:26 +0000 | [diff] [blame] | 3782 | // __clear_and_shrink | 
 | 3783 |  | 
 | 3784 | template<class _CharT, class _Traits, class _Allocator> | 
 | 3785 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3786 | void  | 
| Marshall Clow | ab343bb | 2018-05-29 17:04:37 +0000 | [diff] [blame] | 3787 | basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT | 
| Vedant Kumar | 2b588cb | 2018-03-08 21:15:26 +0000 | [diff] [blame] | 3788 | { | 
 | 3789 |     clear(); | 
 | 3790 |     if(__is_long()) | 
 | 3791 |     { | 
 | 3792 |         __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1); | 
 | 3793 |         __set_long_cap(0); | 
 | 3794 |         __set_short_size(0); | 
 | 3795 |     } | 
 | 3796 | }  | 
 | 3797 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3798 | // operator== | 
 | 3799 |  | 
 | 3800 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3801 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3802 | bool | 
 | 3803 | operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3804 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3805 | { | 
| Howard Hinnant | 08dd253 | 2013-04-22 23:55:13 +0000 | [diff] [blame] | 3806 |     size_t __lhs_sz = __lhs.size(); | 
 | 3807 |     return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), | 
 | 3808 |                                                         __rhs.data(), | 
 | 3809 |                                                         __lhs_sz) == 0; | 
 | 3810 | } | 
 | 3811 |  | 
 | 3812 | template<class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3813 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 08dd253 | 2013-04-22 23:55:13 +0000 | [diff] [blame] | 3814 | bool | 
 | 3815 | operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, | 
 | 3816 |            const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT | 
 | 3817 | { | 
 | 3818 |     size_t __lhs_sz = __lhs.size(); | 
 | 3819 |     if (__lhs_sz != __rhs.size()) | 
 | 3820 |         return false; | 
 | 3821 |     const char* __lp = __lhs.data(); | 
 | 3822 |     const char* __rp = __rhs.data(); | 
 | 3823 |     if (__lhs.__is_long()) | 
 | 3824 |         return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0; | 
 | 3825 |     for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp) | 
 | 3826 |         if (*__lp != *__rp) | 
 | 3827 |             return false; | 
 | 3828 |     return true; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3829 | } | 
 | 3830 |  | 
 | 3831 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3832 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3833 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3834 | operator==(const _CharT* __lhs, | 
 | 3835 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3836 | { | 
| Eric Fiselier | 4f24182 | 2015-08-28 03:02:37 +0000 | [diff] [blame] | 3837 |     typedef basic_string<_CharT, _Traits, _Allocator> _String; | 
 | 3838 |     _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr"); | 
 | 3839 |     size_t __lhs_len = _Traits::length(__lhs); | 
 | 3840 |     if (__lhs_len != __rhs.size()) return false; | 
 | 3841 |     return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3842 | } | 
 | 3843 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3844 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3845 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3846 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3847 | operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, | 
 | 3848 |            const _CharT* __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3849 | { | 
| Eric Fiselier | 4f24182 | 2015-08-28 03:02:37 +0000 | [diff] [blame] | 3850 |     typedef basic_string<_CharT, _Traits, _Allocator> _String; | 
 | 3851 |     _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); | 
 | 3852 |     size_t __rhs_len = _Traits::length(__rhs); | 
 | 3853 |     if (__rhs_len != __lhs.size()) return false; | 
 | 3854 |     return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3855 | } | 
 | 3856 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3857 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3858 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3859 | bool | 
 | 3860 | operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3861 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3862 | { | 
 | 3863 |     return !(__lhs == __rhs); | 
 | 3864 | } | 
 | 3865 |  | 
 | 3866 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3867 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3868 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3869 | operator!=(const _CharT* __lhs, | 
 | 3870 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3871 | { | 
 | 3872 |     return !(__lhs == __rhs); | 
 | 3873 | } | 
 | 3874 |  | 
 | 3875 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3876 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3877 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3878 | operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
 | 3879 |            const _CharT* __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3880 | { | 
 | 3881 |     return !(__lhs == __rhs); | 
 | 3882 | } | 
 | 3883 |  | 
 | 3884 | // operator< | 
 | 3885 |  | 
 | 3886 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3887 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3888 | bool | 
 | 3889 | operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3890 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3891 | { | 
| Howard Hinnant | 2644a7b | 2011-07-24 15:07:21 +0000 | [diff] [blame] | 3892 |     return __lhs.compare(__rhs) < 0; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3893 | } | 
 | 3894 |  | 
 | 3895 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3896 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3897 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3898 | operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
 | 3899 |            const _CharT* __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3900 | { | 
| Howard Hinnant | 2644a7b | 2011-07-24 15:07:21 +0000 | [diff] [blame] | 3901 |     return __lhs.compare(__rhs) < 0; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3902 | } | 
 | 3903 |  | 
 | 3904 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3905 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3906 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3907 | operator< (const _CharT* __lhs, | 
 | 3908 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3909 | { | 
 | 3910 |     return __rhs.compare(__lhs) > 0; | 
 | 3911 | } | 
 | 3912 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3913 | // operator> | 
 | 3914 |  | 
 | 3915 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3916 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3917 | bool | 
 | 3918 | operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3919 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3920 | { | 
 | 3921 |     return __rhs < __lhs; | 
 | 3922 | } | 
 | 3923 |  | 
 | 3924 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3925 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3926 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3927 | operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
 | 3928 |            const _CharT* __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3929 | { | 
 | 3930 |     return __rhs < __lhs; | 
 | 3931 | } | 
 | 3932 |  | 
 | 3933 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3934 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3935 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3936 | operator> (const _CharT* __lhs, | 
 | 3937 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3938 | { | 
 | 3939 |     return __rhs < __lhs; | 
 | 3940 | } | 
 | 3941 |  | 
 | 3942 | // operator<= | 
 | 3943 |  | 
 | 3944 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3945 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3946 | bool | 
 | 3947 | operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3948 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3949 | { | 
 | 3950 |     return !(__rhs < __lhs); | 
 | 3951 | } | 
 | 3952 |  | 
 | 3953 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3954 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3955 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3956 | operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
 | 3957 |            const _CharT* __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3958 | { | 
 | 3959 |     return !(__rhs < __lhs); | 
 | 3960 | } | 
 | 3961 |  | 
 | 3962 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3963 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3964 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3965 | operator<=(const _CharT* __lhs, | 
 | 3966 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3967 | { | 
 | 3968 |     return !(__rhs < __lhs); | 
 | 3969 | } | 
 | 3970 |  | 
 | 3971 | // operator>= | 
 | 3972 |  | 
 | 3973 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3974 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3975 | bool | 
 | 3976 | operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3977 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3978 | { | 
 | 3979 |     return !(__lhs < __rhs); | 
 | 3980 | } | 
 | 3981 |  | 
 | 3982 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3983 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3984 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3985 | operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
 | 3986 |            const _CharT* __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3987 | { | 
 | 3988 |     return !(__lhs < __rhs); | 
 | 3989 | } | 
 | 3990 |  | 
 | 3991 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 3992 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3993 | bool | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 3994 | operator>=(const _CharT* __lhs, | 
 | 3995 |            const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3996 | { | 
 | 3997 |     return !(__lhs < __rhs); | 
 | 3998 | } | 
 | 3999 |  | 
 | 4000 | // operator + | 
 | 4001 |  | 
 | 4002 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4003 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4004 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
 | 4005 |           const basic_string<_CharT, _Traits, _Allocator>& __rhs) | 
 | 4006 | { | 
 | 4007 |     basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); | 
 | 4008 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); | 
 | 4009 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); | 
 | 4010 |     __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); | 
 | 4011 |     __r.append(__rhs.data(), __rhs_sz); | 
 | 4012 |     return __r; | 
 | 4013 | } | 
 | 4014 |  | 
 | 4015 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4016 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4017 | operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) | 
 | 4018 | { | 
 | 4019 |     basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); | 
 | 4020 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs); | 
 | 4021 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); | 
 | 4022 |     __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz); | 
 | 4023 |     __r.append(__rhs.data(), __rhs_sz); | 
 | 4024 |     return __r; | 
 | 4025 | } | 
 | 4026 |  | 
 | 4027 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4028 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4029 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs) | 
 | 4030 | { | 
 | 4031 |     basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); | 
 | 4032 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); | 
 | 4033 |     __r.__init(&__lhs, 1, 1 + __rhs_sz); | 
 | 4034 |     __r.append(__rhs.data(), __rhs_sz); | 
 | 4035 |     return __r; | 
 | 4036 | } | 
 | 4037 |  | 
 | 4038 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4039 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4040 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) | 
 | 4041 | { | 
 | 4042 |     basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); | 
 | 4043 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); | 
 | 4044 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs); | 
 | 4045 |     __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); | 
 | 4046 |     __r.append(__rhs, __rhs_sz); | 
 | 4047 |     return __r; | 
 | 4048 | } | 
 | 4049 |  | 
 | 4050 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4051 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4052 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) | 
 | 4053 | { | 
 | 4054 |     basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); | 
 | 4055 |     typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); | 
 | 4056 |     __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1); | 
 | 4057 |     __r.push_back(__rhs); | 
 | 4058 |     return __r; | 
 | 4059 | } | 
 | 4060 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 4061 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4062 |  | 
 | 4063 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 4064 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4065 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4066 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) | 
 | 4067 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4068 |     return _VSTD::move(__lhs.append(__rhs)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4069 | } | 
 | 4070 |  | 
 | 4071 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 4072 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4073 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4074 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) | 
 | 4075 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4076 |     return _VSTD::move(__rhs.insert(0, __lhs)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4077 | } | 
 | 4078 |  | 
 | 4079 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 4080 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4081 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4082 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) | 
 | 4083 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4084 |     return _VSTD::move(__lhs.append(__rhs)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4085 | } | 
 | 4086 |  | 
 | 4087 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 4088 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4089 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4090 | operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) | 
 | 4091 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4092 |     return _VSTD::move(__rhs.insert(0, __lhs)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4093 | } | 
 | 4094 |  | 
 | 4095 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 4096 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4097 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4098 | operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) | 
 | 4099 | { | 
 | 4100 |     __rhs.insert(__rhs.begin(), __lhs); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4101 |     return _VSTD::move(__rhs); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4102 | } | 
 | 4103 |  | 
 | 4104 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 4105 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4106 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4107 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) | 
 | 4108 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4109 |     return _VSTD::move(__lhs.append(__rhs)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4110 | } | 
 | 4111 |  | 
 | 4112 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 4113 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4114 | basic_string<_CharT, _Traits, _Allocator> | 
 | 4115 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) | 
 | 4116 | { | 
 | 4117 |     __lhs.push_back(__rhs); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4118 |     return _VSTD::move(__lhs); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4119 | } | 
 | 4120 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 4121 | #endif  // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4122 |  | 
 | 4123 | // swap | 
 | 4124 |  | 
 | 4125 | template<class _CharT, class _Traits, class _Allocator> | 
| Howard Hinnant | 1e56424 | 2013-10-04 22:09:00 +0000 | [diff] [blame] | 4126 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4127 | void | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 4128 | swap(basic_string<_CharT, _Traits, _Allocator>& __lhs, | 
| Howard Hinnant | 53f7d4c | 2011-06-03 18:40:47 +0000 | [diff] [blame] | 4129 |      basic_string<_CharT, _Traits, _Allocator>& __rhs) | 
 | 4130 |      _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs))) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4131 | { | 
 | 4132 |     __lhs.swap(__rhs); | 
 | 4133 | } | 
 | 4134 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4135 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | 
 | 4136 |  | 
 | 4137 | typedef basic_string<char16_t> u16string; | 
 | 4138 | typedef basic_string<char32_t> u32string; | 
 | 4139 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4140 | #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4141 |  | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 4142 | _LIBCPP_FUNC_VIS int                stoi  (const string& __str, size_t* __idx = 0, int __base = 10); | 
 | 4143 | _LIBCPP_FUNC_VIS long               stol  (const string& __str, size_t* __idx = 0, int __base = 10); | 
 | 4144 | _LIBCPP_FUNC_VIS unsigned long      stoul (const string& __str, size_t* __idx = 0, int __base = 10); | 
 | 4145 | _LIBCPP_FUNC_VIS long long          stoll (const string& __str, size_t* __idx = 0, int __base = 10); | 
 | 4146 | _LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 4147 |  | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 4148 | _LIBCPP_FUNC_VIS float       stof (const string& __str, size_t* __idx = 0); | 
 | 4149 | _LIBCPP_FUNC_VIS double      stod (const string& __str, size_t* __idx = 0); | 
 | 4150 | _LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = 0); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 4151 |  | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 4152 | _LIBCPP_FUNC_VIS string to_string(int __val); | 
 | 4153 | _LIBCPP_FUNC_VIS string to_string(unsigned __val); | 
 | 4154 | _LIBCPP_FUNC_VIS string to_string(long __val); | 
 | 4155 | _LIBCPP_FUNC_VIS string to_string(unsigned long __val); | 
 | 4156 | _LIBCPP_FUNC_VIS string to_string(long long __val); | 
 | 4157 | _LIBCPP_FUNC_VIS string to_string(unsigned long long __val); | 
 | 4158 | _LIBCPP_FUNC_VIS string to_string(float __val); | 
 | 4159 | _LIBCPP_FUNC_VIS string to_string(double __val); | 
 | 4160 | _LIBCPP_FUNC_VIS string to_string(long double __val); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 4161 |  | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 4162 | _LIBCPP_FUNC_VIS int                stoi  (const wstring& __str, size_t* __idx = 0, int __base = 10); | 
 | 4163 | _LIBCPP_FUNC_VIS long               stol  (const wstring& __str, size_t* __idx = 0, int __base = 10); | 
 | 4164 | _LIBCPP_FUNC_VIS unsigned long      stoul (const wstring& __str, size_t* __idx = 0, int __base = 10); | 
 | 4165 | _LIBCPP_FUNC_VIS long long          stoll (const wstring& __str, size_t* __idx = 0, int __base = 10); | 
 | 4166 | _LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 4167 |  | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 4168 | _LIBCPP_FUNC_VIS float       stof (const wstring& __str, size_t* __idx = 0); | 
 | 4169 | _LIBCPP_FUNC_VIS double      stod (const wstring& __str, size_t* __idx = 0); | 
 | 4170 | _LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = 0); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 4171 |  | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 4172 | _LIBCPP_FUNC_VIS wstring to_wstring(int __val); | 
 | 4173 | _LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val); | 
 | 4174 | _LIBCPP_FUNC_VIS wstring to_wstring(long __val); | 
 | 4175 | _LIBCPP_FUNC_VIS wstring to_wstring(unsigned long __val); | 
 | 4176 | _LIBCPP_FUNC_VIS wstring to_wstring(long long __val); | 
 | 4177 | _LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val); | 
 | 4178 | _LIBCPP_FUNC_VIS wstring to_wstring(float __val); | 
 | 4179 | _LIBCPP_FUNC_VIS wstring to_wstring(double __val); | 
 | 4180 | _LIBCPP_FUNC_VIS wstring to_wstring(long double __val); | 
| Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 4181 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4182 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4183 |     const typename basic_string<_CharT, _Traits, _Allocator>::size_type | 
 | 4184 |                    basic_string<_CharT, _Traits, _Allocator>::npos; | 
 | 4185 |  | 
 | 4186 | template<class _CharT, class _Traits, class _Allocator> | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 4187 | struct _LIBCPP_TEMPLATE_VIS hash<basic_string<_CharT, _Traits, _Allocator> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4188 |     : public unary_function<basic_string<_CharT, _Traits, _Allocator>, size_t> | 
 | 4189 | { | 
 | 4190 |     size_t | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 4191 |         operator()(const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4192 | }; | 
 | 4193 |  | 
 | 4194 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4195 | size_t | 
 | 4196 | hash<basic_string<_CharT, _Traits, _Allocator> >::operator()( | 
| Howard Hinnant | a6119a8 | 2011-05-29 19:57:12 +0000 | [diff] [blame] | 4197 |         const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4198 | { | 
| Sean Hunt | affd9e5 | 2011-07-29 23:31:56 +0000 | [diff] [blame] | 4199 |     return __do_string_hash(__val.data(), __val.data() + __val.size()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4200 | } | 
 | 4201 |  | 
| Howard Hinnant | 464aa5c | 2011-07-18 15:51:59 +0000 | [diff] [blame] | 4202 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4203 | basic_ostream<_CharT, _Traits>& | 
 | 4204 | operator<<(basic_ostream<_CharT, _Traits>& __os, | 
 | 4205 |            const basic_string<_CharT, _Traits, _Allocator>& __str); | 
 | 4206 |  | 
 | 4207 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4208 | basic_istream<_CharT, _Traits>& | 
 | 4209 | operator>>(basic_istream<_CharT, _Traits>& __is, | 
 | 4210 |            basic_string<_CharT, _Traits, _Allocator>& __str); | 
 | 4211 |  | 
 | 4212 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4213 | basic_istream<_CharT, _Traits>& | 
 | 4214 | getline(basic_istream<_CharT, _Traits>& __is, | 
 | 4215 |         basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); | 
 | 4216 |  | 
 | 4217 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4218 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4219 | basic_istream<_CharT, _Traits>& | 
 | 4220 | getline(basic_istream<_CharT, _Traits>& __is, | 
 | 4221 |         basic_string<_CharT, _Traits, _Allocator>& __str); | 
 | 4222 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 4223 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 464aa5c | 2011-07-18 15:51:59 +0000 | [diff] [blame] | 4224 |  | 
 | 4225 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4226 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4227 | basic_istream<_CharT, _Traits>& | 
 | 4228 | getline(basic_istream<_CharT, _Traits>&& __is, | 
 | 4229 |         basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); | 
 | 4230 |  | 
 | 4231 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4232 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4233 | basic_istream<_CharT, _Traits>& | 
 | 4234 | getline(basic_istream<_CharT, _Traits>&& __is, | 
 | 4235 |         basic_string<_CharT, _Traits, _Allocator>& __str); | 
 | 4236 |  | 
| Eric Fiselier | 3e92897 | 2017-04-19 00:28:44 +0000 | [diff] [blame] | 4237 | #endif  // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 464aa5c | 2011-07-18 15:51:59 +0000 | [diff] [blame] | 4238 |  | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 4239 | #if _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 4240 |  | 
 | 4241 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4242 | bool | 
 | 4243 | basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const | 
 | 4244 | { | 
 | 4245 |     return this->data() <= _VSTD::__to_raw_pointer(__i->base()) && | 
 | 4246 |            _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size(); | 
 | 4247 | } | 
 | 4248 |  | 
 | 4249 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4250 | bool | 
 | 4251 | basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const | 
 | 4252 | { | 
 | 4253 |     return this->data() < _VSTD::__to_raw_pointer(__i->base()) && | 
 | 4254 |            _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size(); | 
 | 4255 | } | 
 | 4256 |  | 
 | 4257 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4258 | bool | 
 | 4259 | basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const | 
 | 4260 | { | 
 | 4261 |     const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; | 
 | 4262 |     return this->data() <= __p && __p <= this->data() + this->size(); | 
 | 4263 | } | 
 | 4264 |  | 
 | 4265 | template<class _CharT, class _Traits, class _Allocator> | 
 | 4266 | bool | 
 | 4267 | basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const | 
 | 4268 | { | 
 | 4269 |     const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; | 
 | 4270 |     return this->data() <= __p && __p < this->data() + this->size(); | 
 | 4271 | } | 
 | 4272 |  | 
 | 4273 | #endif  // _LIBCPP_DEBUG_LEVEL >= 2 | 
 | 4274 |  | 
| Shoaib Meenai | 6850670 | 2017-06-29 02:52:46 +0000 | [diff] [blame] | 4275 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<char>) | 
 | 4276 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<wchar_t>) | 
| Shoaib Meenai | 6850670 | 2017-06-29 02:52:46 +0000 | [diff] [blame] | 4277 |  | 
| Marshall Clow | 1523432 | 2013-07-23 17:05:24 +0000 | [diff] [blame] | 4278 | #if _LIBCPP_STD_VER > 11  | 
 | 4279 | // Literal suffixes for basic_string [basic.string.literals] | 
| Marshall Clow | 8d9dd7a | 2013-10-05 21:18:32 +0000 | [diff] [blame] | 4280 | inline namespace literals | 
| Marshall Clow | 1523432 | 2013-07-23 17:05:24 +0000 | [diff] [blame] | 4281 | { | 
 | 4282 |   inline namespace string_literals | 
 | 4283 |   { | 
| Howard Hinnant | ab61b2c | 2013-08-07 19:39:48 +0000 | [diff] [blame] | 4284 |     inline _LIBCPP_INLINE_VISIBILITY | 
 | 4285 |     basic_string<char> operator "" s( const char *__str, size_t __len ) | 
 | 4286 |     { | 
 | 4287 |         return basic_string<char> (__str, __len); | 
 | 4288 |     } | 
| Marshall Clow | 1523432 | 2013-07-23 17:05:24 +0000 | [diff] [blame] | 4289 |  | 
| Howard Hinnant | ab61b2c | 2013-08-07 19:39:48 +0000 | [diff] [blame] | 4290 |     inline _LIBCPP_INLINE_VISIBILITY | 
 | 4291 |     basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len ) | 
 | 4292 |     { | 
 | 4293 |         return basic_string<wchar_t> (__str, __len); | 
 | 4294 |     } | 
| Marshall Clow | 1523432 | 2013-07-23 17:05:24 +0000 | [diff] [blame] | 4295 |  | 
| Howard Hinnant | ab61b2c | 2013-08-07 19:39:48 +0000 | [diff] [blame] | 4296 |     inline _LIBCPP_INLINE_VISIBILITY | 
 | 4297 |     basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len ) | 
 | 4298 |     { | 
 | 4299 |         return basic_string<char16_t> (__str, __len); | 
 | 4300 |     } | 
| Marshall Clow | 1523432 | 2013-07-23 17:05:24 +0000 | [diff] [blame] | 4301 |  | 
| Howard Hinnant | ab61b2c | 2013-08-07 19:39:48 +0000 | [diff] [blame] | 4302 |     inline _LIBCPP_INLINE_VISIBILITY | 
 | 4303 |     basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len ) | 
 | 4304 |     { | 
 | 4305 |         return basic_string<char32_t> (__str, __len); | 
 | 4306 |     } | 
| Marshall Clow | 1523432 | 2013-07-23 17:05:24 +0000 | [diff] [blame] | 4307 |   } | 
 | 4308 | } | 
 | 4309 | #endif | 
 | 4310 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4311 | _LIBCPP_END_NAMESPACE_STD | 
 | 4312 |  | 
| Eric Fiselier | 018a3d5 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 4313 | _LIBCPP_POP_MACROS | 
 | 4314 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4315 | #endif  // _LIBCPP_STRING |