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