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