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