- tmp/tmp_q63mond/{from.md → to.md} +537 -641
tmp/tmp_q63mond/{from.md → to.md}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
## Class template `basic_string` <a id="basic.string">[[basic.string]]</a>
|
| 2 |
|
| 3 |
The class template `basic_string` describes objects that can store a
|
| 4 |
sequence consisting of a varying number of arbitrary char-like objects
|
| 5 |
with the first element of the sequence at position zero. Such a sequence
|
| 6 |
is also called a “string” if the type of the char-like objects that it
|
|
@@ -10,12 +10,12 @@ char-like objects held in a `basic_string` object is designated by
|
|
| 10 |
|
| 11 |
The member functions of `basic_string` use an object of the `Allocator`
|
| 12 |
class passed as a template parameter to allocate and free storage for
|
| 13 |
the contained char-like objects.[^2]
|
| 14 |
|
| 15 |
-
|
| 16 |
-
[[
|
| 17 |
|
| 18 |
In all cases, `size() <= capacity()`.
|
| 19 |
|
| 20 |
The functions described in this Clause can report two kinds of errors,
|
| 21 |
each associated with an exception type:
|
|
@@ -30,33 +30,39 @@ namespace std {
|
|
| 30 |
template<class charT, class traits = char_traits<charT>,
|
| 31 |
class Allocator = allocator<charT>>
|
| 32 |
class basic_string {
|
| 33 |
public:
|
| 34 |
// types:
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
typedef implementation-defined iterator; // See [container.requirements]
|
| 47 |
-
typedef implementation-defined const_iterator; // See [container.requirements]
|
| 48 |
-
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 49 |
-
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 50 |
static const size_type npos = -1;
|
| 51 |
|
| 52 |
-
// [string.cons], construct/copy/destroy
|
| 53 |
-
basic_string() : basic_string(Allocator()) { }
|
| 54 |
-
explicit basic_string(const Allocator& a);
|
| 55 |
basic_string(const basic_string& str);
|
| 56 |
basic_string(basic_string&& str) noexcept;
|
| 57 |
-
basic_string(const basic_string& str, size_type pos,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
const Allocator& a = Allocator());
|
| 59 |
basic_string(const charT* s,
|
| 60 |
size_type n, const Allocator& a = Allocator());
|
| 61 |
basic_string(const charT* s, const Allocator& a = Allocator());
|
| 62 |
basic_string(size_type n, charT c, const Allocator& a = Allocator());
|
|
@@ -67,16 +73,19 @@ namespace std {
|
|
| 67 |
basic_string(const basic_string&, const Allocator&);
|
| 68 |
basic_string(basic_string&&, const Allocator&);
|
| 69 |
|
| 70 |
~basic_string();
|
| 71 |
basic_string& operator=(const basic_string& str);
|
| 72 |
-
basic_string& operator=(basic_string&& str)
|
|
|
|
|
|
|
|
|
|
| 73 |
basic_string& operator=(const charT* s);
|
| 74 |
basic_string& operator=(charT c);
|
| 75 |
basic_string& operator=(initializer_list<charT>);
|
| 76 |
|
| 77 |
-
// [string.iterators], iterators
|
| 78 |
iterator begin() noexcept;
|
| 79 |
const_iterator begin() const noexcept;
|
| 80 |
iterator end() noexcept;
|
| 81 |
const_iterator end() const noexcept;
|
| 82 |
|
|
@@ -88,11 +97,11 @@ namespace std {
|
|
| 88 |
const_iterator cbegin() const noexcept;
|
| 89 |
const_iterator cend() const noexcept;
|
| 90 |
const_reverse_iterator crbegin() const noexcept;
|
| 91 |
const_reverse_iterator crend() const noexcept;
|
| 92 |
|
| 93 |
-
// [string.capacity], capacity
|
| 94 |
size_type size() const noexcept;
|
| 95 |
size_type length() const noexcept;
|
| 96 |
size_type max_size() const noexcept;
|
| 97 |
void resize(size_type n, charT c);
|
| 98 |
void resize(size_type n);
|
|
@@ -100,51 +109,64 @@ namespace std {
|
|
| 100 |
void reserve(size_type res_arg = 0);
|
| 101 |
void shrink_to_fit();
|
| 102 |
void clear() noexcept;
|
| 103 |
bool empty() const noexcept;
|
| 104 |
|
| 105 |
-
// [string.access], element access
|
| 106 |
const_reference operator[](size_type pos) const;
|
| 107 |
reference operator[](size_type pos);
|
| 108 |
const_reference at(size_type n) const;
|
| 109 |
reference at(size_type n);
|
| 110 |
|
| 111 |
const charT& front() const;
|
| 112 |
charT& front();
|
| 113 |
const charT& back() const;
|
| 114 |
charT& back();
|
| 115 |
|
| 116 |
-
// [string.modifiers], modifiers
|
| 117 |
basic_string& operator+=(const basic_string& str);
|
|
|
|
| 118 |
basic_string& operator+=(const charT* s);
|
| 119 |
basic_string& operator+=(charT c);
|
| 120 |
basic_string& operator+=(initializer_list<charT>);
|
| 121 |
basic_string& append(const basic_string& str);
|
| 122 |
basic_string& append(const basic_string& str, size_type pos,
|
| 123 |
size_type n = npos);
|
|
|
|
|
|
|
|
|
|
| 124 |
basic_string& append(const charT* s, size_type n);
|
| 125 |
basic_string& append(const charT* s);
|
| 126 |
basic_string& append(size_type n, charT c);
|
| 127 |
template<class InputIterator>
|
| 128 |
basic_string& append(InputIterator first, InputIterator last);
|
| 129 |
basic_string& append(initializer_list<charT>);
|
| 130 |
void push_back(charT c);
|
| 131 |
|
| 132 |
basic_string& assign(const basic_string& str);
|
| 133 |
-
basic_string& assign(basic_string&& str)
|
|
|
|
|
|
|
| 134 |
basic_string& assign(const basic_string& str, size_type pos,
|
| 135 |
size_type n = npos);
|
|
|
|
|
|
|
|
|
|
| 136 |
basic_string& assign(const charT* s, size_type n);
|
| 137 |
basic_string& assign(const charT* s);
|
| 138 |
basic_string& assign(size_type n, charT c);
|
| 139 |
template<class InputIterator>
|
| 140 |
basic_string& assign(InputIterator first, InputIterator last);
|
| 141 |
basic_string& assign(initializer_list<charT>);
|
| 142 |
|
| 143 |
-
basic_string& insert(size_type
|
| 144 |
basic_string& insert(size_type pos1, const basic_string& str,
|
| 145 |
size_type pos2, size_type n = npos);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
basic_string& insert(size_type pos, const charT* s, size_type n);
|
| 147 |
basic_string& insert(size_type pos, const charT* s);
|
| 148 |
basic_string& insert(size_type pos, size_type n, charT c);
|
| 149 |
iterator insert(const_iterator p, charT c);
|
| 150 |
iterator insert(const_iterator p, size_type n, charT c);
|
|
@@ -161,18 +183,25 @@ namespace std {
|
|
| 161 |
basic_string& replace(size_type pos1, size_type n1,
|
| 162 |
const basic_string& str);
|
| 163 |
basic_string& replace(size_type pos1, size_type n1,
|
| 164 |
const basic_string& str,
|
| 165 |
size_type pos2, size_type n2 = npos);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
basic_string& replace(size_type pos, size_type n1, const charT* s,
|
| 167 |
size_type n2);
|
| 168 |
basic_string& replace(size_type pos, size_type n1, const charT* s);
|
| 169 |
basic_string& replace(size_type pos, size_type n1, size_type n2,
|
| 170 |
charT c);
|
| 171 |
|
| 172 |
basic_string& replace(const_iterator i1, const_iterator i2,
|
| 173 |
const basic_string& str);
|
|
|
|
|
|
|
| 174 |
basic_string& replace(const_iterator i1, const_iterator i2, const charT* s,
|
| 175 |
size_type n);
|
| 176 |
basic_string& replace(const_iterator i1, const_iterator i2, const charT* s);
|
| 177 |
basic_string& replace(const_iterator i1, const_iterator i2,
|
| 178 |
size_type n, charT c);
|
|
@@ -180,54 +209,76 @@ namespace std {
|
|
| 180 |
basic_string& replace(const_iterator i1, const_iterator i2,
|
| 181 |
InputIterator j1, InputIterator j2);
|
| 182 |
basic_string& replace(const_iterator, const_iterator, initializer_list<charT>);
|
| 183 |
|
| 184 |
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
| 185 |
-
void swap(basic_string& str)
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
// [string.ops], string operations
|
| 188 |
const charT* c_str() const noexcept;
|
| 189 |
const charT* data() const noexcept;
|
|
|
|
|
|
|
| 190 |
allocator_type get_allocator() const noexcept;
|
| 191 |
|
|
|
|
|
|
|
| 192 |
size_type find (const basic_string& str, size_type pos = 0) const noexcept;
|
| 193 |
size_type find (const charT* s, size_type pos, size_type n) const;
|
| 194 |
size_type find (const charT* s, size_type pos = 0) const;
|
| 195 |
size_type find (charT c, size_type pos = 0) const;
|
|
|
|
|
|
|
| 196 |
size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
|
| 197 |
size_type rfind(const charT* s, size_type pos, size_type n) const;
|
| 198 |
size_type rfind(const charT* s, size_type pos = npos) const;
|
| 199 |
size_type rfind(charT c, size_type pos = npos) const;
|
| 200 |
|
|
|
|
|
|
|
| 201 |
size_type find_first_of(const basic_string& str,
|
| 202 |
size_type pos = 0) const noexcept;
|
| 203 |
size_type find_first_of(const charT* s,
|
| 204 |
size_type pos, size_type n) const;
|
| 205 |
size_type find_first_of(const charT* s, size_type pos = 0) const;
|
| 206 |
size_type find_first_of(charT c, size_type pos = 0) const;
|
|
|
|
|
|
|
| 207 |
size_type find_last_of (const basic_string& str,
|
| 208 |
size_type pos = npos) const noexcept;
|
| 209 |
size_type find_last_of (const charT* s,
|
| 210 |
size_type pos, size_type n) const;
|
| 211 |
size_type find_last_of (const charT* s, size_type pos = npos) const;
|
| 212 |
size_type find_last_of (charT c, size_type pos = npos) const;
|
| 213 |
|
|
|
|
|
|
|
| 214 |
size_type find_first_not_of(const basic_string& str,
|
| 215 |
size_type pos = 0) const noexcept;
|
| 216 |
size_type find_first_not_of(const charT* s, size_type pos,
|
| 217 |
size_type n) const;
|
| 218 |
size_type find_first_not_of(const charT* s, size_type pos = 0) const;
|
| 219 |
size_type find_first_not_of(charT c, size_type pos = 0) const;
|
|
|
|
|
|
|
| 220 |
size_type find_last_not_of (const basic_string& str,
|
| 221 |
size_type pos = npos) const noexcept;
|
| 222 |
size_type find_last_not_of (const charT* s, size_type pos,
|
| 223 |
size_type n) const;
|
| 224 |
size_type find_last_not_of (const charT* s,
|
| 225 |
size_type pos = npos) const;
|
| 226 |
size_type find_last_not_of (charT c, size_type pos = npos) const;
|
| 227 |
|
| 228 |
basic_string substr(size_type pos = 0, size_type n = npos) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
int compare(const basic_string& str) const noexcept;
|
| 230 |
int compare(size_type pos1, size_type n1,
|
| 231 |
const basic_string& str) const;
|
| 232 |
int compare(size_type pos1, size_type n1,
|
| 233 |
const basic_string& str,
|
|
@@ -236,14 +287,21 @@ namespace std {
|
|
| 236 |
int compare(size_type pos1, size_type n1,
|
| 237 |
const charT* s) const;
|
| 238 |
int compare(size_type pos1, size_type n1,
|
| 239 |
const charT* s, size_type n2) const;
|
| 240 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
}
|
| 242 |
```
|
| 243 |
|
| 244 |
-
### `basic_string` general requirements <a id="string.require">[[string.require]]</a>
|
| 245 |
|
| 246 |
If any operation would cause `size()` to exceed `max_size()`, that
|
| 247 |
operation shall throw an exception object of type `length_error`.
|
| 248 |
|
| 249 |
If any member function or operator of `basic_string` throws an
|
|
@@ -253,30 +311,28 @@ In every specialization `basic_string<charT, traits, Allocator>`, the
|
|
| 253 |
type `allocator_traits<Allocator>::value_type` shall name the same type
|
| 254 |
as `charT`. Every object of type
|
| 255 |
`basic_string<charT, traits, Allocator>` shall use an object of type
|
| 256 |
`Allocator` to allocate and free storage for the contained `charT`
|
| 257 |
objects as needed. The `Allocator` object used shall be obtained as
|
| 258 |
-
described in [[container.requirements.general]].
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
`&*(s.begin() + n) == &*s.begin() + n` shall hold for all values of `n`
|
| 263 |
-
such that `0 <= n < s.size()`.
|
| 264 |
|
| 265 |
References, pointers, and iterators referring to the elements of a
|
| 266 |
`basic_string` sequence may be invalidated by the following uses of that
|
| 267 |
`basic_string` object:
|
| 268 |
|
| 269 |
- as an argument to any standard library function taking a reference to
|
| 270 |
non-const `basic_string` as an argument.[^3]
|
| 271 |
-
- Calling non-const member functions, except `operator[]`, `at`,
|
| 272 |
`front`, `back`, `begin`, `rbegin`, `end`, and `rend`.
|
| 273 |
|
| 274 |
-
### `basic_string` constructors and assignment operators <a id="string.cons">[[string.cons]]</a>
|
| 275 |
|
| 276 |
``` cpp
|
| 277 |
-
explicit basic_string(const Allocator& a);
|
| 278 |
```
|
| 279 |
|
| 280 |
*Effects:* Constructs an object of class `basic_string`. The
|
| 281 |
postconditions of this function are indicated in
|
| 282 |
Table [[tab:strings.ctr.1]].
|
|
@@ -305,32 +361,65 @@ valid state with an unspecified value.
|
|
| 305 |
| `data()` | points at the first element of an allocated copy of the array whose first element is pointed at by `str.data()` |
|
| 306 |
| `size()` | `str.size()` |
|
| 307 |
| `capacity()` | a value at least as large as `size()` |
|
| 308 |
|
| 309 |
``` cpp
|
| 310 |
-
basic_string(const basic_string& str,
|
| 311 |
-
size_type pos, size_type n = npos,
|
| 312 |
const Allocator& a = Allocator());
|
| 313 |
```
|
| 314 |
|
| 315 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
|
| 317 |
*Throws:* `out_of_range` if `pos > str.size()`.
|
| 318 |
|
| 319 |
*Effects:* Constructs an object of class `basic_string` and determines
|
| 320 |
the effective length `rlen` of the initial string value as the smaller
|
| 321 |
of `n` and `str.size() - pos`, as indicated in
|
| 322 |
Table [[tab:strings.ctr.2]].
|
| 323 |
|
| 324 |
-
**Table: `basic_string(const basic_string&, size_type,
|
|
|
|
| 325 |
|
| 326 |
| Element | Value |
|
| 327 |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 328 |
| `data()` | points at the first element of an allocated copy of `rlen` consecutive elements of the string controlled by `str` beginning at position `pos` |
|
| 329 |
| `size()` | `rlen` |
|
| 330 |
| `capacity()` | a value at least as large as `size()` |
|
| 331 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
``` cpp
|
| 333 |
basic_string(const charT* s, size_type n,
|
| 334 |
const Allocator& a = Allocator());
|
| 335 |
```
|
| 336 |
|
|
@@ -367,18 +456,15 @@ indicated in Table [[tab:strings.ctr.4]].
|
|
| 367 |
| ------------ | ------------------------------------------------------------------------------------------------------ |
|
| 368 |
| `data()` | points at the first element of an allocated copy of the array whose first element is pointed at by `s` |
|
| 369 |
| `size()` | `traits::length(s)` |
|
| 370 |
| `capacity()` | a value at least as large as `size()` |
|
| 371 |
|
| 372 |
-
|
| 373 |
-
*Remarks:* Uses `traits::length()`.
|
| 374 |
-
|
| 375 |
``` cpp
|
| 376 |
basic_string(size_type n, charT c, const Allocator& a = Allocator());
|
| 377 |
```
|
| 378 |
|
| 379 |
-
*Requires:* `n < npos`
|
| 380 |
|
| 381 |
*Effects:* Constructs an object of class `basic_string` and determines
|
| 382 |
its initial string value by repeating the char-like object `c` for all
|
| 383 |
`n` elements, as indicated in Table [[tab:strings.ctr.5]].
|
| 384 |
|
|
@@ -394,14 +480,14 @@ its initial string value by repeating the char-like object `c` for all
|
|
| 394 |
template<class InputIterator>
|
| 395 |
basic_string(InputIterator begin, InputIterator end,
|
| 396 |
const Allocator& a = Allocator());
|
| 397 |
```
|
| 398 |
|
| 399 |
-
*Effects:* If `InputIterator` is an integral type, equivalent to
|
| 400 |
|
| 401 |
``` cpp
|
| 402 |
-
basic_string(static_cast<size_type>(begin), static_cast<value_type>(end), a)
|
| 403 |
```
|
| 404 |
|
| 405 |
Otherwise constructs a string from the values in the range \[`begin`,
|
| 406 |
`end`), as indicated in the Sequence Requirements table
|
| 407 |
(see [[sequence.reqmts]]).
|
|
@@ -420,11 +506,11 @@ basic_string(basic_string&& str, const Allocator& alloc);
|
|
| 420 |
*Effects:* Constructs an object of class `basic_string` as indicated in
|
| 421 |
Table [[tab:strings.ctr.6]]. The stored allocator is constructed from
|
| 422 |
`alloc`. In the second form, `str` is left in a valid state with an
|
| 423 |
unspecified value.
|
| 424 |
|
| 425 |
-
**Table: `basic_string(const basic_string&, const Allocator&)` and
|
| 426 |
`basic_string(basic_string&&, const Allocator&)` effects** <a id="tab:strings.ctr.6">[tab:strings.ctr.6]</a>
|
| 427 |
|
| 428 |
| Element | Value |
|
| 429 |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
| 430 |
| `data()` | points at the first element of an allocated copy of the array whose first element is pointed at by the original value of `str.data()`. |
|
|
@@ -434,48 +520,60 @@ unspecified value.
|
|
| 434 |
|
| 435 |
|
| 436 |
*Throws:* The second form throws nothing if
|
| 437 |
`alloc == str.get_allocator()`.
|
| 438 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
``` cpp
|
| 440 |
basic_string& operator=(const basic_string& str);
|
| 441 |
```
|
| 442 |
|
| 443 |
*Effects:* If `*this` and `str` are not the same object, modifies
|
| 444 |
`*this` as shown in Table [[tab:strings.op=]].
|
| 445 |
|
| 446 |
If `*this` and `str` are the same object, the member has no effect.
|
| 447 |
|
| 448 |
-
*Returns:* `*this`
|
| 449 |
|
| 450 |
**Table: `operator=(const basic_string&)` effects** <a id="tab:strings.op=">[tab:strings.op=]</a>
|
| 451 |
|
| 452 |
| Element | Value |
|
| 453 |
| ------------ | --------------------------------------------------------------------------------------------------------------- |
|
| 454 |
| `data()` | points at the first element of an allocated copy of the array whose first element is pointed at by `str.data()` |
|
| 455 |
| `size()` | `str.size()` |
|
| 456 |
| `capacity()` | a value at least as large as `size()` |
|
| 457 |
|
| 458 |
``` cpp
|
| 459 |
-
basic_string& operator=(basic_string&& str)
|
|
|
|
|
|
|
| 460 |
```
|
| 461 |
|
| 462 |
-
*Effects:*
|
| 463 |
-
|
| 464 |
-
|
| 465 |
|
| 466 |
-
|
| 467 |
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
|
| 472 |
-
|
| 473 |
-
| ------------ | ---------------------------------------------------------------------- |
|
| 474 |
-
| `data()` | points at the array whose first element was pointed at by `str.data()` |
|
| 475 |
-
| `size()` | previous value of `str.size()` |
|
| 476 |
-
| `capacity()` | a value at least as large as `size()` |
|
| 477 |
|
| 478 |
``` cpp
|
| 479 |
basic_string& operator=(const charT* s);
|
| 480 |
```
|
| 481 |
|
|
@@ -491,15 +589,15 @@ basic_string& operator=(charT c);
|
|
| 491 |
|
| 492 |
``` cpp
|
| 493 |
basic_string& operator=(initializer_list<charT> il);
|
| 494 |
```
|
| 495 |
|
| 496 |
-
*Effects:* `*this = basic_string(il)`
|
| 497 |
|
| 498 |
*Returns:* `*this`.
|
| 499 |
|
| 500 |
-
### `basic_string` iterator support <a id="string.iterators">[[string.iterators]]</a>
|
| 501 |
|
| 502 |
``` cpp
|
| 503 |
iterator begin() noexcept;
|
| 504 |
const_iterator begin() const noexcept;
|
| 505 |
const_iterator cbegin() const noexcept;
|
|
@@ -531,11 +629,11 @@ const_reverse_iterator crend() const noexcept;
|
|
| 531 |
```
|
| 532 |
|
| 533 |
*Returns:* An iterator which is semantically equivalent to
|
| 534 |
`reverse_iterator(begin())`.
|
| 535 |
|
| 536 |
-
### `basic_string` capacity <a id="string.capacity">[[string.capacity]]</a>
|
| 537 |
|
| 538 |
``` cpp
|
| 539 |
size_type size() const noexcept;
|
| 540 |
```
|
| 541 |
|
|
@@ -552,20 +650,19 @@ size_type length() const noexcept;
|
|
| 552 |
|
| 553 |
``` cpp
|
| 554 |
size_type max_size() const noexcept;
|
| 555 |
```
|
| 556 |
|
| 557 |
-
*Returns:* The
|
|
|
|
| 558 |
|
| 559 |
*Complexity:* Constant time.
|
| 560 |
|
| 561 |
``` cpp
|
| 562 |
void resize(size_type n, charT c);
|
| 563 |
```
|
| 564 |
|
| 565 |
-
*Requires:* `n <= max_size()`
|
| 566 |
-
|
| 567 |
*Throws:* `length_error` if `n > max_size()`.
|
| 568 |
|
| 569 |
*Effects:* Alters the length of the string designated by `*this` as
|
| 570 |
follows:
|
| 571 |
|
|
@@ -579,11 +676,11 @@ follows:
|
|
| 579 |
|
| 580 |
``` cpp
|
| 581 |
void resize(size_type n);
|
| 582 |
```
|
| 583 |
|
| 584 |
-
*Effects:* `resize(n,charT())`.
|
| 585 |
|
| 586 |
``` cpp
|
| 587 |
size_type capacity() const noexcept;
|
| 588 |
```
|
| 589 |
|
|
@@ -596,24 +693,37 @@ void reserve(size_type res_arg=0);
|
|
| 596 |
The member function `reserve()` is a directive that informs a
|
| 597 |
`basic_string` object of a planned change in size, so that it can manage
|
| 598 |
the storage allocation accordingly.
|
| 599 |
|
| 600 |
*Effects:* After `reserve()`, `capacity()` is greater or equal to the
|
| 601 |
-
argument of `reserve`.
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
request.
|
|
|
|
|
|
|
| 605 |
|
| 606 |
*Throws:* `length_error` if `res_arg > max_size()`.[^4]
|
| 607 |
|
| 608 |
``` cpp
|
| 609 |
void shrink_to_fit();
|
| 610 |
```
|
| 611 |
|
| 612 |
-
*
|
| 613 |
-
`capacity()` to `size()`.
|
| 614 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 615 |
|
| 616 |
``` cpp
|
| 617 |
void clear() noexcept;
|
| 618 |
```
|
| 619 |
|
|
@@ -627,22 +737,23 @@ erase(begin(), end());
|
|
| 627 |
bool empty() const noexcept;
|
| 628 |
```
|
| 629 |
|
| 630 |
*Returns:* `size() == 0`.
|
| 631 |
|
| 632 |
-
### `basic_string` element access <a id="string.access">[[string.access]]</a>
|
| 633 |
|
| 634 |
``` cpp
|
| 635 |
const_reference operator[](size_type pos) const;
|
| 636 |
reference operator[](size_type pos);
|
| 637 |
```
|
| 638 |
|
| 639 |
*Requires:* `pos <= size()`.
|
| 640 |
|
| 641 |
*Returns:* `*(begin() + pos)` if `pos < size()`. Otherwise, returns a
|
| 642 |
reference to an object of type `charT` with value `charT()`, where
|
| 643 |
-
modifying the object
|
|
|
|
| 644 |
|
| 645 |
*Throws:* Nothing.
|
| 646 |
|
| 647 |
*Complexity:* Constant time.
|
| 648 |
|
|
@@ -658,36 +769,44 @@ reference at(size_type pos);
|
|
| 658 |
``` cpp
|
| 659 |
const charT& front() const;
|
| 660 |
charT& front();
|
| 661 |
```
|
| 662 |
|
| 663 |
-
*Requires:* `!empty()`
|
| 664 |
|
| 665 |
-
*Effects:* Equivalent to `operator[](0)`
|
| 666 |
|
| 667 |
``` cpp
|
| 668 |
const charT& back() const;
|
| 669 |
charT& back();
|
| 670 |
```
|
| 671 |
|
| 672 |
-
*Requires:* `!empty()`
|
| 673 |
|
| 674 |
-
*Effects:* Equivalent to `operator[](size() - 1)`
|
| 675 |
|
| 676 |
-
### `basic_string` modifiers <a id="string.modifiers">[[string.modifiers]]</a>
|
| 677 |
|
| 678 |
-
#### `basic_string::operator+=` <a id="string
|
| 679 |
|
| 680 |
``` cpp
|
| 681 |
basic_string&
|
| 682 |
operator+=(const basic_string& str);
|
| 683 |
```
|
| 684 |
|
| 685 |
*Effects:* Calls `append(str)`.
|
| 686 |
|
| 687 |
*Returns:* `*this`.
|
| 688 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 689 |
``` cpp
|
| 690 |
basic_string& operator+=(const charT* s);
|
| 691 |
```
|
| 692 |
|
| 693 |
*Effects:* Calls `append(s)`.
|
|
@@ -708,11 +827,11 @@ basic_string& operator+=(initializer_list<charT> il);
|
|
| 708 |
|
| 709 |
*Effects:* Calls `append(il)`.
|
| 710 |
|
| 711 |
*Returns:* `*this`.
|
| 712 |
|
| 713 |
-
#### `basic_string::append` <a id="string
|
| 714 |
|
| 715 |
``` cpp
|
| 716 |
basic_string&
|
| 717 |
append(const basic_string& str);
|
| 718 |
```
|
|
@@ -724,20 +843,42 @@ basic_string&
|
|
| 724 |
``` cpp
|
| 725 |
basic_string&
|
| 726 |
append(const basic_string& str, size_type pos, size_type n = npos);
|
| 727 |
```
|
| 728 |
|
| 729 |
-
*Requires:* `pos <= str.size()`
|
| 730 |
-
|
| 731 |
*Throws:* `out_of_range` if `pos > str.size()`.
|
| 732 |
|
| 733 |
*Effects:* Determines the effective length `rlen` of the string to
|
| 734 |
append as the smaller of `n` and `str``.size() - ``pos` and calls
|
| 735 |
`append(str.data() + pos, rlen)`.
|
| 736 |
|
| 737 |
*Returns:* `*this`.
|
| 738 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 739 |
``` cpp
|
| 740 |
basic_string&
|
| 741 |
append(const charT* s, size_type n);
|
| 742 |
```
|
| 743 |
|
|
@@ -776,11 +917,12 @@ template<class InputIterator>
|
|
| 776 |
basic_string& append(InputIterator first, InputIterator last);
|
| 777 |
```
|
| 778 |
|
| 779 |
*Requires:* \[`first`, `last`) is a valid range.
|
| 780 |
|
| 781 |
-
*Effects:* Equivalent to
|
|
|
|
| 782 |
|
| 783 |
*Returns:* `*this`.
|
| 784 |
|
| 785 |
``` cpp
|
| 786 |
basic_string& append(initializer_list<charT> il);
|
|
@@ -794,43 +936,65 @@ basic_string& append(initializer_list<charT> il);
|
|
| 794 |
void push_back(charT c);
|
| 795 |
```
|
| 796 |
|
| 797 |
*Effects:* Equivalent to `append(static_cast<size_type>(1), c)`.
|
| 798 |
|
| 799 |
-
#### `basic_string::assign` <a id="string
|
| 800 |
|
| 801 |
``` cpp
|
| 802 |
basic_string& assign(const basic_string& str);
|
| 803 |
```
|
| 804 |
|
| 805 |
-
*Effects:* Equivalent to `
|
| 806 |
|
| 807 |
*Returns:* `*this`.
|
| 808 |
|
| 809 |
``` cpp
|
| 810 |
-
basic_string& assign(basic_string&& str)
|
|
|
|
|
|
|
| 811 |
```
|
| 812 |
|
| 813 |
-
*Effects:*
|
| 814 |
-
string of length `str.size()` whose elements are a copy of the string
|
| 815 |
-
controlled by `str`. A valid implementation is `swap(str)`.
|
| 816 |
|
| 817 |
*Returns:* `*this`.
|
| 818 |
|
| 819 |
``` cpp
|
| 820 |
basic_string&
|
| 821 |
assign(const basic_string& str, size_type pos,
|
| 822 |
size_type n = npos);
|
| 823 |
```
|
| 824 |
|
| 825 |
-
*Requires:* `pos <= str.size()`
|
| 826 |
-
|
| 827 |
*Throws:* `out_of_range` if `pos > str.size()`.
|
| 828 |
|
| 829 |
*Effects:* Determines the effective length `rlen` of the string to
|
| 830 |
assign as the smaller of `n` and `str``.size() - ``pos` and calls
|
| 831 |
-
`assign(str.data() + pos rlen)`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 832 |
|
| 833 |
*Returns:* `*this`.
|
| 834 |
|
| 835 |
``` cpp
|
| 836 |
basic_string& assign(const charT* s, size_type n);
|
|
@@ -875,54 +1039,71 @@ basic_string& assign(size_type n, charT c);
|
|
| 875 |
``` cpp
|
| 876 |
template<class InputIterator>
|
| 877 |
basic_string& assign(InputIterator first, InputIterator last);
|
| 878 |
```
|
| 879 |
|
| 880 |
-
*Effects:* Equivalent to
|
|
|
|
| 881 |
|
| 882 |
*Returns:* `*this`.
|
| 883 |
|
| 884 |
-
#### `basic_string::insert` <a id="string
|
| 885 |
|
| 886 |
``` cpp
|
| 887 |
basic_string&
|
| 888 |
-
insert(size_type
|
| 889 |
const basic_string& str);
|
| 890 |
```
|
| 891 |
|
| 892 |
-
*
|
| 893 |
-
|
| 894 |
-
*Throws:* `out_of_range` if `pos > size()`.
|
| 895 |
-
|
| 896 |
-
*Effects:* Calls `insert(pos, str.data(), str.size())`.
|
| 897 |
-
|
| 898 |
-
*Returns:* `*this`.
|
| 899 |
|
| 900 |
``` cpp
|
| 901 |
basic_string&
|
| 902 |
insert(size_type pos1,
|
| 903 |
const basic_string& str,
|
| 904 |
size_type pos2, size_type n = npos);
|
| 905 |
```
|
| 906 |
|
| 907 |
-
*Requires:* `pos1 <= size()` and `pos2 <= str.size()`
|
| 908 |
-
|
| 909 |
*Throws:* `out_of_range` if `pos1 > size()` or `pos2 > str.size()`.
|
| 910 |
|
| 911 |
*Effects:* Determines the effective length `rlen` of the string to
|
| 912 |
insert as the smaller of `n` and `str.size() - pos2` and calls
|
| 913 |
`insert(pos1, str.data() + pos2, rlen)`.
|
| 914 |
|
| 915 |
*Returns:* `*this`.
|
| 916 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 917 |
``` cpp
|
| 918 |
basic_string&
|
| 919 |
insert(size_type pos, const charT* s, size_type n);
|
| 920 |
```
|
| 921 |
|
| 922 |
-
*Requires:* `s` points to an array of at least `n` elements of `charT`
|
| 923 |
-
and `pos <= size()`.
|
| 924 |
|
| 925 |
*Throws:* `out_of_range` if `pos > size()` or `length_error` if
|
| 926 |
`size() + n > max_size()`.
|
| 927 |
|
| 928 |
*Effects:* Replaces the string controlled by `*this` with a string of
|
|
@@ -937,16 +1118,14 @@ by `*this`.
|
|
| 937 |
``` cpp
|
| 938 |
basic_string&
|
| 939 |
insert(size_type pos, const charT* s);
|
| 940 |
```
|
| 941 |
|
| 942 |
-
*Requires:* `
|
| 943 |
-
|
| 944 |
|
| 945 |
-
*Effects:* Equivalent to `insert(pos, s, traits::length(s))`
|
| 946 |
-
|
| 947 |
-
*Returns:* `*this`.
|
| 948 |
|
| 949 |
``` cpp
|
| 950 |
basic_string&
|
| 951 |
insert(size_type pos, size_type n, charT c);
|
| 952 |
```
|
|
@@ -959,11 +1138,11 @@ basic_string&
|
|
| 959 |
iterator insert(const_iterator p, charT c);
|
| 960 |
```
|
| 961 |
|
| 962 |
*Requires:* `p` is a valid iterator on `*this`.
|
| 963 |
|
| 964 |
-
*Effects:*
|
| 965 |
`p`.
|
| 966 |
|
| 967 |
*Returns:* An iterator which refers to the copy of the inserted
|
| 968 |
character.
|
| 969 |
|
|
@@ -971,11 +1150,11 @@ character.
|
|
| 971 |
iterator insert(const_iterator p, size_type n, charT c);
|
| 972 |
```
|
| 973 |
|
| 974 |
*Requires:* `p` is a valid iterator on `*this`.
|
| 975 |
|
| 976 |
-
*Effects:*
|
| 977 |
`p`.
|
| 978 |
|
| 979 |
*Returns:* An iterator which refers to the copy of the first inserted
|
| 980 |
character, or `p` if `n == 0`.
|
| 981 |
|
|
@@ -986,32 +1165,30 @@ template<class InputIterator>
|
|
| 986 |
|
| 987 |
*Requires:* `p` is a valid iterator on `*this`. `[first, last)` is a
|
| 988 |
valid range.
|
| 989 |
|
| 990 |
*Effects:* Equivalent to
|
| 991 |
-
`insert(p - begin(), basic_string(first, last))`.
|
| 992 |
|
| 993 |
*Returns:* An iterator which refers to the copy of the first inserted
|
| 994 |
character, or `p` if `first == last`.
|
| 995 |
|
| 996 |
``` cpp
|
| 997 |
iterator insert(const_iterator p, initializer_list<charT> il);
|
| 998 |
```
|
| 999 |
|
| 1000 |
-
*Effects:* `insert(p, il.begin(), il.end())`.
|
| 1001 |
|
| 1002 |
*Returns:* An iterator which refers to the copy of the first inserted
|
| 1003 |
character, or `p` if `i1` is empty.
|
| 1004 |
|
| 1005 |
-
#### `basic_string::erase` <a id="string
|
| 1006 |
|
| 1007 |
``` cpp
|
| 1008 |
basic_string& erase(size_type pos = 0, size_type n = npos);
|
| 1009 |
```
|
| 1010 |
|
| 1011 |
-
*Requires:* `pos` ` <= size()`
|
| 1012 |
-
|
| 1013 |
*Throws:* `out_of_range` if `pos` `> size()`.
|
| 1014 |
|
| 1015 |
*Effects:* Determines the effective length `xlen` of the string to be
|
| 1016 |
removed as the smaller of `n` and `size() - pos`.
|
| 1017 |
|
|
@@ -1027,11 +1204,11 @@ string controlled by `*this` beginning at position `pos + xlen`.
|
|
| 1027 |
iterator erase(const_iterator p);
|
| 1028 |
```
|
| 1029 |
|
| 1030 |
*Throws:* Nothing.
|
| 1031 |
|
| 1032 |
-
*Effects:*
|
| 1033 |
|
| 1034 |
*Returns:* An iterator which points to the element immediately following
|
| 1035 |
`p` prior to the element being erased. If no such element exists,
|
| 1036 |
`end()` is returned.
|
| 1037 |
|
|
@@ -1042,66 +1219,86 @@ iterator erase(const_iterator first, const_iterator last);
|
|
| 1042 |
*Requires:* `first` and `last` are valid iterators on `*this`, defining
|
| 1043 |
a range `[first, last)`.
|
| 1044 |
|
| 1045 |
*Throws:* Nothing.
|
| 1046 |
|
| 1047 |
-
*Effects:*
|
| 1048 |
|
| 1049 |
*Returns:* An iterator which points to the element pointed to by `last`
|
| 1050 |
prior to the other elements being erased. If no such element exists,
|
| 1051 |
`end()` is returned.
|
| 1052 |
|
| 1053 |
``` cpp
|
| 1054 |
void pop_back();
|
| 1055 |
```
|
| 1056 |
|
| 1057 |
-
*Requires:* `!empty()`
|
| 1058 |
|
| 1059 |
*Throws:* Nothing.
|
| 1060 |
|
| 1061 |
*Effects:* Equivalent to `erase(size() - 1, 1)`.
|
| 1062 |
|
| 1063 |
-
#### `basic_string::replace` <a id="string
|
| 1064 |
|
| 1065 |
``` cpp
|
| 1066 |
basic_string&
|
| 1067 |
replace(size_type pos1, size_type n1,
|
| 1068 |
const basic_string& str);
|
| 1069 |
```
|
| 1070 |
|
| 1071 |
-
*
|
| 1072 |
-
|
| 1073 |
-
*Throws:* `out_of_range` if `pos1 > size()`.
|
| 1074 |
-
|
| 1075 |
-
*Effects:* Calls `replace(pos1, n1, str.data(), str.size())`.
|
| 1076 |
-
|
| 1077 |
-
*Returns:* `*this`.
|
| 1078 |
|
| 1079 |
``` cpp
|
| 1080 |
basic_string&
|
| 1081 |
replace(size_type pos1, size_type n1,
|
| 1082 |
const basic_string& str,
|
| 1083 |
size_type pos2, size_type n2 = npos);
|
| 1084 |
```
|
| 1085 |
|
| 1086 |
-
*Requires:* `pos1 <= size()` and `pos2 <= str.size()`.
|
| 1087 |
-
|
| 1088 |
*Throws:* `out_of_range` if `pos1 > size()` or `pos2 > str.size()`.
|
| 1089 |
|
| 1090 |
*Effects:* Determines the effective length `rlen` of the string to be
|
| 1091 |
inserted as the smaller of `n2` and `str.size() - pos2` and calls
|
| 1092 |
`replace(pos1, n1, str.data() + pos2, rlen)`.
|
| 1093 |
|
| 1094 |
*Returns:* `*this`.
|
| 1095 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1096 |
``` cpp
|
| 1097 |
basic_string&
|
| 1098 |
replace(size_type pos1, size_type n1, const charT* s, size_type n2);
|
| 1099 |
```
|
| 1100 |
|
| 1101 |
-
*Requires:* `
|
| 1102 |
-
elements of `charT`.
|
| 1103 |
|
| 1104 |
*Throws:* `out_of_range` if `pos1 > size()` or `length_error` if the
|
| 1105 |
length of the resulting string would exceed `max_size()` (see below).
|
| 1106 |
|
| 1107 |
*Effects:* Determines the effective length `xlen` of the string to be
|
|
@@ -1119,16 +1316,15 @@ string controlled by `*this` beginning at position `pos + xlen`.
|
|
| 1119 |
``` cpp
|
| 1120 |
basic_string&
|
| 1121 |
replace(size_type pos, size_type n, const charT* s);
|
| 1122 |
```
|
| 1123 |
|
| 1124 |
-
*Requires:* `
|
| 1125 |
-
|
| 1126 |
|
| 1127 |
-
*Effects:*
|
| 1128 |
-
|
| 1129 |
-
*Returns:* `*this`.
|
| 1130 |
|
| 1131 |
``` cpp
|
| 1132 |
basic_string&
|
| 1133 |
replace(size_type pos1, size_type n1,
|
| 1134 |
size_type n2, charT c);
|
|
@@ -1146,10 +1342,21 @@ basic_string& replace(const_iterator i1, const_iterator i2, const basic_string&
|
|
| 1146 |
|
| 1147 |
*Effects:* Calls `replace(i1 - begin(), i2 - i1, str)`.
|
| 1148 |
|
| 1149 |
*Returns:* `*this`.
|
| 1150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1151 |
``` cpp
|
| 1152 |
basic_string&
|
| 1153 |
replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
|
| 1154 |
```
|
| 1155 |
|
|
@@ -1190,11 +1397,12 @@ template<class InputIterator>
|
|
| 1190 |
```
|
| 1191 |
|
| 1192 |
*Requires:* \[`begin()`, `i1`), \[`i1`, `i2`) and \[`j1`, `j2`) are
|
| 1193 |
valid ranges.
|
| 1194 |
|
| 1195 |
-
*Effects:* Calls
|
|
|
|
| 1196 |
|
| 1197 |
*Returns:* `*this`.
|
| 1198 |
|
| 1199 |
``` cpp
|
| 1200 |
basic_string& replace(const_iterator i1, const_iterator i2,
|
|
@@ -1206,49 +1414,48 @@ basic_string& replace(const_iterator i1, const_iterator i2,
|
|
| 1206 |
*Effects:* Calls
|
| 1207 |
`replace(i1 - begin(), i2 - i1, il.begin(), il.size())`.
|
| 1208 |
|
| 1209 |
*Returns:* `*this`.
|
| 1210 |
|
| 1211 |
-
#### `basic_string::copy` <a id="string
|
| 1212 |
|
| 1213 |
``` cpp
|
| 1214 |
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
| 1215 |
```
|
| 1216 |
|
| 1217 |
-
|
| 1218 |
|
| 1219 |
*Throws:* `out_of_range` if `pos > size()`.
|
| 1220 |
|
| 1221 |
-
*
|
| 1222 |
-
as the smaller of `n` and `size() - pos`. `s` shall designate an array
|
| 1223 |
-
of at least `rlen` elements.
|
| 1224 |
|
| 1225 |
-
|
| 1226 |
-
length `rlen` whose elements are a copy of the string controlled by
|
| 1227 |
-
`*this` beginning at position `pos`.
|
| 1228 |
|
| 1229 |
-
|
| 1230 |
-
|
| 1231 |
|
| 1232 |
*Returns:* `rlen`.
|
| 1233 |
|
| 1234 |
-
#### `basic_string::swap` <a id="string
|
| 1235 |
|
| 1236 |
``` cpp
|
| 1237 |
-
void swap(basic_string& s)
|
|
|
|
|
|
|
| 1238 |
```
|
| 1239 |
|
| 1240 |
-
`*this` contains the same sequence of characters that
|
| 1241 |
-
contains the same sequence of characters that was in
|
|
|
|
| 1242 |
|
| 1243 |
*Throws:* Nothing.
|
| 1244 |
|
| 1245 |
*Complexity:* Constant time.
|
| 1246 |
|
| 1247 |
-
### `basic_string` string operations <a id="string.ops">[[string.ops]]</a>
|
| 1248 |
|
| 1249 |
-
#### `basic_string` accessors <a id="string.accessors">[[string.accessors]]</a>
|
| 1250 |
|
| 1251 |
``` cpp
|
| 1252 |
const charT* c_str() const noexcept;
|
| 1253 |
const charT* data() const noexcept;
|
| 1254 |
```
|
|
@@ -1259,726 +1466,415 @@ const charT* data() const noexcept;
|
|
| 1259 |
*Complexity:* Constant time.
|
| 1260 |
|
| 1261 |
*Requires:* The program shall not alter any of the values stored in the
|
| 1262 |
character array.
|
| 1263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1264 |
``` cpp
|
| 1265 |
allocator_type get_allocator() const noexcept;
|
| 1266 |
```
|
| 1267 |
|
| 1268 |
*Returns:* A copy of the `Allocator` object used to construct the string
|
| 1269 |
or, if that allocator has been replaced, a copy of the most recent
|
| 1270 |
replacement.
|
| 1271 |
|
| 1272 |
-
#### `basic_string::find` <a id="string
|
| 1273 |
|
| 1274 |
``` cpp
|
| 1275 |
-
size_type find(
|
| 1276 |
-
size_type pos = 0) const noexcept;
|
| 1277 |
```
|
| 1278 |
|
| 1279 |
*Effects:* Determines the lowest position `xpos`, if possible, such that
|
| 1280 |
-
both of the following conditions
|
| 1281 |
|
| 1282 |
-
- `pos <= xpos` and `xpos +
|
| 1283 |
-
- `traits::eq(at(xpos+I),
|
| 1284 |
-
|
| 1285 |
|
| 1286 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1287 |
Otherwise, returns `npos`.
|
| 1288 |
|
| 1289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1290 |
|
| 1291 |
``` cpp
|
| 1292 |
size_type find(const charT* s, size_type pos, size_type n) const;
|
| 1293 |
```
|
| 1294 |
|
| 1295 |
-
*Returns:* `find(
|
| 1296 |
|
| 1297 |
``` cpp
|
| 1298 |
size_type find(const charT* s, size_type pos = 0) const;
|
| 1299 |
```
|
| 1300 |
|
| 1301 |
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1302 |
elements of `charT`.
|
| 1303 |
|
| 1304 |
-
*Returns:* `find(
|
| 1305 |
|
| 1306 |
``` cpp
|
| 1307 |
size_type find(charT c, size_type pos = 0) const;
|
| 1308 |
```
|
| 1309 |
|
| 1310 |
*Returns:* `find(basic_string(1, c), pos)`.
|
| 1311 |
|
| 1312 |
-
#### `basic_string::rfind` <a id="string
|
| 1313 |
|
| 1314 |
``` cpp
|
| 1315 |
-
size_type rfind(
|
| 1316 |
-
size_type pos = npos) const noexcept;
|
| 1317 |
```
|
| 1318 |
|
| 1319 |
*Effects:* Determines the highest position `xpos`, if possible, such
|
| 1320 |
-
that both of the following conditions
|
| 1321 |
|
| 1322 |
-
- `xpos <= pos` and `xpos +
|
| 1323 |
-
- `traits::eq(at(xpos+I),
|
| 1324 |
-
|
| 1325 |
|
| 1326 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1327 |
Otherwise, returns `npos`.
|
| 1328 |
|
| 1329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1330 |
|
| 1331 |
``` cpp
|
| 1332 |
size_type rfind(const charT* s, size_type pos, size_type n) const;
|
| 1333 |
```
|
| 1334 |
|
| 1335 |
-
*Returns:* `rfind(
|
| 1336 |
|
| 1337 |
``` cpp
|
| 1338 |
size_type rfind(const charT* s, size_type pos = npos) const;
|
| 1339 |
```
|
| 1340 |
|
| 1341 |
-
*Requires:* s points to an array of at least `traits::length(s) + 1`
|
| 1342 |
elements of `charT`.
|
| 1343 |
|
| 1344 |
-
*Returns:* `rfind(
|
| 1345 |
|
| 1346 |
``` cpp
|
| 1347 |
size_type rfind(charT c, size_type pos = npos) const;
|
| 1348 |
```
|
| 1349 |
|
| 1350 |
*Returns:* `rfind(basic_string(1, c), pos)`.
|
| 1351 |
|
| 1352 |
-
#### `basic_string::find_first_of` <a id="string
|
| 1353 |
|
| 1354 |
``` cpp
|
| 1355 |
-
size_type
|
| 1356 |
-
find_first_of(const basic_string& str,
|
| 1357 |
-
size_type pos = 0) const noexcept;
|
| 1358 |
```
|
| 1359 |
|
| 1360 |
*Effects:* Determines the lowest position `xpos`, if possible, such that
|
| 1361 |
-
both of the following conditions
|
| 1362 |
|
| 1363 |
- `pos <= xpos` and `xpos < size()`;
|
| 1364 |
-
- `traits::eq(at(xpos),
|
| 1365 |
-
|
| 1366 |
|
| 1367 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1368 |
Otherwise, returns `npos`.
|
| 1369 |
|
| 1370 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1371 |
|
| 1372 |
``` cpp
|
| 1373 |
-
size_type
|
| 1374 |
-
find_first_of(const charT* s, size_type pos, size_type n) const;
|
| 1375 |
```
|
| 1376 |
|
| 1377 |
-
*Returns:* `find_first_of(
|
| 1378 |
|
| 1379 |
``` cpp
|
| 1380 |
size_type find_first_of(const charT* s, size_type pos = 0) const;
|
| 1381 |
```
|
| 1382 |
|
| 1383 |
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1384 |
elements of `charT`.
|
| 1385 |
|
| 1386 |
-
*Returns:* `find_first_of(
|
| 1387 |
|
| 1388 |
``` cpp
|
| 1389 |
size_type find_first_of(charT c, size_type pos = 0) const;
|
| 1390 |
```
|
| 1391 |
|
| 1392 |
*Returns:* `find_first_of(basic_string(1, c), pos)`.
|
| 1393 |
|
| 1394 |
-
#### `basic_string::find_last_of` <a id="string
|
| 1395 |
|
| 1396 |
``` cpp
|
| 1397 |
-
size_type
|
| 1398 |
-
find_last_of(const basic_string& str,
|
| 1399 |
-
size_type pos = npos) const noexcept;
|
| 1400 |
```
|
| 1401 |
|
| 1402 |
*Effects:* Determines the highest position `xpos`, if possible, such
|
| 1403 |
-
that both of the following conditions
|
| 1404 |
|
| 1405 |
- `xpos <= pos` and `xpos < size()`;
|
| 1406 |
-
- `traits::eq(at(xpos),
|
| 1407 |
-
|
| 1408 |
|
| 1409 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1410 |
Otherwise, returns `npos`.
|
| 1411 |
|
| 1412 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1413 |
|
| 1414 |
``` cpp
|
| 1415 |
size_type find_last_of(const charT* s, size_type pos, size_type n) const;
|
| 1416 |
```
|
| 1417 |
|
| 1418 |
-
*Returns:* `find_last_of(
|
| 1419 |
|
| 1420 |
``` cpp
|
| 1421 |
size_type find_last_of(const charT* s, size_type pos = npos) const;
|
| 1422 |
```
|
| 1423 |
|
| 1424 |
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1425 |
elements of `charT`.
|
| 1426 |
|
| 1427 |
-
*Returns:* `find_last_of(
|
| 1428 |
|
| 1429 |
``` cpp
|
| 1430 |
size_type find_last_of(charT c, size_type pos = npos) const;
|
| 1431 |
```
|
| 1432 |
|
| 1433 |
*Returns:* `find_last_of(basic_string(1, c), pos)`.
|
| 1434 |
|
| 1435 |
-
#### `basic_string::find_first_not_of` <a id="string
|
| 1436 |
|
| 1437 |
``` cpp
|
| 1438 |
-
size_type
|
| 1439 |
-
find_first_not_of(const basic_string& str,
|
| 1440 |
size_type pos = 0) const noexcept;
|
| 1441 |
```
|
| 1442 |
|
| 1443 |
*Effects:* Determines the lowest position `xpos`, if possible, such that
|
| 1444 |
-
both of the following conditions
|
| 1445 |
|
| 1446 |
- `pos <= xpos` and `xpos < size()`;
|
| 1447 |
-
- `traits::eq(at(xpos),
|
| 1448 |
-
|
| 1449 |
|
| 1450 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1451 |
Otherwise, returns `npos`.
|
| 1452 |
|
| 1453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1454 |
|
| 1455 |
``` cpp
|
| 1456 |
-
size_type
|
| 1457 |
-
find_first_not_of(const charT* s, size_type pos, size_type n) const;
|
| 1458 |
```
|
| 1459 |
|
| 1460 |
-
*Returns:*
|
|
|
|
| 1461 |
|
| 1462 |
``` cpp
|
| 1463 |
size_type find_first_not_of(const charT* s, size_type pos = 0) const;
|
| 1464 |
```
|
| 1465 |
|
| 1466 |
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1467 |
elements of `charT`.
|
| 1468 |
|
| 1469 |
-
*Returns:*
|
|
|
|
| 1470 |
|
| 1471 |
``` cpp
|
| 1472 |
size_type find_first_not_of(charT c, size_type pos = 0) const;
|
| 1473 |
```
|
| 1474 |
|
| 1475 |
*Returns:* `find_first_not_of(basic_string(1, c), pos)`.
|
| 1476 |
|
| 1477 |
-
#### `basic_string::find_last_not_of` <a id="string
|
| 1478 |
|
| 1479 |
``` cpp
|
| 1480 |
-
size_type
|
| 1481 |
-
find_last_not_of(const basic_string& str,
|
| 1482 |
size_type pos = npos) const noexcept;
|
| 1483 |
```
|
| 1484 |
|
| 1485 |
*Effects:* Determines the highest position `xpos`, if possible, such
|
| 1486 |
-
that both of the following conditions
|
| 1487 |
|
| 1488 |
- `xpos <= pos` and `xpos < size()`;
|
| 1489 |
-
- `traits::eq(at(xpos),
|
| 1490 |
-
|
| 1491 |
|
| 1492 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1493 |
Otherwise, returns `npos`.
|
| 1494 |
|
| 1495 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1496 |
|
| 1497 |
``` cpp
|
| 1498 |
-
size_type find_last_not_of(const charT* s, size_type pos,
|
| 1499 |
-
size_type n) const;
|
| 1500 |
```
|
| 1501 |
|
| 1502 |
-
*Returns:*
|
|
|
|
| 1503 |
|
| 1504 |
``` cpp
|
| 1505 |
size_type find_last_not_of(const charT* s, size_type pos = npos) const;
|
| 1506 |
```
|
| 1507 |
|
| 1508 |
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1509 |
elements of `charT`.
|
| 1510 |
|
| 1511 |
-
*Returns:* `find_last_not_of(
|
| 1512 |
|
| 1513 |
``` cpp
|
| 1514 |
size_type find_last_not_of(charT c, size_type pos = npos) const;
|
| 1515 |
```
|
| 1516 |
|
| 1517 |
*Returns:* `find_last_not_of(basic_string(1, c), pos)`.
|
| 1518 |
|
| 1519 |
-
#### `basic_string::substr` <a id="string
|
| 1520 |
|
| 1521 |
``` cpp
|
| 1522 |
basic_string substr(size_type pos = 0, size_type n = npos) const;
|
| 1523 |
```
|
| 1524 |
|
| 1525 |
-
*Requires:* `pos <= size()`
|
| 1526 |
-
|
| 1527 |
*Throws:* `out_of_range` if `pos > size()`.
|
| 1528 |
|
| 1529 |
*Effects:* Determines the effective length `rlen` of the string to copy
|
| 1530 |
as the smaller of `n` and `size() - pos`.
|
| 1531 |
|
| 1532 |
*Returns:* `basic_string(data()+pos, rlen)`.
|
| 1533 |
|
| 1534 |
-
#### `basic_string::compare` <a id="string
|
| 1535 |
|
| 1536 |
``` cpp
|
| 1537 |
-
int compare(
|
| 1538 |
```
|
| 1539 |
|
| 1540 |
-
*Effects:* Determines the effective length
|
| 1541 |
-
compare as the
|
| 1542 |
compares the two strings by calling
|
| 1543 |
-
`traits::compare(data(),
|
| 1544 |
|
| 1545 |
*Returns:* The nonzero result if the result of the comparison is
|
| 1546 |
nonzero. Otherwise, returns a value as indicated in
|
| 1547 |
Table [[tab:strings.compare]].
|
| 1548 |
|
| 1549 |
**Table: `compare()` results** <a id="tab:strings.compare">[tab:strings.compare]</a>
|
| 1550 |
|
| 1551 |
| Condition | Return Value |
|
| 1552 |
-
| ---------------------
|
| 1553 |
-
| `size() <
|
| 1554 |
-
| `size() ==
|
| 1555 |
-
| `size() >
|
| 1556 |
|
| 1557 |
``` cpp
|
| 1558 |
-
int compare(size_type pos1, size_type n1,
|
| 1559 |
-
const basic_string& str) const;
|
| 1560 |
```
|
| 1561 |
|
| 1562 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1563 |
|
| 1564 |
``` cpp
|
| 1565 |
int compare(size_type pos1, size_type n1,
|
| 1566 |
const basic_string& str,
|
| 1567 |
size_type pos2, size_type n2 = npos) const;
|
| 1568 |
```
|
| 1569 |
|
| 1570 |
-
*
|
| 1571 |
-
|
|
|
|
|
|
|
|
|
|
| 1572 |
|
| 1573 |
``` cpp
|
| 1574 |
int compare(const charT* s) const;
|
| 1575 |
```
|
| 1576 |
|
| 1577 |
*Returns:* `compare(basic_string(s))`.
|
| 1578 |
|
| 1579 |
``` cpp
|
| 1580 |
-
int compare(size_type pos, size_type n1,
|
| 1581 |
-
const charT* s) const;
|
| 1582 |
```
|
| 1583 |
|
| 1584 |
*Returns:* `basic_string(*this, pos, n1).compare(basic_string(s))`.
|
| 1585 |
|
| 1586 |
``` cpp
|
| 1587 |
-
int compare(size_type pos, size_type n1,
|
| 1588 |
-
const charT* s, size_type n2) const;
|
| 1589 |
```
|
| 1590 |
|
| 1591 |
*Returns:* `basic_string(*this, pos, n1).compare(basic_string(s, n2))`.
|
| 1592 |
|
| 1593 |
-
### `basic_string` non-member functions <a id="string.nonmembers">[[string.nonmembers]]</a>
|
| 1594 |
-
|
| 1595 |
-
#### `operator+` <a id="string::op+">[[string::op+]]</a>
|
| 1596 |
-
|
| 1597 |
-
``` cpp
|
| 1598 |
-
template<class charT, class traits, class Allocator>
|
| 1599 |
-
basic_string<charT,traits,Allocator>
|
| 1600 |
-
operator+(const basic_string<charT,traits,Allocator>& lhs,
|
| 1601 |
-
const basic_string<charT,traits,Allocator>& rhs);
|
| 1602 |
-
```
|
| 1603 |
-
|
| 1604 |
-
*Returns:* `basic_string<charT,traits,Allocator>(lhs).append(rhs)`
|
| 1605 |
-
|
| 1606 |
-
``` cpp
|
| 1607 |
-
template<class charT, class traits, class Allocator>
|
| 1608 |
-
basic_string<charT,traits,Allocator>
|
| 1609 |
-
operator+(basic_string<charT,traits,Allocator>&& lhs,
|
| 1610 |
-
const basic_string<charT,traits,Allocator>& rhs);
|
| 1611 |
-
```
|
| 1612 |
-
|
| 1613 |
-
*Returns:* `std::move(lhs.append(rhs))`
|
| 1614 |
-
|
| 1615 |
-
``` cpp
|
| 1616 |
-
template<class charT, class traits, class Allocator>
|
| 1617 |
-
basic_string<charT,traits,Allocator>
|
| 1618 |
-
operator+(const basic_string<charT,traits,Allocator>& lhs,
|
| 1619 |
-
basic_string<charT,traits,Allocator>&& rhs);
|
| 1620 |
-
```
|
| 1621 |
-
|
| 1622 |
-
*Returns:* `std::move(rhs.insert(0, lhs))`
|
| 1623 |
-
|
| 1624 |
-
``` cpp
|
| 1625 |
-
template<class charT, class traits, class Allocator>
|
| 1626 |
-
basic_string<charT,traits,Allocator>
|
| 1627 |
-
operator+(basic_string<charT,traits,Allocator>&& lhs,
|
| 1628 |
-
basic_string<charT,traits,Allocator>&& rhs);
|
| 1629 |
-
```
|
| 1630 |
-
|
| 1631 |
-
*Returns:* `std::move(lhs.append(rhs))` Or equivalently
|
| 1632 |
-
`std::move(rhs.insert(0, lhs))`
|
| 1633 |
-
|
| 1634 |
-
``` cpp
|
| 1635 |
-
template<class charT, class traits, class Allocator>
|
| 1636 |
-
basic_string<charT,traits,Allocator>
|
| 1637 |
-
operator+(const charT* lhs,
|
| 1638 |
-
const basic_string<charT,traits,Allocator>& rhs);
|
| 1639 |
-
```
|
| 1640 |
-
|
| 1641 |
-
*Returns:* `basic_string<charT,traits,Allocator>(lhs) + rhs`.
|
| 1642 |
-
|
| 1643 |
-
*Remarks:* Uses `traits::length()`.
|
| 1644 |
-
|
| 1645 |
-
``` cpp
|
| 1646 |
-
template<class charT, class traits, class Allocator>
|
| 1647 |
-
basic_string<charT,traits,Allocator>
|
| 1648 |
-
operator+(const charT* lhs,
|
| 1649 |
-
basic_string<charT,traits,Allocator>&& rhs);
|
| 1650 |
-
```
|
| 1651 |
-
|
| 1652 |
-
*Returns:* `std::move(rhs.insert(0, lhs))`.
|
| 1653 |
-
|
| 1654 |
-
*Remarks:* Uses `traits::length()`.
|
| 1655 |
-
|
| 1656 |
-
``` cpp
|
| 1657 |
-
template<class charT, class traits, class Allocator>
|
| 1658 |
-
basic_string<charT,traits,Allocator>
|
| 1659 |
-
operator+(charT lhs,
|
| 1660 |
-
const basic_string<charT,traits,Allocator>& rhs);
|
| 1661 |
-
```
|
| 1662 |
-
|
| 1663 |
-
*Returns:* `basic_string<charT,traits,Allocator>(1,lhs) + rhs`.
|
| 1664 |
-
|
| 1665 |
-
``` cpp
|
| 1666 |
-
template<class charT, class traits, class Allocator>
|
| 1667 |
-
basic_string<charT,traits,Allocator>
|
| 1668 |
-
operator+(charT lhs,
|
| 1669 |
-
basic_string<charT,traits,Allocator>&& rhs);
|
| 1670 |
-
```
|
| 1671 |
-
|
| 1672 |
-
*Returns:* `std::move(rhs.insert(0, 1, lhs))`.
|
| 1673 |
-
|
| 1674 |
-
``` cpp
|
| 1675 |
-
template<class charT, class traits, class Allocator>
|
| 1676 |
-
basic_string<charT,traits,Allocator>
|
| 1677 |
-
operator+(const basic_string<charT,traits,Allocator>& lhs,
|
| 1678 |
-
const charT* rhs);
|
| 1679 |
-
```
|
| 1680 |
-
|
| 1681 |
-
*Returns:* `lhs + basic_string<charT,traits,Allocator>(rhs)`.
|
| 1682 |
-
|
| 1683 |
-
*Remarks:* Uses `traits::length()`.
|
| 1684 |
-
|
| 1685 |
-
``` cpp
|
| 1686 |
-
template<class charT, class traits, class Allocator>
|
| 1687 |
-
basic_string<charT,traits,Allocator>
|
| 1688 |
-
operator+(basic_string<charT,traits,Allocator>&& lhs,
|
| 1689 |
-
const charT* rhs);
|
| 1690 |
-
```
|
| 1691 |
-
|
| 1692 |
-
*Returns:* `std::move(lhs.append(rhs))`.
|
| 1693 |
-
|
| 1694 |
-
*Remarks:* Uses `traits::length()`.
|
| 1695 |
-
|
| 1696 |
-
``` cpp
|
| 1697 |
-
template<class charT, class traits, class Allocator>
|
| 1698 |
-
basic_string<charT,traits,Allocator>
|
| 1699 |
-
operator+(const basic_string<charT,traits,Allocator>& lhs,
|
| 1700 |
-
charT rhs);
|
| 1701 |
-
```
|
| 1702 |
-
|
| 1703 |
-
*Returns:* `lhs + basic_string<charT,traits,Allocator>(1,rhs)`.
|
| 1704 |
-
|
| 1705 |
-
``` cpp
|
| 1706 |
-
template<class charT, class traits, class Allocator>
|
| 1707 |
-
basic_string<charT,traits,Allocator>
|
| 1708 |
-
operator+(basic_string<charT,traits,Allocator>&& lhs,
|
| 1709 |
-
charT rhs);
|
| 1710 |
-
```
|
| 1711 |
-
|
| 1712 |
-
*Returns:* `std::move(lhs.append(1, rhs))`.
|
| 1713 |
-
|
| 1714 |
-
#### `operator==` <a id="string::operator==">[[string::operator==]]</a>
|
| 1715 |
-
|
| 1716 |
-
``` cpp
|
| 1717 |
-
template<class charT, class traits, class Allocator>
|
| 1718 |
-
bool operator==(const basic_string<charT,traits,Allocator>& lhs,
|
| 1719 |
-
const basic_string<charT,traits,Allocator>& rhs) noexcept;
|
| 1720 |
-
```
|
| 1721 |
-
|
| 1722 |
-
*Returns:* `lhs.compare(rhs) == 0`.
|
| 1723 |
-
|
| 1724 |
-
``` cpp
|
| 1725 |
-
template<class charT, class traits, class Allocator>
|
| 1726 |
-
bool operator==(const charT* lhs,
|
| 1727 |
-
const basic_string<charT,traits,Allocator>& rhs);
|
| 1728 |
-
```
|
| 1729 |
-
|
| 1730 |
-
*Returns:* `rhs == lhs`.
|
| 1731 |
-
|
| 1732 |
-
``` cpp
|
| 1733 |
-
template<class charT, class traits, class Allocator>
|
| 1734 |
-
bool operator==(const basic_string<charT,traits,Allocator>& lhs,
|
| 1735 |
-
const charT* rhs);
|
| 1736 |
-
```
|
| 1737 |
-
|
| 1738 |
-
*Requires:* `rhs` points to an array of at least
|
| 1739 |
-
`traits::length(rhs) + 1` elements of `charT`.
|
| 1740 |
-
|
| 1741 |
-
*Returns:* `lhs.compare(rhs) == 0`.
|
| 1742 |
-
|
| 1743 |
-
#### `operator!=` <a id="string::op!=">[[string::op!=]]</a>
|
| 1744 |
-
|
| 1745 |
-
``` cpp
|
| 1746 |
-
template<class charT, class traits, class Allocator>
|
| 1747 |
-
bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
|
| 1748 |
-
const basic_string<charT,traits,Allocator>& rhs) noexcept;
|
| 1749 |
-
```
|
| 1750 |
-
|
| 1751 |
-
*Returns:* `!(lhs == rhs)`.
|
| 1752 |
-
|
| 1753 |
-
``` cpp
|
| 1754 |
-
template<class charT, class traits, class Allocator>
|
| 1755 |
-
bool operator!=(const charT* lhs,
|
| 1756 |
-
const basic_string<charT,traits,Allocator>& rhs);
|
| 1757 |
-
```
|
| 1758 |
-
|
| 1759 |
-
*Returns:* `rhs != lhs`.
|
| 1760 |
-
|
| 1761 |
-
``` cpp
|
| 1762 |
-
template<class charT, class traits, class Allocator>
|
| 1763 |
-
bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
|
| 1764 |
-
const charT* rhs);
|
| 1765 |
-
```
|
| 1766 |
-
|
| 1767 |
-
*Requires:* `rhs` points to an array of at least
|
| 1768 |
-
`traits::length(rhs) + 1` elements of `charT`.
|
| 1769 |
-
|
| 1770 |
-
*Returns:* `lhs.compare(rhs) != 0`.
|
| 1771 |
-
|
| 1772 |
-
#### `operator<` <a id="string::op<">[[string::op<]]</a>
|
| 1773 |
-
|
| 1774 |
-
``` cpp
|
| 1775 |
-
template<class charT, class traits, class Allocator>
|
| 1776 |
-
bool operator< (const basic_string<charT,traits,Allocator>& lhs,
|
| 1777 |
-
const basic_string<charT,traits,Allocator>& rhs) noexcept;
|
| 1778 |
-
```
|
| 1779 |
-
|
| 1780 |
-
*Returns:* `lhs.compare(rhs) < 0`.
|
| 1781 |
-
|
| 1782 |
-
``` cpp
|
| 1783 |
-
template<class charT, class traits, class Allocator>
|
| 1784 |
-
bool operator< (const charT* lhs,
|
| 1785 |
-
const basic_string<charT,traits,Allocator>& rhs);
|
| 1786 |
-
```
|
| 1787 |
-
|
| 1788 |
-
*Returns:* `rhs.compare(lhs) > 0`.
|
| 1789 |
-
|
| 1790 |
-
``` cpp
|
| 1791 |
-
template<class charT, class traits, class Allocator>
|
| 1792 |
-
bool operator< (const basic_string<charT,traits,Allocator>& lhs,
|
| 1793 |
-
const charT* rhs);
|
| 1794 |
-
```
|
| 1795 |
-
|
| 1796 |
-
*Returns:* `lhs.compare(rhs) < 0`.
|
| 1797 |
-
|
| 1798 |
-
#### `operator>` <a id="string::op>">[[string::op>]]</a>
|
| 1799 |
-
|
| 1800 |
-
``` cpp
|
| 1801 |
-
template<class charT, class traits, class Allocator>
|
| 1802 |
-
bool operator> (const basic_string<charT,traits,Allocator>& lhs,
|
| 1803 |
-
const basic_string<charT,traits,Allocator>& rhs) noexcept;
|
| 1804 |
-
```
|
| 1805 |
-
|
| 1806 |
-
*Returns:* `lhs.compare(rhs) > 0`.
|
| 1807 |
-
|
| 1808 |
-
``` cpp
|
| 1809 |
-
template<class charT, class traits, class Allocator>
|
| 1810 |
-
bool operator> (const charT* lhs,
|
| 1811 |
-
const basic_string<charT,traits,Allocator>& rhs);
|
| 1812 |
-
```
|
| 1813 |
-
|
| 1814 |
-
*Returns:* `rhs.compare(lhs) < 0`.
|
| 1815 |
-
|
| 1816 |
-
``` cpp
|
| 1817 |
-
template<class charT, class traits, class Allocator>
|
| 1818 |
-
bool operator> (const basic_string<charT,traits,Allocator>& lhs,
|
| 1819 |
-
const charT* rhs);
|
| 1820 |
-
```
|
| 1821 |
-
|
| 1822 |
-
*Returns:* `lhs.compare(rhs) > 0`.
|
| 1823 |
-
|
| 1824 |
-
#### `operator<=` <a id="string::op<=">[[string::op<=]]</a>
|
| 1825 |
-
|
| 1826 |
-
``` cpp
|
| 1827 |
-
template<class charT, class traits, class Allocator>
|
| 1828 |
-
bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
|
| 1829 |
-
const basic_string<charT,traits,Allocator>& rhs) noexcept;
|
| 1830 |
-
```
|
| 1831 |
-
|
| 1832 |
-
*Returns:* `lhs.compare(rhs) <= 0`.
|
| 1833 |
-
|
| 1834 |
-
``` cpp
|
| 1835 |
-
template<class charT, class traits, class Allocator>
|
| 1836 |
-
bool operator<=(const charT* lhs,
|
| 1837 |
-
const basic_string<charT,traits,Allocator>& rhs);
|
| 1838 |
-
```
|
| 1839 |
-
|
| 1840 |
-
*Returns:* `rhs.compare(lhs) >= 0`.
|
| 1841 |
-
|
| 1842 |
-
``` cpp
|
| 1843 |
-
template<class charT, class traits, class Allocator>
|
| 1844 |
-
bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
|
| 1845 |
-
const charT* rhs);
|
| 1846 |
-
```
|
| 1847 |
-
|
| 1848 |
-
*Returns:* `lhs.compare(rhs) <= 0`.
|
| 1849 |
-
|
| 1850 |
-
#### `operator>=` <a id="string::op>=">[[string::op>=]]</a>
|
| 1851 |
-
|
| 1852 |
-
``` cpp
|
| 1853 |
-
template<class charT, class traits, class Allocator>
|
| 1854 |
-
bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
|
| 1855 |
-
const basic_string<charT,traits,Allocator>& rhs) noexcept;
|
| 1856 |
-
```
|
| 1857 |
-
|
| 1858 |
-
*Returns:* `lhs.compare(rhs) >= 0`.
|
| 1859 |
-
|
| 1860 |
-
``` cpp
|
| 1861 |
-
template<class charT, class traits, class Allocator>
|
| 1862 |
-
bool operator>=(const charT* lhs,
|
| 1863 |
-
const basic_string<charT,traits,Allocator>& rhs);
|
| 1864 |
-
```
|
| 1865 |
-
|
| 1866 |
-
*Returns:* `rhs.compare(lhs) <= 0`.
|
| 1867 |
-
|
| 1868 |
-
``` cpp
|
| 1869 |
-
template<class charT, class traits, class Allocator>
|
| 1870 |
-
bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
|
| 1871 |
-
const charT* rhs);
|
| 1872 |
-
```
|
| 1873 |
-
|
| 1874 |
-
*Returns:* `lhs.compare(rhs) >= 0`.
|
| 1875 |
-
|
| 1876 |
-
#### `swap` <a id="string.special">[[string.special]]</a>
|
| 1877 |
-
|
| 1878 |
-
``` cpp
|
| 1879 |
-
template<class charT, class traits, class Allocator>
|
| 1880 |
-
void swap(basic_string<charT,traits,Allocator>& lhs,
|
| 1881 |
-
basic_string<charT,traits,Allocator>& rhs);
|
| 1882 |
-
```
|
| 1883 |
-
|
| 1884 |
-
*Effects:* Equivalent to `lhs.swap(rhs);`
|
| 1885 |
-
|
| 1886 |
-
#### Inserters and extractors <a id="string.io">[[string.io]]</a>
|
| 1887 |
-
|
| 1888 |
-
``` cpp
|
| 1889 |
-
template<class charT, class traits, class Allocator>
|
| 1890 |
-
basic_istream<charT,traits>&
|
| 1891 |
-
operator>>(basic_istream<charT,traits>& is,
|
| 1892 |
-
basic_string<charT,traits,Allocator>& str);
|
| 1893 |
-
```
|
| 1894 |
-
|
| 1895 |
-
*Effects:* Behaves as a formatted input
|
| 1896 |
-
function ([[istream.formatted.reqmts]]). After constructing a `sentry`
|
| 1897 |
-
object, if the sentry converts to true, calls `str.erase()` and then
|
| 1898 |
-
extracts characters from `is` and appends them to `str` as if by calling
|
| 1899 |
-
`str.append(1,c)`. If `is.width()` is greater than zero, the maximum
|
| 1900 |
-
number `n` of characters appended is `is.width()`; otherwise `n` is
|
| 1901 |
-
`str.max_size()`. Characters are extracted and appended until any of the
|
| 1902 |
-
following occurs:
|
| 1903 |
-
|
| 1904 |
-
- *n* characters are stored;
|
| 1905 |
-
- end-of-file occurs on the input sequence;
|
| 1906 |
-
- `isspace(c,is.getloc())` is true for the next available input
|
| 1907 |
-
character *c*.
|
| 1908 |
-
|
| 1909 |
-
After the last character (if any) is extracted, `is.width(0)` is called
|
| 1910 |
-
and the `sentry` object `k` is destroyed.
|
| 1911 |
-
|
| 1912 |
-
If the function extracts no characters, it calls
|
| 1913 |
-
`is.setstate(ios::failbit)`, which may throw
|
| 1914 |
-
`ios_base::failure` ([[iostate.flags]]).
|
| 1915 |
-
|
| 1916 |
-
*Returns:* `is`
|
| 1917 |
-
|
| 1918 |
-
``` cpp
|
| 1919 |
-
template<class charT, class traits, class Allocator>
|
| 1920 |
-
basic_ostream<charT, traits>&
|
| 1921 |
-
operator<<(basic_ostream<charT, traits>& os,
|
| 1922 |
-
const basic_string<charT,traits,Allocator>& str);
|
| 1923 |
-
```
|
| 1924 |
-
|
| 1925 |
-
*Effects:* Behaves as a formatted output
|
| 1926 |
-
function ([[ostream.formatted.reqmts]]) of `os`. Forms a character
|
| 1927 |
-
sequence `seq`, initially consisting of the elements defined by the
|
| 1928 |
-
range \[`str.begin(), str.end()`). Determines padding for `seq` as
|
| 1929 |
-
described in [[ostream.formatted.reqmts]]. Then inserts `seq` as if by
|
| 1930 |
-
calling `os.rdbuf()->sputn(seq, n)`, where `n` is the larger of
|
| 1931 |
-
`os.width()` and `str.size()`; then calls `os.width(0)`.
|
| 1932 |
-
|
| 1933 |
-
*Returns:* `os`
|
| 1934 |
-
|
| 1935 |
-
``` cpp
|
| 1936 |
-
template<class charT, class traits, class Allocator>
|
| 1937 |
-
basic_istream<charT,traits>&
|
| 1938 |
-
getline(basic_istream<charT,traits>& is,
|
| 1939 |
-
basic_string<charT,traits,Allocator>& str,
|
| 1940 |
-
charT delim);
|
| 1941 |
-
template<class charT, class traits, class Allocator>
|
| 1942 |
-
basic_istream<charT,traits>&
|
| 1943 |
-
getline(basic_istream<charT,traits>&& is,
|
| 1944 |
-
basic_string<charT,traits,Allocator>& str,
|
| 1945 |
-
charT delim);
|
| 1946 |
-
```
|
| 1947 |
-
|
| 1948 |
-
*Effects:* Behaves as an unformatted input
|
| 1949 |
-
function ([[istream.unformatted]]), except that it does not affect the
|
| 1950 |
-
value returned by subsequent calls to `basic_istream<>::gcount()`. After
|
| 1951 |
-
constructing a `sentry` object, if the sentry converts to true, calls
|
| 1952 |
-
`str.erase()` and then extracts characters from `is` and appends them to
|
| 1953 |
-
`str` as if by calling `str.append(1, c)` until any of the following
|
| 1954 |
-
occurs:
|
| 1955 |
-
|
| 1956 |
-
- end-of-file occurs on the input sequence (in which case, the `getline`
|
| 1957 |
-
function calls `is.setstate(ios_base::eofbit)`).
|
| 1958 |
-
- `traits::eq(c, delim)` for the next available input character *c* (in
|
| 1959 |
-
which case, *c* is extracted but not appended) ([[iostate.flags]])
|
| 1960 |
-
- `str.max_size()` characters are stored (in which case, the function
|
| 1961 |
-
calls `is.setstate(ios_base::failbit))` ([[iostate.flags]])
|
| 1962 |
-
|
| 1963 |
-
The conditions are tested in the order shown. In any case, after the
|
| 1964 |
-
last character is extracted, the `sentry` object `k` is destroyed.
|
| 1965 |
-
|
| 1966 |
-
If the function extracts no characters, it calls
|
| 1967 |
-
`is.setstate(ios_base::failbit)` which may throw
|
| 1968 |
-
`ios_base::failure` ([[iostate.flags]]).
|
| 1969 |
-
|
| 1970 |
-
*Returns:* `is`.
|
| 1971 |
-
|
| 1972 |
-
``` cpp
|
| 1973 |
-
template<class charT, class traits, class Allocator>
|
| 1974 |
-
basic_istream<charT,traits>&
|
| 1975 |
-
getline(basic_istream<charT,traits>& is,
|
| 1976 |
-
basic_string<charT,traits,Allocator>& str);
|
| 1977 |
-
template<class charT, class traits, class Allocator>
|
| 1978 |
-
basic_istream<charT,traits>&
|
| 1979 |
-
getline(basic_istream<charT,traits>&& is,
|
| 1980 |
-
basic_string<charT,traits,Allocator>& str);
|
| 1981 |
-
```
|
| 1982 |
-
|
| 1983 |
-
*Returns:* `getline(is,str,is.widen(’\n’))`
|
| 1984 |
-
|
|
|
|
| 1 |
+
### Class template `basic_string` <a id="basic.string">[[basic.string]]</a>
|
| 2 |
|
| 3 |
The class template `basic_string` describes objects that can store a
|
| 4 |
sequence consisting of a varying number of arbitrary char-like objects
|
| 5 |
with the first element of the sequence at position zero. Such a sequence
|
| 6 |
is also called a “string” if the type of the char-like objects that it
|
|
|
|
| 10 |
|
| 11 |
The member functions of `basic_string` use an object of the `Allocator`
|
| 12 |
class passed as a template parameter to allocate and free storage for
|
| 13 |
the contained char-like objects.[^2]
|
| 14 |
|
| 15 |
+
A `basic_string` is a contiguous container (
|
| 16 |
+
[[container.requirements.general]]).
|
| 17 |
|
| 18 |
In all cases, `size() <= capacity()`.
|
| 19 |
|
| 20 |
The functions described in this Clause can report two kinds of errors,
|
| 21 |
each associated with an exception type:
|
|
|
|
| 30 |
template<class charT, class traits = char_traits<charT>,
|
| 31 |
class Allocator = allocator<charT>>
|
| 32 |
class basic_string {
|
| 33 |
public:
|
| 34 |
// types:
|
| 35 |
+
using traits_type = traits;
|
| 36 |
+
using value_type = charT;
|
| 37 |
+
using allocator_type = Allocator;
|
| 38 |
+
using size_type = typename allocator_traits<Allocator>::size_type;
|
| 39 |
+
using difference_type = typename allocator_traits<Allocator>::difference_type;
|
| 40 |
+
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 41 |
+
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 42 |
+
using reference = value_type&;
|
| 43 |
+
using const_reference = const value_type&;
|
| 44 |
|
| 45 |
+
using iterator = implementation-defined // type of basic_string::iterator; // see [container.requirements]
|
| 46 |
+
using const_iterator = implementation-defined // type of basic_string::const_iterator; // see [container.requirements]
|
| 47 |
+
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 48 |
+
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
static const size_type npos = -1;
|
| 50 |
|
| 51 |
+
// [string.cons], construct/copy/destroy
|
| 52 |
+
basic_string() noexcept(noexcept(Allocator())) : basic_string(Allocator()) { }
|
| 53 |
+
explicit basic_string(const Allocator& a) noexcept;
|
| 54 |
basic_string(const basic_string& str);
|
| 55 |
basic_string(basic_string&& str) noexcept;
|
| 56 |
+
basic_string(const basic_string& str, size_type pos,
|
| 57 |
+
const Allocator& a = Allocator());
|
| 58 |
+
basic_string(const basic_string& str, size_type pos, size_type n,
|
| 59 |
+
const Allocator& a = Allocator());
|
| 60 |
+
template<class T>
|
| 61 |
+
basic_string(const T& t, size_type pos, size_type n,
|
| 62 |
+
const Allocator& a = Allocator());
|
| 63 |
+
explicit basic_string(basic_string_view<charT, traits> sv,
|
| 64 |
const Allocator& a = Allocator());
|
| 65 |
basic_string(const charT* s,
|
| 66 |
size_type n, const Allocator& a = Allocator());
|
| 67 |
basic_string(const charT* s, const Allocator& a = Allocator());
|
| 68 |
basic_string(size_type n, charT c, const Allocator& a = Allocator());
|
|
|
|
| 73 |
basic_string(const basic_string&, const Allocator&);
|
| 74 |
basic_string(basic_string&&, const Allocator&);
|
| 75 |
|
| 76 |
~basic_string();
|
| 77 |
basic_string& operator=(const basic_string& str);
|
| 78 |
+
basic_string& operator=(basic_string&& str)
|
| 79 |
+
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
|
| 80 |
+
allocator_traits<Allocator>::is_always_equal::value);
|
| 81 |
+
basic_string& operator=(basic_string_view<charT, traits> sv);
|
| 82 |
basic_string& operator=(const charT* s);
|
| 83 |
basic_string& operator=(charT c);
|
| 84 |
basic_string& operator=(initializer_list<charT>);
|
| 85 |
|
| 86 |
+
// [string.iterators], iterators
|
| 87 |
iterator begin() noexcept;
|
| 88 |
const_iterator begin() const noexcept;
|
| 89 |
iterator end() noexcept;
|
| 90 |
const_iterator end() const noexcept;
|
| 91 |
|
|
|
|
| 97 |
const_iterator cbegin() const noexcept;
|
| 98 |
const_iterator cend() const noexcept;
|
| 99 |
const_reverse_iterator crbegin() const noexcept;
|
| 100 |
const_reverse_iterator crend() const noexcept;
|
| 101 |
|
| 102 |
+
// [string.capacity], capacity
|
| 103 |
size_type size() const noexcept;
|
| 104 |
size_type length() const noexcept;
|
| 105 |
size_type max_size() const noexcept;
|
| 106 |
void resize(size_type n, charT c);
|
| 107 |
void resize(size_type n);
|
|
|
|
| 109 |
void reserve(size_type res_arg = 0);
|
| 110 |
void shrink_to_fit();
|
| 111 |
void clear() noexcept;
|
| 112 |
bool empty() const noexcept;
|
| 113 |
|
| 114 |
+
// [string.access], element access
|
| 115 |
const_reference operator[](size_type pos) const;
|
| 116 |
reference operator[](size_type pos);
|
| 117 |
const_reference at(size_type n) const;
|
| 118 |
reference at(size_type n);
|
| 119 |
|
| 120 |
const charT& front() const;
|
| 121 |
charT& front();
|
| 122 |
const charT& back() const;
|
| 123 |
charT& back();
|
| 124 |
|
| 125 |
+
// [string.modifiers], modifiers
|
| 126 |
basic_string& operator+=(const basic_string& str);
|
| 127 |
+
basic_string& operator+=(basic_string_view<charT, traits> sv);
|
| 128 |
basic_string& operator+=(const charT* s);
|
| 129 |
basic_string& operator+=(charT c);
|
| 130 |
basic_string& operator+=(initializer_list<charT>);
|
| 131 |
basic_string& append(const basic_string& str);
|
| 132 |
basic_string& append(const basic_string& str, size_type pos,
|
| 133 |
size_type n = npos);
|
| 134 |
+
basic_string& append(basic_string_view<charT, traits> sv);
|
| 135 |
+
template<class T>
|
| 136 |
+
basic_string& append(const T& t, size_type pos, size_type n = npos);
|
| 137 |
basic_string& append(const charT* s, size_type n);
|
| 138 |
basic_string& append(const charT* s);
|
| 139 |
basic_string& append(size_type n, charT c);
|
| 140 |
template<class InputIterator>
|
| 141 |
basic_string& append(InputIterator first, InputIterator last);
|
| 142 |
basic_string& append(initializer_list<charT>);
|
| 143 |
void push_back(charT c);
|
| 144 |
|
| 145 |
basic_string& assign(const basic_string& str);
|
| 146 |
+
basic_string& assign(basic_string&& str)
|
| 147 |
+
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
|
| 148 |
+
allocator_traits<Allocator>::is_always_equal::value);
|
| 149 |
basic_string& assign(const basic_string& str, size_type pos,
|
| 150 |
size_type n = npos);
|
| 151 |
+
basic_string& assign(basic_string_view<charT, traits> sv);
|
| 152 |
+
template<class T>
|
| 153 |
+
basic_string& assign(const T& t, size_type pos, size_type n = npos);
|
| 154 |
basic_string& assign(const charT* s, size_type n);
|
| 155 |
basic_string& assign(const charT* s);
|
| 156 |
basic_string& assign(size_type n, charT c);
|
| 157 |
template<class InputIterator>
|
| 158 |
basic_string& assign(InputIterator first, InputIterator last);
|
| 159 |
basic_string& assign(initializer_list<charT>);
|
| 160 |
|
| 161 |
+
basic_string& insert(size_type pos, const basic_string& str);
|
| 162 |
basic_string& insert(size_type pos1, const basic_string& str,
|
| 163 |
size_type pos2, size_type n = npos);
|
| 164 |
+
basic_string& insert(size_type pos, basic_string_view<charT, traits> sv);
|
| 165 |
+
template<class T>
|
| 166 |
+
basic_string& insert(size_type pos1, const T& t,
|
| 167 |
+
size_type pos2, size_type n = npos);
|
| 168 |
basic_string& insert(size_type pos, const charT* s, size_type n);
|
| 169 |
basic_string& insert(size_type pos, const charT* s);
|
| 170 |
basic_string& insert(size_type pos, size_type n, charT c);
|
| 171 |
iterator insert(const_iterator p, charT c);
|
| 172 |
iterator insert(const_iterator p, size_type n, charT c);
|
|
|
|
| 183 |
basic_string& replace(size_type pos1, size_type n1,
|
| 184 |
const basic_string& str);
|
| 185 |
basic_string& replace(size_type pos1, size_type n1,
|
| 186 |
const basic_string& str,
|
| 187 |
size_type pos2, size_type n2 = npos);
|
| 188 |
+
basic_string& replace(size_type pos1, size_type n1,
|
| 189 |
+
basic_string_view<charT, traits> sv);
|
| 190 |
+
template<class T>
|
| 191 |
+
basic_string& replace(size_type pos1, size_type n1, const T& t,
|
| 192 |
+
size_type pos2, size_type n2 = npos);
|
| 193 |
basic_string& replace(size_type pos, size_type n1, const charT* s,
|
| 194 |
size_type n2);
|
| 195 |
basic_string& replace(size_type pos, size_type n1, const charT* s);
|
| 196 |
basic_string& replace(size_type pos, size_type n1, size_type n2,
|
| 197 |
charT c);
|
| 198 |
|
| 199 |
basic_string& replace(const_iterator i1, const_iterator i2,
|
| 200 |
const basic_string& str);
|
| 201 |
+
basic_string& replace(const_iterator i1, const_iterator i2,
|
| 202 |
+
basic_string_view<charT, traits> sv);
|
| 203 |
basic_string& replace(const_iterator i1, const_iterator i2, const charT* s,
|
| 204 |
size_type n);
|
| 205 |
basic_string& replace(const_iterator i1, const_iterator i2, const charT* s);
|
| 206 |
basic_string& replace(const_iterator i1, const_iterator i2,
|
| 207 |
size_type n, charT c);
|
|
|
|
| 209 |
basic_string& replace(const_iterator i1, const_iterator i2,
|
| 210 |
InputIterator j1, InputIterator j2);
|
| 211 |
basic_string& replace(const_iterator, const_iterator, initializer_list<charT>);
|
| 212 |
|
| 213 |
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
| 214 |
+
void swap(basic_string& str)
|
| 215 |
+
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
|
| 216 |
+
allocator_traits<Allocator>::is_always_equal::value);
|
| 217 |
|
| 218 |
+
// [string.ops], string operations
|
| 219 |
const charT* c_str() const noexcept;
|
| 220 |
const charT* data() const noexcept;
|
| 221 |
+
charT* data() noexcept;
|
| 222 |
+
operator basic_string_view<charT, traits>() const noexcept;
|
| 223 |
allocator_type get_allocator() const noexcept;
|
| 224 |
|
| 225 |
+
size_type find (basic_string_view<charT, traits> sv,
|
| 226 |
+
size_type pos = 0) const noexcept;
|
| 227 |
size_type find (const basic_string& str, size_type pos = 0) const noexcept;
|
| 228 |
size_type find (const charT* s, size_type pos, size_type n) const;
|
| 229 |
size_type find (const charT* s, size_type pos = 0) const;
|
| 230 |
size_type find (charT c, size_type pos = 0) const;
|
| 231 |
+
size_type rfind(basic_string_view<charT, traits> sv,
|
| 232 |
+
size_type pos = npos) const noexcept;
|
| 233 |
size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
|
| 234 |
size_type rfind(const charT* s, size_type pos, size_type n) const;
|
| 235 |
size_type rfind(const charT* s, size_type pos = npos) const;
|
| 236 |
size_type rfind(charT c, size_type pos = npos) const;
|
| 237 |
|
| 238 |
+
size_type find_first_of(basic_string_view<charT, traits> sv,
|
| 239 |
+
size_type pos = 0) const noexcept;
|
| 240 |
size_type find_first_of(const basic_string& str,
|
| 241 |
size_type pos = 0) const noexcept;
|
| 242 |
size_type find_first_of(const charT* s,
|
| 243 |
size_type pos, size_type n) const;
|
| 244 |
size_type find_first_of(const charT* s, size_type pos = 0) const;
|
| 245 |
size_type find_first_of(charT c, size_type pos = 0) const;
|
| 246 |
+
size_type find_last_of (basic_string_view<charT, traits> sv,
|
| 247 |
+
size_type pos = npos) const noexcept;
|
| 248 |
size_type find_last_of (const basic_string& str,
|
| 249 |
size_type pos = npos) const noexcept;
|
| 250 |
size_type find_last_of (const charT* s,
|
| 251 |
size_type pos, size_type n) const;
|
| 252 |
size_type find_last_of (const charT* s, size_type pos = npos) const;
|
| 253 |
size_type find_last_of (charT c, size_type pos = npos) const;
|
| 254 |
|
| 255 |
+
size_type find_first_not_of(basic_string_view<charT, traits> sv,
|
| 256 |
+
size_type pos = 0) const noexcept;
|
| 257 |
size_type find_first_not_of(const basic_string& str,
|
| 258 |
size_type pos = 0) const noexcept;
|
| 259 |
size_type find_first_not_of(const charT* s, size_type pos,
|
| 260 |
size_type n) const;
|
| 261 |
size_type find_first_not_of(const charT* s, size_type pos = 0) const;
|
| 262 |
size_type find_first_not_of(charT c, size_type pos = 0) const;
|
| 263 |
+
size_type find_last_not_of (basic_string_view<charT, traits> sv,
|
| 264 |
+
size_type pos = npos) const noexcept;
|
| 265 |
size_type find_last_not_of (const basic_string& str,
|
| 266 |
size_type pos = npos) const noexcept;
|
| 267 |
size_type find_last_not_of (const charT* s, size_type pos,
|
| 268 |
size_type n) const;
|
| 269 |
size_type find_last_not_of (const charT* s,
|
| 270 |
size_type pos = npos) const;
|
| 271 |
size_type find_last_not_of (charT c, size_type pos = npos) const;
|
| 272 |
|
| 273 |
basic_string substr(size_type pos = 0, size_type n = npos) const;
|
| 274 |
+
int compare(basic_string_view<charT, traits> sv) const noexcept;
|
| 275 |
+
int compare(size_type pos1, size_type n1,
|
| 276 |
+
basic_string_view<charT, traits> sv) const;
|
| 277 |
+
template<class T>
|
| 278 |
+
int compare(size_type pos1, size_type n1, const T& t,
|
| 279 |
+
size_type pos2, size_type n2 = npos) const;
|
| 280 |
int compare(const basic_string& str) const noexcept;
|
| 281 |
int compare(size_type pos1, size_type n1,
|
| 282 |
const basic_string& str) const;
|
| 283 |
int compare(size_type pos1, size_type n1,
|
| 284 |
const basic_string& str,
|
|
|
|
| 287 |
int compare(size_type pos1, size_type n1,
|
| 288 |
const charT* s) const;
|
| 289 |
int compare(size_type pos1, size_type n1,
|
| 290 |
const charT* s, size_type n2) const;
|
| 291 |
};
|
| 292 |
+
|
| 293 |
+
template<class InputIterator,
|
| 294 |
+
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
| 295 |
+
basic_string(InputIterator, InputIterator, Allocator = Allocator())
|
| 296 |
+
-> basic_string<typename iterator_traits<InputIterator>::value_type,
|
| 297 |
+
char_traits<typename iterator_traits<InputIterator>::value_type>,
|
| 298 |
+
Allocator>;
|
| 299 |
}
|
| 300 |
```
|
| 301 |
|
| 302 |
+
#### `basic_string` general requirements <a id="string.require">[[string.require]]</a>
|
| 303 |
|
| 304 |
If any operation would cause `size()` to exceed `max_size()`, that
|
| 305 |
operation shall throw an exception object of type `length_error`.
|
| 306 |
|
| 307 |
If any member function or operator of `basic_string` throws an
|
|
|
|
| 311 |
type `allocator_traits<Allocator>::value_type` shall name the same type
|
| 312 |
as `charT`. Every object of type
|
| 313 |
`basic_string<charT, traits, Allocator>` shall use an object of type
|
| 314 |
`Allocator` to allocate and free storage for the contained `charT`
|
| 315 |
objects as needed. The `Allocator` object used shall be obtained as
|
| 316 |
+
described in [[container.requirements.general]]. In every specialization
|
| 317 |
+
`basic_string<charT, traits, Allocator>`, the type `traits` shall
|
| 318 |
+
satisfy the character traits requirements ([[char.traits]]), and the
|
| 319 |
+
type `traits::char_type` shall name the same type as `charT`.
|
|
|
|
|
|
|
| 320 |
|
| 321 |
References, pointers, and iterators referring to the elements of a
|
| 322 |
`basic_string` sequence may be invalidated by the following uses of that
|
| 323 |
`basic_string` object:
|
| 324 |
|
| 325 |
- as an argument to any standard library function taking a reference to
|
| 326 |
non-const `basic_string` as an argument.[^3]
|
| 327 |
+
- Calling non-const member functions, except `operator[]`, `at`, `data`,
|
| 328 |
`front`, `back`, `begin`, `rbegin`, `end`, and `rend`.
|
| 329 |
|
| 330 |
+
#### `basic_string` constructors and assignment operators <a id="string.cons">[[string.cons]]</a>
|
| 331 |
|
| 332 |
``` cpp
|
| 333 |
+
explicit basic_string(const Allocator& a) noexcept;
|
| 334 |
```
|
| 335 |
|
| 336 |
*Effects:* Constructs an object of class `basic_string`. The
|
| 337 |
postconditions of this function are indicated in
|
| 338 |
Table [[tab:strings.ctr.1]].
|
|
|
|
| 361 |
| `data()` | points at the first element of an allocated copy of the array whose first element is pointed at by `str.data()` |
|
| 362 |
| `size()` | `str.size()` |
|
| 363 |
| `capacity()` | a value at least as large as `size()` |
|
| 364 |
|
| 365 |
``` cpp
|
| 366 |
+
basic_string(const basic_string& str, size_type pos,
|
|
|
|
| 367 |
const Allocator& a = Allocator());
|
| 368 |
```
|
| 369 |
|
| 370 |
+
*Throws:* `out_of_range` if `pos > str.size()`.
|
| 371 |
+
|
| 372 |
+
*Effects:* Constructs an object of class `basic_string` and determines
|
| 373 |
+
the effective length `rlen` of the initial string value as
|
| 374 |
+
`str.size() - pos`, as indicated in Table [[tab:strings.ctr.2]].
|
| 375 |
+
|
| 376 |
+
``` cpp
|
| 377 |
+
basic_string(const basic_string& str, size_type pos, size_type n,
|
| 378 |
+
const Allocator& a = Allocator());
|
| 379 |
+
```
|
| 380 |
|
| 381 |
*Throws:* `out_of_range` if `pos > str.size()`.
|
| 382 |
|
| 383 |
*Effects:* Constructs an object of class `basic_string` and determines
|
| 384 |
the effective length `rlen` of the initial string value as the smaller
|
| 385 |
of `n` and `str.size() - pos`, as indicated in
|
| 386 |
Table [[tab:strings.ctr.2]].
|
| 387 |
|
| 388 |
+
**Table: `basic_string(const basic_string&, size_type, const Allocator&)`\protect\mbox{ }and\protect
|
| 389 |
+
`basic_string(const basic_string&, size_type, size_type, const Allocator&)` effects** <a id="tab:strings.ctr.2">[tab:strings.ctr.2]</a>
|
| 390 |
|
| 391 |
| Element | Value |
|
| 392 |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 393 |
| `data()` | points at the first element of an allocated copy of `rlen` consecutive elements of the string controlled by `str` beginning at position `pos` |
|
| 394 |
| `size()` | `rlen` |
|
| 395 |
| `capacity()` | a value at least as large as `size()` |
|
| 396 |
|
| 397 |
+
``` cpp
|
| 398 |
+
template<class T>
|
| 399 |
+
basic_string(const T& t, size_type pos, size_type n,
|
| 400 |
+
const Allocator& a = Allocator());
|
| 401 |
+
```
|
| 402 |
+
|
| 403 |
+
*Effects:* Creates a variable, `sv`, as if by
|
| 404 |
+
`basic_string_view<charT, traits> sv = t;` and then behaves the same as:
|
| 405 |
+
|
| 406 |
+
``` cpp
|
| 407 |
+
basic_string(sv.substr(pos, n), a);
|
| 408 |
+
```
|
| 409 |
+
|
| 410 |
+
*Remarks:* This constructor shall not participate in overload resolution
|
| 411 |
+
unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
|
| 412 |
+
`true`.
|
| 413 |
+
|
| 414 |
+
``` cpp
|
| 415 |
+
explicit basic_string(basic_string_view<charT, traits> sv,
|
| 416 |
+
const Allocator& a = Allocator());
|
| 417 |
+
```
|
| 418 |
+
|
| 419 |
+
*Effects:* Same as `basic_string(sv.data(), sv.size(), a)`.
|
| 420 |
+
|
| 421 |
``` cpp
|
| 422 |
basic_string(const charT* s, size_type n,
|
| 423 |
const Allocator& a = Allocator());
|
| 424 |
```
|
| 425 |
|
|
|
|
| 456 |
| ------------ | ------------------------------------------------------------------------------------------------------ |
|
| 457 |
| `data()` | points at the first element of an allocated copy of the array whose first element is pointed at by `s` |
|
| 458 |
| `size()` | `traits::length(s)` |
|
| 459 |
| `capacity()` | a value at least as large as `size()` |
|
| 460 |
|
|
|
|
|
|
|
|
|
|
| 461 |
``` cpp
|
| 462 |
basic_string(size_type n, charT c, const Allocator& a = Allocator());
|
| 463 |
```
|
| 464 |
|
| 465 |
+
*Requires:* `n < npos`.
|
| 466 |
|
| 467 |
*Effects:* Constructs an object of class `basic_string` and determines
|
| 468 |
its initial string value by repeating the char-like object `c` for all
|
| 469 |
`n` elements, as indicated in Table [[tab:strings.ctr.5]].
|
| 470 |
|
|
|
|
| 480 |
template<class InputIterator>
|
| 481 |
basic_string(InputIterator begin, InputIterator end,
|
| 482 |
const Allocator& a = Allocator());
|
| 483 |
```
|
| 484 |
|
| 485 |
+
*Effects:* If `InputIterator` is an integral type, equivalent to:
|
| 486 |
|
| 487 |
``` cpp
|
| 488 |
+
basic_string(static_cast<size_type>(begin), static_cast<value_type>(end), a);
|
| 489 |
```
|
| 490 |
|
| 491 |
Otherwise constructs a string from the values in the range \[`begin`,
|
| 492 |
`end`), as indicated in the Sequence Requirements table
|
| 493 |
(see [[sequence.reqmts]]).
|
|
|
|
| 506 |
*Effects:* Constructs an object of class `basic_string` as indicated in
|
| 507 |
Table [[tab:strings.ctr.6]]. The stored allocator is constructed from
|
| 508 |
`alloc`. In the second form, `str` is left in a valid state with an
|
| 509 |
unspecified value.
|
| 510 |
|
| 511 |
+
**Table: `basic_string(const basic_string&, const Allocator&)`\protect and
|
| 512 |
`basic_string(basic_string&&, const Allocator&)` effects** <a id="tab:strings.ctr.6">[tab:strings.ctr.6]</a>
|
| 513 |
|
| 514 |
| Element | Value |
|
| 515 |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
| 516 |
| `data()` | points at the first element of an allocated copy of the array whose first element is pointed at by the original value of `str.data()`. |
|
|
|
|
| 520 |
|
| 521 |
|
| 522 |
*Throws:* The second form throws nothing if
|
| 523 |
`alloc == str.get_allocator()`.
|
| 524 |
|
| 525 |
+
``` cpp
|
| 526 |
+
template<class InputIterator,
|
| 527 |
+
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
| 528 |
+
basic_string(InputIterator, InputIterator, Allocator = Allocator())
|
| 529 |
+
-> basic_string<typename iterator_traits<InputIterator>::value_type,
|
| 530 |
+
char_traits<typename iterator_traits<InputIterator>::value_type>,
|
| 531 |
+
Allocator>;
|
| 532 |
+
```
|
| 533 |
+
|
| 534 |
+
*Remarks:* Shall not participate in overload resolution if
|
| 535 |
+
`InputIterator` is a type that does not qualify as an input iterator, or
|
| 536 |
+
if `Allocator` is a type that does not qualify as an
|
| 537 |
+
allocator ([[container.requirements.general]]).
|
| 538 |
+
|
| 539 |
``` cpp
|
| 540 |
basic_string& operator=(const basic_string& str);
|
| 541 |
```
|
| 542 |
|
| 543 |
*Effects:* If `*this` and `str` are not the same object, modifies
|
| 544 |
`*this` as shown in Table [[tab:strings.op=]].
|
| 545 |
|
| 546 |
If `*this` and `str` are the same object, the member has no effect.
|
| 547 |
|
| 548 |
+
*Returns:* `*this`.
|
| 549 |
|
| 550 |
**Table: `operator=(const basic_string&)` effects** <a id="tab:strings.op=">[tab:strings.op=]</a>
|
| 551 |
|
| 552 |
| Element | Value |
|
| 553 |
| ------------ | --------------------------------------------------------------------------------------------------------------- |
|
| 554 |
| `data()` | points at the first element of an allocated copy of the array whose first element is pointed at by `str.data()` |
|
| 555 |
| `size()` | `str.size()` |
|
| 556 |
| `capacity()` | a value at least as large as `size()` |
|
| 557 |
|
| 558 |
``` cpp
|
| 559 |
+
basic_string& operator=(basic_string&& str)
|
| 560 |
+
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
|
| 561 |
+
allocator_traits<Allocator>::is_always_equal::value);
|
| 562 |
```
|
| 563 |
|
| 564 |
+
*Effects:* Move assigns as a sequence
|
| 565 |
+
container ([[container.requirements]]), except that iterators, pointers
|
| 566 |
+
and references may be invalidated.
|
| 567 |
|
| 568 |
+
*Returns:* `*this`.
|
| 569 |
|
| 570 |
+
``` cpp
|
| 571 |
+
basic_string& operator=(basic_string_view<charT, traits> sv);
|
| 572 |
+
```
|
| 573 |
|
| 574 |
+
*Effects:* Equivalent to: `return assign(sv);`
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
|
| 576 |
``` cpp
|
| 577 |
basic_string& operator=(const charT* s);
|
| 578 |
```
|
| 579 |
|
|
|
|
| 589 |
|
| 590 |
``` cpp
|
| 591 |
basic_string& operator=(initializer_list<charT> il);
|
| 592 |
```
|
| 593 |
|
| 594 |
+
*Effects:* As if by: `*this = basic_string(il);`
|
| 595 |
|
| 596 |
*Returns:* `*this`.
|
| 597 |
|
| 598 |
+
#### `basic_string` iterator support <a id="string.iterators">[[string.iterators]]</a>
|
| 599 |
|
| 600 |
``` cpp
|
| 601 |
iterator begin() noexcept;
|
| 602 |
const_iterator begin() const noexcept;
|
| 603 |
const_iterator cbegin() const noexcept;
|
|
|
|
| 629 |
```
|
| 630 |
|
| 631 |
*Returns:* An iterator which is semantically equivalent to
|
| 632 |
`reverse_iterator(begin())`.
|
| 633 |
|
| 634 |
+
#### `basic_string` capacity <a id="string.capacity">[[string.capacity]]</a>
|
| 635 |
|
| 636 |
``` cpp
|
| 637 |
size_type size() const noexcept;
|
| 638 |
```
|
| 639 |
|
|
|
|
| 650 |
|
| 651 |
``` cpp
|
| 652 |
size_type max_size() const noexcept;
|
| 653 |
```
|
| 654 |
|
| 655 |
+
*Returns:* The largest possible number of char-like objects that can be
|
| 656 |
+
stored in a `basic_string`.
|
| 657 |
|
| 658 |
*Complexity:* Constant time.
|
| 659 |
|
| 660 |
``` cpp
|
| 661 |
void resize(size_type n, charT c);
|
| 662 |
```
|
| 663 |
|
|
|
|
|
|
|
| 664 |
*Throws:* `length_error` if `n > max_size()`.
|
| 665 |
|
| 666 |
*Effects:* Alters the length of the string designated by `*this` as
|
| 667 |
follows:
|
| 668 |
|
|
|
|
| 676 |
|
| 677 |
``` cpp
|
| 678 |
void resize(size_type n);
|
| 679 |
```
|
| 680 |
|
| 681 |
+
*Effects:* As if by `resize(n, charT())`.
|
| 682 |
|
| 683 |
``` cpp
|
| 684 |
size_type capacity() const noexcept;
|
| 685 |
```
|
| 686 |
|
|
|
|
| 693 |
The member function `reserve()` is a directive that informs a
|
| 694 |
`basic_string` object of a planned change in size, so that it can manage
|
| 695 |
the storage allocation accordingly.
|
| 696 |
|
| 697 |
*Effects:* After `reserve()`, `capacity()` is greater or equal to the
|
| 698 |
+
argument of `reserve`.
|
| 699 |
+
|
| 700 |
+
[*Note 1*: Calling `reserve()` with a `res_arg` argument less than
|
| 701 |
+
`capacity()` is in effect a non-binding shrink request. A call with
|
| 702 |
+
`res_arg <= size()` is in effect a non-binding shrink-to-fit
|
| 703 |
+
request. — *end note*]
|
| 704 |
|
| 705 |
*Throws:* `length_error` if `res_arg > max_size()`.[^4]
|
| 706 |
|
| 707 |
``` cpp
|
| 708 |
void shrink_to_fit();
|
| 709 |
```
|
| 710 |
|
| 711 |
+
*Effects:* `shrink_to_fit` is a non-binding request to reduce
|
| 712 |
+
`capacity()` to `size()`.
|
| 713 |
+
|
| 714 |
+
[*Note 2*: The request is non-binding to allow latitude for
|
| 715 |
+
implementation-specific optimizations. — *end note*]
|
| 716 |
+
|
| 717 |
+
It does not increase `capacity()`, but may reduce `capacity()` by
|
| 718 |
+
causing reallocation.
|
| 719 |
+
|
| 720 |
+
*Complexity:* Linear in the size of the sequence.
|
| 721 |
+
|
| 722 |
+
*Remarks:* Reallocation invalidates all the references, pointers, and
|
| 723 |
+
iterators referring to the elements in the sequence as well as the
|
| 724 |
+
past-the-end iterator. If no reallocation happens, they remain valid.
|
| 725 |
|
| 726 |
``` cpp
|
| 727 |
void clear() noexcept;
|
| 728 |
```
|
| 729 |
|
|
|
|
| 737 |
bool empty() const noexcept;
|
| 738 |
```
|
| 739 |
|
| 740 |
*Returns:* `size() == 0`.
|
| 741 |
|
| 742 |
+
#### `basic_string` element access <a id="string.access">[[string.access]]</a>
|
| 743 |
|
| 744 |
``` cpp
|
| 745 |
const_reference operator[](size_type pos) const;
|
| 746 |
reference operator[](size_type pos);
|
| 747 |
```
|
| 748 |
|
| 749 |
*Requires:* `pos <= size()`.
|
| 750 |
|
| 751 |
*Returns:* `*(begin() + pos)` if `pos < size()`. Otherwise, returns a
|
| 752 |
reference to an object of type `charT` with value `charT()`, where
|
| 753 |
+
modifying the object to any value other than `charT()` leads to
|
| 754 |
+
undefined behavior.
|
| 755 |
|
| 756 |
*Throws:* Nothing.
|
| 757 |
|
| 758 |
*Complexity:* Constant time.
|
| 759 |
|
|
|
|
| 769 |
``` cpp
|
| 770 |
const charT& front() const;
|
| 771 |
charT& front();
|
| 772 |
```
|
| 773 |
|
| 774 |
+
*Requires:* `!empty()`.
|
| 775 |
|
| 776 |
+
*Effects:* Equivalent to: `return operator[](0);`
|
| 777 |
|
| 778 |
``` cpp
|
| 779 |
const charT& back() const;
|
| 780 |
charT& back();
|
| 781 |
```
|
| 782 |
|
| 783 |
+
*Requires:* `!empty()`.
|
| 784 |
|
| 785 |
+
*Effects:* Equivalent to: `return operator[](size() - 1);`
|
| 786 |
|
| 787 |
+
#### `basic_string` modifiers <a id="string.modifiers">[[string.modifiers]]</a>
|
| 788 |
|
| 789 |
+
##### `basic_string::operator+=` <a id="string.op+=">[[string.op+=]]</a>
|
| 790 |
|
| 791 |
``` cpp
|
| 792 |
basic_string&
|
| 793 |
operator+=(const basic_string& str);
|
| 794 |
```
|
| 795 |
|
| 796 |
*Effects:* Calls `append(str)`.
|
| 797 |
|
| 798 |
*Returns:* `*this`.
|
| 799 |
|
| 800 |
+
``` cpp
|
| 801 |
+
basic_string& operator+=(basic_string_view<charT, traits> sv);
|
| 802 |
+
```
|
| 803 |
+
|
| 804 |
+
*Effects:* Calls `append(sv)`.
|
| 805 |
+
|
| 806 |
+
*Returns:* `*this`.
|
| 807 |
+
|
| 808 |
``` cpp
|
| 809 |
basic_string& operator+=(const charT* s);
|
| 810 |
```
|
| 811 |
|
| 812 |
*Effects:* Calls `append(s)`.
|
|
|
|
| 827 |
|
| 828 |
*Effects:* Calls `append(il)`.
|
| 829 |
|
| 830 |
*Returns:* `*this`.
|
| 831 |
|
| 832 |
+
##### `basic_string::append` <a id="string.append">[[string.append]]</a>
|
| 833 |
|
| 834 |
``` cpp
|
| 835 |
basic_string&
|
| 836 |
append(const basic_string& str);
|
| 837 |
```
|
|
|
|
| 843 |
``` cpp
|
| 844 |
basic_string&
|
| 845 |
append(const basic_string& str, size_type pos, size_type n = npos);
|
| 846 |
```
|
| 847 |
|
|
|
|
|
|
|
| 848 |
*Throws:* `out_of_range` if `pos > str.size()`.
|
| 849 |
|
| 850 |
*Effects:* Determines the effective length `rlen` of the string to
|
| 851 |
append as the smaller of `n` and `str``.size() - ``pos` and calls
|
| 852 |
`append(str.data() + pos, rlen)`.
|
| 853 |
|
| 854 |
*Returns:* `*this`.
|
| 855 |
|
| 856 |
+
``` cpp
|
| 857 |
+
basic_string& append(basic_string_view<charT, traits> sv);
|
| 858 |
+
```
|
| 859 |
+
|
| 860 |
+
*Effects:* Equivalent to: `return append(sv.data(), sv.size());`
|
| 861 |
+
|
| 862 |
+
``` cpp
|
| 863 |
+
template<class T>
|
| 864 |
+
basic_string& append(const T& t, size_type pos, size_type n = npos);
|
| 865 |
+
```
|
| 866 |
+
|
| 867 |
+
*Throws:* `out_of_range` if `pos > sv.size()`.
|
| 868 |
+
|
| 869 |
+
*Effects:* Creates a variable, `sv`, as if by
|
| 870 |
+
`basic_string_view<charT, traits> sv = t`. Determines the effective
|
| 871 |
+
length `rlen` of the string to append as the smaller of `n` and
|
| 872 |
+
`sv.size() - pos` and calls `append(sv.data() + pos, rlen)`.
|
| 873 |
+
|
| 874 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 875 |
+
unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
|
| 876 |
+
`true` and `is_convertible_v<const T&, const charT*>` is `false`.
|
| 877 |
+
|
| 878 |
+
*Returns:* `*this`.
|
| 879 |
+
|
| 880 |
``` cpp
|
| 881 |
basic_string&
|
| 882 |
append(const charT* s, size_type n);
|
| 883 |
```
|
| 884 |
|
|
|
|
| 917 |
basic_string& append(InputIterator first, InputIterator last);
|
| 918 |
```
|
| 919 |
|
| 920 |
*Requires:* \[`first`, `last`) is a valid range.
|
| 921 |
|
| 922 |
+
*Effects:* Equivalent to
|
| 923 |
+
`append(basic_string(first, last, get_allocator()))`.
|
| 924 |
|
| 925 |
*Returns:* `*this`.
|
| 926 |
|
| 927 |
``` cpp
|
| 928 |
basic_string& append(initializer_list<charT> il);
|
|
|
|
| 936 |
void push_back(charT c);
|
| 937 |
```
|
| 938 |
|
| 939 |
*Effects:* Equivalent to `append(static_cast<size_type>(1), c)`.
|
| 940 |
|
| 941 |
+
##### `basic_string::assign` <a id="string.assign">[[string.assign]]</a>
|
| 942 |
|
| 943 |
``` cpp
|
| 944 |
basic_string& assign(const basic_string& str);
|
| 945 |
```
|
| 946 |
|
| 947 |
+
*Effects:* Equivalent to `*this = str`.
|
| 948 |
|
| 949 |
*Returns:* `*this`.
|
| 950 |
|
| 951 |
``` cpp
|
| 952 |
+
basic_string& assign(basic_string&& str)
|
| 953 |
+
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
|
| 954 |
+
allocator_traits<Allocator>::is_always_equal::value);
|
| 955 |
```
|
| 956 |
|
| 957 |
+
*Effects:* Equivalent to `*this = std::move(str)`.
|
|
|
|
|
|
|
| 958 |
|
| 959 |
*Returns:* `*this`.
|
| 960 |
|
| 961 |
``` cpp
|
| 962 |
basic_string&
|
| 963 |
assign(const basic_string& str, size_type pos,
|
| 964 |
size_type n = npos);
|
| 965 |
```
|
| 966 |
|
|
|
|
|
|
|
| 967 |
*Throws:* `out_of_range` if `pos > str.size()`.
|
| 968 |
|
| 969 |
*Effects:* Determines the effective length `rlen` of the string to
|
| 970 |
assign as the smaller of `n` and `str``.size() - ``pos` and calls
|
| 971 |
+
`assign(str.data() + pos, rlen)`.
|
| 972 |
+
|
| 973 |
+
*Returns:* `*this`.
|
| 974 |
+
|
| 975 |
+
``` cpp
|
| 976 |
+
basic_string& assign(basic_string_view<charT, traits> sv);
|
| 977 |
+
```
|
| 978 |
+
|
| 979 |
+
*Effects:* Equivalent to: `return assign(sv.data(), sv.size());`
|
| 980 |
+
|
| 981 |
+
``` cpp
|
| 982 |
+
template<class T>
|
| 983 |
+
basic_string& assign(const T& t, size_type pos, size_type n = npos);
|
| 984 |
+
```
|
| 985 |
+
|
| 986 |
+
*Throws:* `out_of_range` if `pos > sv.size()`.
|
| 987 |
+
|
| 988 |
+
*Effects:* Creates a variable, `sv`, as if by
|
| 989 |
+
`basic_string_view<charT, traits> sv = t`. Determines the effective
|
| 990 |
+
length `rlen` of the string to assign as the smaller of `n` and
|
| 991 |
+
`sv.size() - pos` and calls `assign(sv.data() + pos, rlen)`.
|
| 992 |
+
|
| 993 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 994 |
+
unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
|
| 995 |
+
`true` and `is_convertible_v<const T&, const charT*>` is `false`.
|
| 996 |
|
| 997 |
*Returns:* `*this`.
|
| 998 |
|
| 999 |
``` cpp
|
| 1000 |
basic_string& assign(const charT* s, size_type n);
|
|
|
|
| 1039 |
``` cpp
|
| 1040 |
template<class InputIterator>
|
| 1041 |
basic_string& assign(InputIterator first, InputIterator last);
|
| 1042 |
```
|
| 1043 |
|
| 1044 |
+
*Effects:* Equivalent to
|
| 1045 |
+
`assign(basic_string(first, last, get_allocator()))`.
|
| 1046 |
|
| 1047 |
*Returns:* `*this`.
|
| 1048 |
|
| 1049 |
+
##### `basic_string::insert` <a id="string.insert">[[string.insert]]</a>
|
| 1050 |
|
| 1051 |
``` cpp
|
| 1052 |
basic_string&
|
| 1053 |
+
insert(size_type pos,
|
| 1054 |
const basic_string& str);
|
| 1055 |
```
|
| 1056 |
|
| 1057 |
+
*Effects:* Equivalent to: `return insert(pos, str.data(), str.size());`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1058 |
|
| 1059 |
``` cpp
|
| 1060 |
basic_string&
|
| 1061 |
insert(size_type pos1,
|
| 1062 |
const basic_string& str,
|
| 1063 |
size_type pos2, size_type n = npos);
|
| 1064 |
```
|
| 1065 |
|
|
|
|
|
|
|
| 1066 |
*Throws:* `out_of_range` if `pos1 > size()` or `pos2 > str.size()`.
|
| 1067 |
|
| 1068 |
*Effects:* Determines the effective length `rlen` of the string to
|
| 1069 |
insert as the smaller of `n` and `str.size() - pos2` and calls
|
| 1070 |
`insert(pos1, str.data() + pos2, rlen)`.
|
| 1071 |
|
| 1072 |
*Returns:* `*this`.
|
| 1073 |
|
| 1074 |
+
``` cpp
|
| 1075 |
+
basic_string& insert(size_type pos, basic_string_view<charT, traits> sv);
|
| 1076 |
+
```
|
| 1077 |
+
|
| 1078 |
+
*Effects:* Equivalent to: `return insert(pos, sv.data(), sv.size());`
|
| 1079 |
+
|
| 1080 |
+
``` cpp
|
| 1081 |
+
template<class T>
|
| 1082 |
+
basic_string& insert(size_type pos1, const T& t,
|
| 1083 |
+
size_type pos2, size_type n = npos);
|
| 1084 |
+
```
|
| 1085 |
+
|
| 1086 |
+
*Throws:* `out_of_range` if `pos1 > size()` or `pos2 > sv.size()`.
|
| 1087 |
+
|
| 1088 |
+
*Effects:* Creates a variable, `sv`, as if by
|
| 1089 |
+
`basic_string_view<charT, traits> sv = t`. Determines the effective
|
| 1090 |
+
length `rlen` of the string to assign as the smaller of `n` and
|
| 1091 |
+
`sv.size() - pos2` and calls `insert(pos1, sv.data() + pos2, rlen)`.
|
| 1092 |
+
|
| 1093 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 1094 |
+
unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
|
| 1095 |
+
`true` and `is_convertible_v<const T&, const charT*>` is `false`.
|
| 1096 |
+
|
| 1097 |
+
*Returns:* `*this`.
|
| 1098 |
+
|
| 1099 |
``` cpp
|
| 1100 |
basic_string&
|
| 1101 |
insert(size_type pos, const charT* s, size_type n);
|
| 1102 |
```
|
| 1103 |
|
| 1104 |
+
*Requires:* `s` points to an array of at least `n` elements of `charT`.
|
|
|
|
| 1105 |
|
| 1106 |
*Throws:* `out_of_range` if `pos > size()` or `length_error` if
|
| 1107 |
`size() + n > max_size()`.
|
| 1108 |
|
| 1109 |
*Effects:* Replaces the string controlled by `*this` with a string of
|
|
|
|
| 1118 |
``` cpp
|
| 1119 |
basic_string&
|
| 1120 |
insert(size_type pos, const charT* s);
|
| 1121 |
```
|
| 1122 |
|
| 1123 |
+
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1124 |
+
elements of `charT`.
|
| 1125 |
|
| 1126 |
+
*Effects:* Equivalent to: `return insert(pos, s, traits::length(s));`
|
|
|
|
|
|
|
| 1127 |
|
| 1128 |
``` cpp
|
| 1129 |
basic_string&
|
| 1130 |
insert(size_type pos, size_type n, charT c);
|
| 1131 |
```
|
|
|
|
| 1138 |
iterator insert(const_iterator p, charT c);
|
| 1139 |
```
|
| 1140 |
|
| 1141 |
*Requires:* `p` is a valid iterator on `*this`.
|
| 1142 |
|
| 1143 |
+
*Effects:* Inserts a copy of `c` before the character referred to by
|
| 1144 |
`p`.
|
| 1145 |
|
| 1146 |
*Returns:* An iterator which refers to the copy of the inserted
|
| 1147 |
character.
|
| 1148 |
|
|
|
|
| 1150 |
iterator insert(const_iterator p, size_type n, charT c);
|
| 1151 |
```
|
| 1152 |
|
| 1153 |
*Requires:* `p` is a valid iterator on `*this`.
|
| 1154 |
|
| 1155 |
+
*Effects:* Inserts `n` copies of `c` before the character referred to by
|
| 1156 |
`p`.
|
| 1157 |
|
| 1158 |
*Returns:* An iterator which refers to the copy of the first inserted
|
| 1159 |
character, or `p` if `n == 0`.
|
| 1160 |
|
|
|
|
| 1165 |
|
| 1166 |
*Requires:* `p` is a valid iterator on `*this`. `[first, last)` is a
|
| 1167 |
valid range.
|
| 1168 |
|
| 1169 |
*Effects:* Equivalent to
|
| 1170 |
+
`insert(p - begin(), basic_string(first, last, get_allocator()))`.
|
| 1171 |
|
| 1172 |
*Returns:* An iterator which refers to the copy of the first inserted
|
| 1173 |
character, or `p` if `first == last`.
|
| 1174 |
|
| 1175 |
``` cpp
|
| 1176 |
iterator insert(const_iterator p, initializer_list<charT> il);
|
| 1177 |
```
|
| 1178 |
|
| 1179 |
+
*Effects:* As if by `insert(p, il.begin(), il.end())`.
|
| 1180 |
|
| 1181 |
*Returns:* An iterator which refers to the copy of the first inserted
|
| 1182 |
character, or `p` if `i1` is empty.
|
| 1183 |
|
| 1184 |
+
##### `basic_string::erase` <a id="string.erase">[[string.erase]]</a>
|
| 1185 |
|
| 1186 |
``` cpp
|
| 1187 |
basic_string& erase(size_type pos = 0, size_type n = npos);
|
| 1188 |
```
|
| 1189 |
|
|
|
|
|
|
|
| 1190 |
*Throws:* `out_of_range` if `pos` `> size()`.
|
| 1191 |
|
| 1192 |
*Effects:* Determines the effective length `xlen` of the string to be
|
| 1193 |
removed as the smaller of `n` and `size() - pos`.
|
| 1194 |
|
|
|
|
| 1204 |
iterator erase(const_iterator p);
|
| 1205 |
```
|
| 1206 |
|
| 1207 |
*Throws:* Nothing.
|
| 1208 |
|
| 1209 |
+
*Effects:* Removes the character referred to by `p`.
|
| 1210 |
|
| 1211 |
*Returns:* An iterator which points to the element immediately following
|
| 1212 |
`p` prior to the element being erased. If no such element exists,
|
| 1213 |
`end()` is returned.
|
| 1214 |
|
|
|
|
| 1219 |
*Requires:* `first` and `last` are valid iterators on `*this`, defining
|
| 1220 |
a range `[first, last)`.
|
| 1221 |
|
| 1222 |
*Throws:* Nothing.
|
| 1223 |
|
| 1224 |
+
*Effects:* Removes the characters in the range `[first, last)`.
|
| 1225 |
|
| 1226 |
*Returns:* An iterator which points to the element pointed to by `last`
|
| 1227 |
prior to the other elements being erased. If no such element exists,
|
| 1228 |
`end()` is returned.
|
| 1229 |
|
| 1230 |
``` cpp
|
| 1231 |
void pop_back();
|
| 1232 |
```
|
| 1233 |
|
| 1234 |
+
*Requires:* `!empty()`.
|
| 1235 |
|
| 1236 |
*Throws:* Nothing.
|
| 1237 |
|
| 1238 |
*Effects:* Equivalent to `erase(size() - 1, 1)`.
|
| 1239 |
|
| 1240 |
+
##### `basic_string::replace` <a id="string.replace">[[string.replace]]</a>
|
| 1241 |
|
| 1242 |
``` cpp
|
| 1243 |
basic_string&
|
| 1244 |
replace(size_type pos1, size_type n1,
|
| 1245 |
const basic_string& str);
|
| 1246 |
```
|
| 1247 |
|
| 1248 |
+
*Effects:* Equivalent to:
|
| 1249 |
+
`return replace(pos1, n1, str.data(), str.size());`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1250 |
|
| 1251 |
``` cpp
|
| 1252 |
basic_string&
|
| 1253 |
replace(size_type pos1, size_type n1,
|
| 1254 |
const basic_string& str,
|
| 1255 |
size_type pos2, size_type n2 = npos);
|
| 1256 |
```
|
| 1257 |
|
|
|
|
|
|
|
| 1258 |
*Throws:* `out_of_range` if `pos1 > size()` or `pos2 > str.size()`.
|
| 1259 |
|
| 1260 |
*Effects:* Determines the effective length `rlen` of the string to be
|
| 1261 |
inserted as the smaller of `n2` and `str.size() - pos2` and calls
|
| 1262 |
`replace(pos1, n1, str.data() + pos2, rlen)`.
|
| 1263 |
|
| 1264 |
*Returns:* `*this`.
|
| 1265 |
|
| 1266 |
+
``` cpp
|
| 1267 |
+
basic_string& replace(size_type pos1, size_type n1,
|
| 1268 |
+
basic_string_view<charT, traits> sv);
|
| 1269 |
+
```
|
| 1270 |
+
|
| 1271 |
+
*Effects:* Equivalent to:
|
| 1272 |
+
`return replace(pos1, n1, sv.data(), sv.size());`
|
| 1273 |
+
|
| 1274 |
+
``` cpp
|
| 1275 |
+
template<class T>
|
| 1276 |
+
basic_string& replace(size_type pos1, size_type n1, const T& t,
|
| 1277 |
+
size_type pos2, size_type n2 = npos);
|
| 1278 |
+
```
|
| 1279 |
+
|
| 1280 |
+
*Throws:* `out_of_range` if `pos1 > size()` or `pos2 > sv.size()`.
|
| 1281 |
+
|
| 1282 |
+
*Effects:* Creates a variable, `sv`, as if by
|
| 1283 |
+
`basic_string_view<charT, traits> sv = t`. Determines the effective
|
| 1284 |
+
length `rlen` of the string to be inserted as the smaller of `n2` and
|
| 1285 |
+
`sv.size() - pos2` and calls
|
| 1286 |
+
`replace(pos1, n1, sv.data() + pos2, rlen)`.
|
| 1287 |
+
|
| 1288 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 1289 |
+
unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
|
| 1290 |
+
`true` and `is_convertible_v<const T&, const charT*>` is `false`.
|
| 1291 |
+
|
| 1292 |
+
*Returns:* `*this`.
|
| 1293 |
+
|
| 1294 |
``` cpp
|
| 1295 |
basic_string&
|
| 1296 |
replace(size_type pos1, size_type n1, const charT* s, size_type n2);
|
| 1297 |
```
|
| 1298 |
|
| 1299 |
+
*Requires:* `s` points to an array of at least `n2` elements of `charT`.
|
|
|
|
| 1300 |
|
| 1301 |
*Throws:* `out_of_range` if `pos1 > size()` or `length_error` if the
|
| 1302 |
length of the resulting string would exceed `max_size()` (see below).
|
| 1303 |
|
| 1304 |
*Effects:* Determines the effective length `xlen` of the string to be
|
|
|
|
| 1316 |
``` cpp
|
| 1317 |
basic_string&
|
| 1318 |
replace(size_type pos, size_type n, const charT* s);
|
| 1319 |
```
|
| 1320 |
|
| 1321 |
+
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1322 |
+
elements of `charT`.
|
| 1323 |
|
| 1324 |
+
*Effects:* Equivalent to:
|
| 1325 |
+
`return replace(pos, n, s, traits::length(s));`
|
|
|
|
| 1326 |
|
| 1327 |
``` cpp
|
| 1328 |
basic_string&
|
| 1329 |
replace(size_type pos1, size_type n1,
|
| 1330 |
size_type n2, charT c);
|
|
|
|
| 1342 |
|
| 1343 |
*Effects:* Calls `replace(i1 - begin(), i2 - i1, str)`.
|
| 1344 |
|
| 1345 |
*Returns:* `*this`.
|
| 1346 |
|
| 1347 |
+
``` cpp
|
| 1348 |
+
basic_string& replace(const_iterator i1, const_iterator i2,
|
| 1349 |
+
basic_string_view<charT, traits> sv);
|
| 1350 |
+
```
|
| 1351 |
+
|
| 1352 |
+
*Requires:* \[`begin()`, `i1`) and \[`i1`, `i2`) are valid ranges.
|
| 1353 |
+
|
| 1354 |
+
*Effects:* Calls `replace(i1 - begin(), i2 - i1, sv)`.
|
| 1355 |
+
|
| 1356 |
+
*Returns:* `*this`.
|
| 1357 |
+
|
| 1358 |
``` cpp
|
| 1359 |
basic_string&
|
| 1360 |
replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
|
| 1361 |
```
|
| 1362 |
|
|
|
|
| 1397 |
```
|
| 1398 |
|
| 1399 |
*Requires:* \[`begin()`, `i1`), \[`i1`, `i2`) and \[`j1`, `j2`) are
|
| 1400 |
valid ranges.
|
| 1401 |
|
| 1402 |
+
*Effects:* Calls
|
| 1403 |
+
`replace(i1 - begin(), i2 - i1, basic_string(j1, j2, get_allocator()))`.
|
| 1404 |
|
| 1405 |
*Returns:* `*this`.
|
| 1406 |
|
| 1407 |
``` cpp
|
| 1408 |
basic_string& replace(const_iterator i1, const_iterator i2,
|
|
|
|
| 1414 |
*Effects:* Calls
|
| 1415 |
`replace(i1 - begin(), i2 - i1, il.begin(), il.size())`.
|
| 1416 |
|
| 1417 |
*Returns:* `*this`.
|
| 1418 |
|
| 1419 |
+
##### `basic_string::copy` <a id="string.copy">[[string.copy]]</a>
|
| 1420 |
|
| 1421 |
``` cpp
|
| 1422 |
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
| 1423 |
```
|
| 1424 |
|
| 1425 |
+
Let `rlen` be the smaller of `n` and `size() - pos`.
|
| 1426 |
|
| 1427 |
*Throws:* `out_of_range` if `pos > size()`.
|
| 1428 |
|
| 1429 |
+
*Requires:* \[`s`, `s + rlen`) is a valid range.
|
|
|
|
|
|
|
| 1430 |
|
| 1431 |
+
*Effects:* Equivalent to: `traits::copy(s, data() + pos, rlen)`.
|
|
|
|
|
|
|
| 1432 |
|
| 1433 |
+
[*Note 1*: This does not terminate `s` with a null
|
| 1434 |
+
object. — *end note*]
|
| 1435 |
|
| 1436 |
*Returns:* `rlen`.
|
| 1437 |
|
| 1438 |
+
##### `basic_string::swap` <a id="string.swap">[[string.swap]]</a>
|
| 1439 |
|
| 1440 |
``` cpp
|
| 1441 |
+
void swap(basic_string& s)
|
| 1442 |
+
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
|
| 1443 |
+
allocator_traits<Allocator>::is_always_equal::value);
|
| 1444 |
```
|
| 1445 |
|
| 1446 |
+
*Postconditions:* `*this` contains the same sequence of characters that
|
| 1447 |
+
was in `s`, `s` contains the same sequence of characters that was in
|
| 1448 |
+
`*this`.
|
| 1449 |
|
| 1450 |
*Throws:* Nothing.
|
| 1451 |
|
| 1452 |
*Complexity:* Constant time.
|
| 1453 |
|
| 1454 |
+
#### `basic_string` string operations <a id="string.ops">[[string.ops]]</a>
|
| 1455 |
|
| 1456 |
+
##### `basic_string` accessors <a id="string.accessors">[[string.accessors]]</a>
|
| 1457 |
|
| 1458 |
``` cpp
|
| 1459 |
const charT* c_str() const noexcept;
|
| 1460 |
const charT* data() const noexcept;
|
| 1461 |
```
|
|
|
|
| 1466 |
*Complexity:* Constant time.
|
| 1467 |
|
| 1468 |
*Requires:* The program shall not alter any of the values stored in the
|
| 1469 |
character array.
|
| 1470 |
|
| 1471 |
+
``` cpp
|
| 1472 |
+
charT* data() noexcept;
|
| 1473 |
+
```
|
| 1474 |
+
|
| 1475 |
+
*Returns:* A pointer `p` such that `p + i == &operator[](i)` for each
|
| 1476 |
+
`i` in \[`0`, `size()`\].
|
| 1477 |
+
|
| 1478 |
+
*Complexity:* Constant time.
|
| 1479 |
+
|
| 1480 |
+
*Requires:* The program shall not alter the value stored at
|
| 1481 |
+
`p + size()`.
|
| 1482 |
+
|
| 1483 |
+
``` cpp
|
| 1484 |
+
operator basic_string_view<charT, traits>() const noexcept;
|
| 1485 |
+
```
|
| 1486 |
+
|
| 1487 |
+
*Effects:* Equivalent to:
|
| 1488 |
+
`return basic_string_view<charT, traits>(data(), size());`
|
| 1489 |
+
|
| 1490 |
``` cpp
|
| 1491 |
allocator_type get_allocator() const noexcept;
|
| 1492 |
```
|
| 1493 |
|
| 1494 |
*Returns:* A copy of the `Allocator` object used to construct the string
|
| 1495 |
or, if that allocator has been replaced, a copy of the most recent
|
| 1496 |
replacement.
|
| 1497 |
|
| 1498 |
+
##### `basic_string::find` <a id="string.find">[[string.find]]</a>
|
| 1499 |
|
| 1500 |
``` cpp
|
| 1501 |
+
size_type find(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
|
|
|
|
| 1502 |
```
|
| 1503 |
|
| 1504 |
*Effects:* Determines the lowest position `xpos`, if possible, such that
|
| 1505 |
+
both of the following conditions hold:
|
| 1506 |
|
| 1507 |
+
- `pos <= xpos` and `xpos + sv.size() <= size()`;
|
| 1508 |
+
- `traits::eq(at(xpos + I), sv.at(I))` for all elements `I` of the data
|
| 1509 |
+
referenced by `sv`.
|
| 1510 |
|
| 1511 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1512 |
Otherwise, returns `npos`.
|
| 1513 |
|
| 1514 |
+
``` cpp
|
| 1515 |
+
size_type find(const basic_string& str, size_type pos = 0) const noexcept;
|
| 1516 |
+
```
|
| 1517 |
+
|
| 1518 |
+
*Effects:* Equivalent to:
|
| 1519 |
+
`return find(basic_string_view<charT, traits>(str), pos);`
|
| 1520 |
|
| 1521 |
``` cpp
|
| 1522 |
size_type find(const charT* s, size_type pos, size_type n) const;
|
| 1523 |
```
|
| 1524 |
|
| 1525 |
+
*Returns:* `find(basic_string_view<charT, traits>(s, n), pos)`.
|
| 1526 |
|
| 1527 |
``` cpp
|
| 1528 |
size_type find(const charT* s, size_type pos = 0) const;
|
| 1529 |
```
|
| 1530 |
|
| 1531 |
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1532 |
elements of `charT`.
|
| 1533 |
|
| 1534 |
+
*Returns:* `find(basic_string_view<charT, traits>(s), pos)`.
|
| 1535 |
|
| 1536 |
``` cpp
|
| 1537 |
size_type find(charT c, size_type pos = 0) const;
|
| 1538 |
```
|
| 1539 |
|
| 1540 |
*Returns:* `find(basic_string(1, c), pos)`.
|
| 1541 |
|
| 1542 |
+
##### `basic_string::rfind` <a id="string.rfind">[[string.rfind]]</a>
|
| 1543 |
|
| 1544 |
``` cpp
|
| 1545 |
+
size_type rfind(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
|
|
|
|
| 1546 |
```
|
| 1547 |
|
| 1548 |
*Effects:* Determines the highest position `xpos`, if possible, such
|
| 1549 |
+
that both of the following conditions hold:
|
| 1550 |
|
| 1551 |
+
- `xpos <= pos` and `xpos + sv.size() <= size()`;
|
| 1552 |
+
- `traits::eq(at(xpos + I), sv.at(I))` for all elements `I` of the data
|
| 1553 |
+
referenced by `sv`.
|
| 1554 |
|
| 1555 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1556 |
Otherwise, returns `npos`.
|
| 1557 |
|
| 1558 |
+
``` cpp
|
| 1559 |
+
size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
|
| 1560 |
+
```
|
| 1561 |
+
|
| 1562 |
+
*Effects:* Equivalent to:
|
| 1563 |
+
`return rfind(basic_string_view<charT, traits>(str), pos);`
|
| 1564 |
|
| 1565 |
``` cpp
|
| 1566 |
size_type rfind(const charT* s, size_type pos, size_type n) const;
|
| 1567 |
```
|
| 1568 |
|
| 1569 |
+
*Returns:* `rfind(basic_string_view<charT, traits>(s, n), pos)`.
|
| 1570 |
|
| 1571 |
``` cpp
|
| 1572 |
size_type rfind(const charT* s, size_type pos = npos) const;
|
| 1573 |
```
|
| 1574 |
|
| 1575 |
+
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1576 |
elements of `charT`.
|
| 1577 |
|
| 1578 |
+
*Returns:* `rfind(basic_string_view<charT, traits>(s), pos)`.
|
| 1579 |
|
| 1580 |
``` cpp
|
| 1581 |
size_type rfind(charT c, size_type pos = npos) const;
|
| 1582 |
```
|
| 1583 |
|
| 1584 |
*Returns:* `rfind(basic_string(1, c), pos)`.
|
| 1585 |
|
| 1586 |
+
##### `basic_string::find_first_of` <a id="string.find.first.of">[[string.find.first.of]]</a>
|
| 1587 |
|
| 1588 |
``` cpp
|
| 1589 |
+
size_type find_first_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
|
|
|
|
|
|
|
| 1590 |
```
|
| 1591 |
|
| 1592 |
*Effects:* Determines the lowest position `xpos`, if possible, such that
|
| 1593 |
+
both of the following conditions hold:
|
| 1594 |
|
| 1595 |
- `pos <= xpos` and `xpos < size()`;
|
| 1596 |
+
- `traits::eq(at(xpos), sv.at(I))` for some element `I` of the data
|
| 1597 |
+
referenced by `sv`.
|
| 1598 |
|
| 1599 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1600 |
Otherwise, returns `npos`.
|
| 1601 |
|
| 1602 |
+
``` cpp
|
| 1603 |
+
size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;
|
| 1604 |
+
```
|
| 1605 |
+
|
| 1606 |
+
*Effects:* Equivalent to:
|
| 1607 |
+
`return find_first_of(basic_string_view<charT, traits>(str), pos);`
|
| 1608 |
|
| 1609 |
``` cpp
|
| 1610 |
+
size_type find_first_of(const charT* s, size_type pos, size_type n) const;
|
|
|
|
| 1611 |
```
|
| 1612 |
|
| 1613 |
+
*Returns:* `find_first_of(basic_string_view<charT, traits>(s, n), pos)`.
|
| 1614 |
|
| 1615 |
``` cpp
|
| 1616 |
size_type find_first_of(const charT* s, size_type pos = 0) const;
|
| 1617 |
```
|
| 1618 |
|
| 1619 |
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1620 |
elements of `charT`.
|
| 1621 |
|
| 1622 |
+
*Returns:* `find_first_of(basic_string_view<charT, traits>(s), pos)`.
|
| 1623 |
|
| 1624 |
``` cpp
|
| 1625 |
size_type find_first_of(charT c, size_type pos = 0) const;
|
| 1626 |
```
|
| 1627 |
|
| 1628 |
*Returns:* `find_first_of(basic_string(1, c), pos)`.
|
| 1629 |
|
| 1630 |
+
##### `basic_string::find_last_of` <a id="string.find.last.of">[[string.find.last.of]]</a>
|
| 1631 |
|
| 1632 |
``` cpp
|
| 1633 |
+
size_type find_last_of(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
|
|
|
|
|
|
|
| 1634 |
```
|
| 1635 |
|
| 1636 |
*Effects:* Determines the highest position `xpos`, if possible, such
|
| 1637 |
+
that both of the following conditions hold:
|
| 1638 |
|
| 1639 |
- `xpos <= pos` and `xpos < size()`;
|
| 1640 |
+
- `traits::eq(at(xpos), sv.at(I))` for some element `I` of the data
|
| 1641 |
+
referenced by `sv`.
|
| 1642 |
|
| 1643 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1644 |
Otherwise, returns `npos`.
|
| 1645 |
|
| 1646 |
+
``` cpp
|
| 1647 |
+
size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
|
| 1648 |
+
```
|
| 1649 |
+
|
| 1650 |
+
*Effects:* Equivalent to:
|
| 1651 |
+
`return find_last_of(basic_string_view<charT, traits>(str), pos);`
|
| 1652 |
|
| 1653 |
``` cpp
|
| 1654 |
size_type find_last_of(const charT* s, size_type pos, size_type n) const;
|
| 1655 |
```
|
| 1656 |
|
| 1657 |
+
*Returns:* `find_last_of(basic_string_view<charT, traits>(s, n), pos)`.
|
| 1658 |
|
| 1659 |
``` cpp
|
| 1660 |
size_type find_last_of(const charT* s, size_type pos = npos) const;
|
| 1661 |
```
|
| 1662 |
|
| 1663 |
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1664 |
elements of `charT`.
|
| 1665 |
|
| 1666 |
+
*Returns:* `find_last_of(basic_string_view<charT, traits>(s), pos)`.
|
| 1667 |
|
| 1668 |
``` cpp
|
| 1669 |
size_type find_last_of(charT c, size_type pos = npos) const;
|
| 1670 |
```
|
| 1671 |
|
| 1672 |
*Returns:* `find_last_of(basic_string(1, c), pos)`.
|
| 1673 |
|
| 1674 |
+
##### `basic_string::find_first_not_of` <a id="string.find.first.not.of">[[string.find.first.not.of]]</a>
|
| 1675 |
|
| 1676 |
``` cpp
|
| 1677 |
+
size_type find_first_not_of(basic_string_view<charT, traits> sv,
|
|
|
|
| 1678 |
size_type pos = 0) const noexcept;
|
| 1679 |
```
|
| 1680 |
|
| 1681 |
*Effects:* Determines the lowest position `xpos`, if possible, such that
|
| 1682 |
+
both of the following conditions hold:
|
| 1683 |
|
| 1684 |
- `pos <= xpos` and `xpos < size()`;
|
| 1685 |
+
- `traits::eq(at(xpos), sv.at(I))` for no element `I` of the data
|
| 1686 |
+
referenced by `sv`.
|
| 1687 |
|
| 1688 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1689 |
Otherwise, returns `npos`.
|
| 1690 |
|
| 1691 |
+
``` cpp
|
| 1692 |
+
size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept;
|
| 1693 |
+
```
|
| 1694 |
+
|
| 1695 |
+
*Effects:* Equivalent to:
|
| 1696 |
+
|
| 1697 |
+
``` cpp
|
| 1698 |
+
return find_first_not_of(basic_string_view<charT, traits>(str), pos);
|
| 1699 |
+
```
|
| 1700 |
|
| 1701 |
``` cpp
|
| 1702 |
+
size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
|
|
|
|
| 1703 |
```
|
| 1704 |
|
| 1705 |
+
*Returns:*
|
| 1706 |
+
`find_first_not_of(basic_string_view<charT, traits>(s, n), pos)`.
|
| 1707 |
|
| 1708 |
``` cpp
|
| 1709 |
size_type find_first_not_of(const charT* s, size_type pos = 0) const;
|
| 1710 |
```
|
| 1711 |
|
| 1712 |
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1713 |
elements of `charT`.
|
| 1714 |
|
| 1715 |
+
*Returns:*
|
| 1716 |
+
`find_first_not_of(basic_string_view<charT, traits>(s), pos)`.
|
| 1717 |
|
| 1718 |
``` cpp
|
| 1719 |
size_type find_first_not_of(charT c, size_type pos = 0) const;
|
| 1720 |
```
|
| 1721 |
|
| 1722 |
*Returns:* `find_first_not_of(basic_string(1, c), pos)`.
|
| 1723 |
|
| 1724 |
+
##### `basic_string::find_last_not_of` <a id="string.find.last.not.of">[[string.find.last.not.of]]</a>
|
| 1725 |
|
| 1726 |
``` cpp
|
| 1727 |
+
size_type find_last_not_of(basic_string_view<charT, traits> sv,
|
|
|
|
| 1728 |
size_type pos = npos) const noexcept;
|
| 1729 |
```
|
| 1730 |
|
| 1731 |
*Effects:* Determines the highest position `xpos`, if possible, such
|
| 1732 |
+
that both of the following conditions hold:
|
| 1733 |
|
| 1734 |
- `xpos <= pos` and `xpos < size()`;
|
| 1735 |
+
- `traits::eq(at(xpos), sv.at(I))` for no element `I` of the data
|
| 1736 |
+
referenced by `sv`.
|
| 1737 |
|
| 1738 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 1739 |
Otherwise, returns `npos`.
|
| 1740 |
|
| 1741 |
+
``` cpp
|
| 1742 |
+
size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
|
| 1743 |
+
```
|
| 1744 |
+
|
| 1745 |
+
*Effects:* Equivalent to:
|
| 1746 |
+
|
| 1747 |
+
``` cpp
|
| 1748 |
+
return find_last_not_of(basic_string_view<charT, traits>(str), pos);
|
| 1749 |
+
```
|
| 1750 |
|
| 1751 |
``` cpp
|
| 1752 |
+
size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
|
|
|
|
| 1753 |
```
|
| 1754 |
|
| 1755 |
+
*Returns:*
|
| 1756 |
+
`find_last_not_of(basic_string_view<charT, traits>(s, n), pos)`.
|
| 1757 |
|
| 1758 |
``` cpp
|
| 1759 |
size_type find_last_not_of(const charT* s, size_type pos = npos) const;
|
| 1760 |
```
|
| 1761 |
|
| 1762 |
*Requires:* `s` points to an array of at least `traits::length(s) + 1`
|
| 1763 |
elements of `charT`.
|
| 1764 |
|
| 1765 |
+
*Returns:* `find_last_not_of(basic_string_view<charT, traits>(s), pos)`.
|
| 1766 |
|
| 1767 |
``` cpp
|
| 1768 |
size_type find_last_not_of(charT c, size_type pos = npos) const;
|
| 1769 |
```
|
| 1770 |
|
| 1771 |
*Returns:* `find_last_not_of(basic_string(1, c), pos)`.
|
| 1772 |
|
| 1773 |
+
##### `basic_string::substr` <a id="string.substr">[[string.substr]]</a>
|
| 1774 |
|
| 1775 |
``` cpp
|
| 1776 |
basic_string substr(size_type pos = 0, size_type n = npos) const;
|
| 1777 |
```
|
| 1778 |
|
|
|
|
|
|
|
| 1779 |
*Throws:* `out_of_range` if `pos > size()`.
|
| 1780 |
|
| 1781 |
*Effects:* Determines the effective length `rlen` of the string to copy
|
| 1782 |
as the smaller of `n` and `size() - pos`.
|
| 1783 |
|
| 1784 |
*Returns:* `basic_string(data()+pos, rlen)`.
|
| 1785 |
|
| 1786 |
+
##### `basic_string::compare` <a id="string.compare">[[string.compare]]</a>
|
| 1787 |
|
| 1788 |
``` cpp
|
| 1789 |
+
int compare(basic_string_view<charT, traits> sv) const noexcept;
|
| 1790 |
```
|
| 1791 |
|
| 1792 |
+
*Effects:* Determines the effective length `rlen` of the strings to
|
| 1793 |
+
compare as the smaller of `size()` and `sv.size()`. The function then
|
| 1794 |
compares the two strings by calling
|
| 1795 |
+
`traits::compare(data(), sv.data(), rlen)`.
|
| 1796 |
|
| 1797 |
*Returns:* The nonzero result if the result of the comparison is
|
| 1798 |
nonzero. Otherwise, returns a value as indicated in
|
| 1799 |
Table [[tab:strings.compare]].
|
| 1800 |
|
| 1801 |
**Table: `compare()` results** <a id="tab:strings.compare">[tab:strings.compare]</a>
|
| 1802 |
|
| 1803 |
| Condition | Return Value |
|
| 1804 |
+
| --------------------- | ------------ |
|
| 1805 |
+
| `size() < sv.size()` | `< 0` |
|
| 1806 |
+
| `size() == sv.size()` | ` 0` |
|
| 1807 |
+
| `size() > sv.size()` | `> 0` |
|
| 1808 |
|
| 1809 |
``` cpp
|
| 1810 |
+
int compare(size_type pos1, size_type n1, basic_string_view<charT, traits> sv) const;
|
|
|
|
| 1811 |
```
|
| 1812 |
|
| 1813 |
+
*Effects:* Equivalent to:
|
| 1814 |
+
|
| 1815 |
+
``` cpp
|
| 1816 |
+
return basic_string_view<charT, traits>(data(), size()).substr(pos1, n1).compare(sv);
|
| 1817 |
+
```
|
| 1818 |
+
|
| 1819 |
+
``` cpp
|
| 1820 |
+
template<class T>
|
| 1821 |
+
int compare(size_type pos1, size_type n1, const T& t,
|
| 1822 |
+
size_type pos2, size_type n2 = npos) const;
|
| 1823 |
+
```
|
| 1824 |
+
|
| 1825 |
+
*Effects:* Equivalent to:
|
| 1826 |
+
|
| 1827 |
+
``` cpp
|
| 1828 |
+
basic_string_view<charT, traits> sv = t;
|
| 1829 |
+
return basic_string_view<charT, traits>(
|
| 1830 |
+
data(), size()).substr(pos1, n1).compare(sv.substr(pos2, n2));
|
| 1831 |
+
```
|
| 1832 |
+
|
| 1833 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 1834 |
+
unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
|
| 1835 |
+
`true` and `is_convertible_v<const T&, const charT*>` is `false`.
|
| 1836 |
+
|
| 1837 |
+
``` cpp
|
| 1838 |
+
int compare(const basic_string& str) const noexcept;
|
| 1839 |
+
```
|
| 1840 |
+
|
| 1841 |
+
*Effects:* Equivalent to:
|
| 1842 |
+
`return compare(basic_string_view<charT, traits>(str));`
|
| 1843 |
+
|
| 1844 |
+
``` cpp
|
| 1845 |
+
int compare(size_type pos1, size_type n1, const basic_string& str) const;
|
| 1846 |
+
```
|
| 1847 |
+
|
| 1848 |
+
*Effects:* Equivalent to:
|
| 1849 |
+
`return compare(pos1, n1, basic_string_view<charT, traits>(str));`
|
| 1850 |
|
| 1851 |
``` cpp
|
| 1852 |
int compare(size_type pos1, size_type n1,
|
| 1853 |
const basic_string& str,
|
| 1854 |
size_type pos2, size_type n2 = npos) const;
|
| 1855 |
```
|
| 1856 |
|
| 1857 |
+
*Effects:* Equivalent to:
|
| 1858 |
+
|
| 1859 |
+
``` cpp
|
| 1860 |
+
return compare(pos1, n1, basic_string_view<charT, traits>(str), pos2, n2);
|
| 1861 |
+
```
|
| 1862 |
|
| 1863 |
``` cpp
|
| 1864 |
int compare(const charT* s) const;
|
| 1865 |
```
|
| 1866 |
|
| 1867 |
*Returns:* `compare(basic_string(s))`.
|
| 1868 |
|
| 1869 |
``` cpp
|
| 1870 |
+
int compare(size_type pos, size_type n1, const charT* s) const;
|
|
|
|
| 1871 |
```
|
| 1872 |
|
| 1873 |
*Returns:* `basic_string(*this, pos, n1).compare(basic_string(s))`.
|
| 1874 |
|
| 1875 |
``` cpp
|
| 1876 |
+
int compare(size_type pos, size_type n1, const charT* s, size_type n2) const;
|
|
|
|
| 1877 |
```
|
| 1878 |
|
| 1879 |
*Returns:* `basic_string(*this, pos, n1).compare(basic_string(s, n2))`.
|
| 1880 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|