From Jason Turner

[string.modifiers]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp54jn62x_/{from.md → to.md} +172 -76
tmp/tmp54jn62x_/{from.md → to.md} RENAMED
@@ -1,18 +1,26 @@
1
- ### `basic_string` modifiers <a id="string.modifiers">[[string.modifiers]]</a>
2
 
3
- #### `basic_string::operator+=` <a id="string::op+=">[[string::op+=]]</a>
4
 
5
  ``` cpp
6
  basic_string&
7
  operator+=(const basic_string& str);
8
  ```
9
 
10
  *Effects:* Calls `append(str)`.
11
 
12
  *Returns:* `*this`.
13
 
 
 
 
 
 
 
 
 
14
  ``` cpp
15
  basic_string& operator+=(const charT* s);
16
  ```
17
 
18
  *Effects:* Calls `append(s)`.
@@ -33,11 +41,11 @@ basic_string& operator+=(initializer_list<charT> il);
33
 
34
  *Effects:* Calls `append(il)`.
35
 
36
  *Returns:* `*this`.
37
 
38
- #### `basic_string::append` <a id="string::append">[[string::append]]</a>
39
 
40
  ``` cpp
41
  basic_string&
42
  append(const basic_string& str);
43
  ```
@@ -49,20 +57,42 @@ basic_string&
49
  ``` cpp
50
  basic_string&
51
  append(const basic_string& str, size_type pos, size_type n = npos);
52
  ```
53
 
54
- *Requires:* `pos <= str.size()`
55
-
56
  *Throws:* `out_of_range` if `pos > str.size()`.
57
 
58
  *Effects:* Determines the effective length `rlen` of the string to
59
  append as the smaller of `n` and `str``.size() - ``pos` and calls
60
  `append(str.data() + pos, rlen)`.
61
 
62
  *Returns:* `*this`.
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  ``` cpp
65
  basic_string&
66
  append(const charT* s, size_type n);
67
  ```
68
 
@@ -101,11 +131,12 @@ template<class InputIterator>
101
  basic_string& append(InputIterator first, InputIterator last);
102
  ```
103
 
104
  *Requires:* \[`first`, `last`) is a valid range.
105
 
106
- *Effects:* Equivalent to `append(basic_string(first, last))`.
 
107
 
108
  *Returns:* `*this`.
109
 
110
  ``` cpp
111
  basic_string& append(initializer_list<charT> il);
@@ -119,43 +150,65 @@ basic_string& append(initializer_list<charT> il);
119
  void push_back(charT c);
120
  ```
121
 
122
  *Effects:* Equivalent to `append(static_cast<size_type>(1), c)`.
123
 
124
- #### `basic_string::assign` <a id="string::assign">[[string::assign]]</a>
125
 
126
  ``` cpp
127
  basic_string& assign(const basic_string& str);
128
  ```
129
 
130
- *Effects:* Equivalent to `assign(str, 0, npos)`.
131
 
132
  *Returns:* `*this`.
133
 
134
  ``` cpp
135
- basic_string& assign(basic_string&& str) noexcept;
 
 
136
  ```
137
 
138
- *Effects:* The function replaces the string controlled by `*this` with a
139
- string of length `str.size()` whose elements are a copy of the string
140
- controlled by `str`. A valid implementation is `swap(str)`.
141
 
142
  *Returns:* `*this`.
143
 
144
  ``` cpp
145
  basic_string&
146
  assign(const basic_string& str, size_type pos,
147
  size_type n = npos);
148
  ```
149
 
150
- *Requires:* `pos <= str.size()`
151
-
152
  *Throws:* `out_of_range` if `pos > str.size()`.
153
 
154
  *Effects:* Determines the effective length `rlen` of the string to
155
  assign as the smaller of `n` and `str``.size() - ``pos` and calls
156
- `assign(str.data() + pos rlen)`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  *Returns:* `*this`.
159
 
160
  ``` cpp
161
  basic_string& assign(const charT* s, size_type n);
@@ -200,54 +253,71 @@ basic_string& assign(size_type n, charT c);
200
  ``` cpp
201
  template<class InputIterator>
202
  basic_string& assign(InputIterator first, InputIterator last);
203
  ```
204
 
205
- *Effects:* Equivalent to `assign(basic_string(first, last))`.
 
206
 
207
  *Returns:* `*this`.
208
 
209
- #### `basic_string::insert` <a id="string::insert">[[string::insert]]</a>
210
 
211
  ``` cpp
212
  basic_string&
213
- insert(size_type pos1,
214
  const basic_string& str);
215
  ```
216
 
217
- *Requires:* `pos <= size()`.
218
-
219
- *Throws:* `out_of_range` if `pos > size()`.
220
-
221
- *Effects:* Calls `insert(pos, str.data(), str.size())`.
222
-
223
- *Returns:* `*this`.
224
 
225
  ``` cpp
226
  basic_string&
227
  insert(size_type pos1,
228
  const basic_string& str,
229
  size_type pos2, size_type n = npos);
230
  ```
231
 
232
- *Requires:* `pos1 <= size()` and `pos2 <= str.size()`
233
-
234
  *Throws:* `out_of_range` if `pos1 > size()` or `pos2 > str.size()`.
235
 
236
  *Effects:* Determines the effective length `rlen` of the string to
237
  insert as the smaller of `n` and `str.size() - pos2` and calls
238
  `insert(pos1, str.data() + pos2, rlen)`.
239
 
240
  *Returns:* `*this`.
241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  ``` cpp
243
  basic_string&
244
  insert(size_type pos, const charT* s, size_type n);
245
  ```
246
 
247
- *Requires:* `s` points to an array of at least `n` elements of `charT`
248
- and `pos <= size()`.
249
 
250
  *Throws:* `out_of_range` if `pos > size()` or `length_error` if
251
  `size() + n > max_size()`.
252
 
253
  *Effects:* Replaces the string controlled by `*this` with a string of
@@ -262,16 +332,14 @@ by `*this`.
262
  ``` cpp
263
  basic_string&
264
  insert(size_type pos, const charT* s);
265
  ```
266
 
267
- *Requires:* `pos <= size()` and `s` points to an array of at least
268
- `traits::length(s) + 1` elements of `charT`.
269
 
270
- *Effects:* Equivalent to `insert(pos, s, traits::length(s))`.
271
-
272
- *Returns:* `*this`.
273
 
274
  ``` cpp
275
  basic_string&
276
  insert(size_type pos, size_type n, charT c);
277
  ```
@@ -284,11 +352,11 @@ basic_string&
284
  iterator insert(const_iterator p, charT c);
285
  ```
286
 
287
  *Requires:* `p` is a valid iterator on `*this`.
288
 
289
- *Effects:* inserts a copy of `c` before the character referred to by
290
  `p`.
291
 
292
  *Returns:* An iterator which refers to the copy of the inserted
293
  character.
294
 
@@ -296,11 +364,11 @@ character.
296
  iterator insert(const_iterator p, size_type n, charT c);
297
  ```
298
 
299
  *Requires:* `p` is a valid iterator on `*this`.
300
 
301
- *Effects:* inserts `n` copies of `c` before the character referred to by
302
  `p`.
303
 
304
  *Returns:* An iterator which refers to the copy of the first inserted
305
  character, or `p` if `n == 0`.
306
 
@@ -311,32 +379,30 @@ template<class InputIterator>
311
 
312
  *Requires:* `p` is a valid iterator on `*this`. `[first, last)` is a
313
  valid range.
314
 
315
  *Effects:* Equivalent to
316
- `insert(p - begin(), basic_string(first, last))`.
317
 
318
  *Returns:* An iterator which refers to the copy of the first inserted
319
  character, or `p` if `first == last`.
320
 
321
  ``` cpp
322
  iterator insert(const_iterator p, initializer_list<charT> il);
323
  ```
324
 
325
- *Effects:* `insert(p, il.begin(), il.end())`.
326
 
327
  *Returns:* An iterator which refers to the copy of the first inserted
328
  character, or `p` if `i1` is empty.
329
 
330
- #### `basic_string::erase` <a id="string::erase">[[string::erase]]</a>
331
 
332
  ``` cpp
333
  basic_string& erase(size_type pos = 0, size_type n = npos);
334
  ```
335
 
336
- *Requires:* `pos` ` <= size()`
337
-
338
  *Throws:* `out_of_range` if `pos` `> size()`.
339
 
340
  *Effects:* Determines the effective length `xlen` of the string to be
341
  removed as the smaller of `n` and `size() - pos`.
342
 
@@ -352,11 +418,11 @@ string controlled by `*this` beginning at position `pos + xlen`.
352
  iterator erase(const_iterator p);
353
  ```
354
 
355
  *Throws:* Nothing.
356
 
357
- *Effects:* removes the character referred to by `p`.
358
 
359
  *Returns:* An iterator which points to the element immediately following
360
  `p` prior to the element being erased. If no such element exists,
361
  `end()` is returned.
362
 
@@ -367,66 +433,86 @@ iterator erase(const_iterator first, const_iterator last);
367
  *Requires:* `first` and `last` are valid iterators on `*this`, defining
368
  a range `[first, last)`.
369
 
370
  *Throws:* Nothing.
371
 
372
- *Effects:* removes the characters in the range `[first,last)`.
373
 
374
  *Returns:* An iterator which points to the element pointed to by `last`
375
  prior to the other elements being erased. If no such element exists,
376
  `end()` is returned.
377
 
378
  ``` cpp
379
  void pop_back();
380
  ```
381
 
382
- *Requires:* `!empty()`
383
 
384
  *Throws:* Nothing.
385
 
386
  *Effects:* Equivalent to `erase(size() - 1, 1)`.
387
 
388
- #### `basic_string::replace` <a id="string::replace">[[string::replace]]</a>
389
 
390
  ``` cpp
391
  basic_string&
392
  replace(size_type pos1, size_type n1,
393
  const basic_string& str);
394
  ```
395
 
396
- *Requires:* `pos1 <= size()`.
397
-
398
- *Throws:* `out_of_range` if `pos1 > size()`.
399
-
400
- *Effects:* Calls `replace(pos1, n1, str.data(), str.size())`.
401
-
402
- *Returns:* `*this`.
403
 
404
  ``` cpp
405
  basic_string&
406
  replace(size_type pos1, size_type n1,
407
  const basic_string& str,
408
  size_type pos2, size_type n2 = npos);
409
  ```
410
 
411
- *Requires:* `pos1 <= size()` and `pos2 <= str.size()`.
412
-
413
  *Throws:* `out_of_range` if `pos1 > size()` or `pos2 > str.size()`.
414
 
415
  *Effects:* Determines the effective length `rlen` of the string to be
416
  inserted as the smaller of `n2` and `str.size() - pos2` and calls
417
  `replace(pos1, n1, str.data() + pos2, rlen)`.
418
 
419
  *Returns:* `*this`.
420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  ``` cpp
422
  basic_string&
423
  replace(size_type pos1, size_type n1, const charT* s, size_type n2);
424
  ```
425
 
426
- *Requires:* `pos1 <= size()` and `s` points to an array of at least `n2`
427
- elements of `charT`.
428
 
429
  *Throws:* `out_of_range` if `pos1 > size()` or `length_error` if the
430
  length of the resulting string would exceed `max_size()` (see below).
431
 
432
  *Effects:* Determines the effective length `xlen` of the string to be
@@ -444,16 +530,15 @@ string controlled by `*this` beginning at position `pos + xlen`.
444
  ``` cpp
445
  basic_string&
446
  replace(size_type pos, size_type n, const charT* s);
447
  ```
448
 
449
- *Requires:* `pos <= size()` and `s` points to an array of at least
450
- `traits::length(s) + 1` elements of `charT`.
451
 
452
- *Effects:* Calls `replace(pos, n, s, traits::length(s))`.
453
-
454
- *Returns:* `*this`.
455
 
456
  ``` cpp
457
  basic_string&
458
  replace(size_type pos1, size_type n1,
459
  size_type n2, charT c);
@@ -471,10 +556,21 @@ basic_string& replace(const_iterator i1, const_iterator i2, const basic_string&
471
 
472
  *Effects:* Calls `replace(i1 - begin(), i2 - i1, str)`.
473
 
474
  *Returns:* `*this`.
475
 
 
 
 
 
 
 
 
 
 
 
 
476
  ``` cpp
477
  basic_string&
478
  replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
479
  ```
480
 
@@ -515,11 +611,12 @@ template<class InputIterator>
515
  ```
516
 
517
  *Requires:* \[`begin()`, `i1`), \[`i1`, `i2`) and \[`j1`, `j2`) are
518
  valid ranges.
519
 
520
- *Effects:* Calls `replace(i1 - begin(), i2 - i1, basic_string(j1, j2))`.
 
521
 
522
  *Returns:* `*this`.
523
 
524
  ``` cpp
525
  basic_string& replace(const_iterator i1, const_iterator i2,
@@ -531,41 +628,40 @@ basic_string& replace(const_iterator i1, const_iterator i2,
531
  *Effects:* Calls
532
  `replace(i1 - begin(), i2 - i1, il.begin(), il.size())`.
533
 
534
  *Returns:* `*this`.
535
 
536
- #### `basic_string::copy` <a id="string::copy">[[string::copy]]</a>
537
 
538
  ``` cpp
539
  size_type copy(charT* s, size_type n, size_type pos = 0) const;
540
  ```
541
 
542
- *Requires:* `pos <= size()`
543
 
544
  *Throws:* `out_of_range` if `pos > size()`.
545
 
546
- *Effects:* Determines the effective length `rlen` of the string to copy
547
- as the smaller of `n` and `size() - pos`. `s` shall designate an array
548
- of at least `rlen` elements.
549
 
550
- The function then replaces the string designated by `s` with a string of
551
- length `rlen` whose elements are a copy of the string controlled by
552
- `*this` beginning at position `pos`.
553
 
554
- The function does not append a null object to the string designated by
555
- `s`.
556
 
557
  *Returns:* `rlen`.
558
 
559
- #### `basic_string::swap` <a id="string::swap">[[string::swap]]</a>
560
 
561
  ``` cpp
562
- void swap(basic_string& s);
 
 
563
  ```
564
 
565
- `*this` contains the same sequence of characters that was in `s`, `s`
566
- contains the same sequence of characters that was in `*this`.
 
567
 
568
  *Throws:* Nothing.
569
 
570
  *Complexity:* Constant time.
571
 
 
1
+ #### `basic_string` modifiers <a id="string.modifiers">[[string.modifiers]]</a>
2
 
3
+ ##### `basic_string::operator+=` <a id="string.op+=">[[string.op+=]]</a>
4
 
5
  ``` cpp
6
  basic_string&
7
  operator+=(const basic_string& str);
8
  ```
9
 
10
  *Effects:* Calls `append(str)`.
11
 
12
  *Returns:* `*this`.
13
 
14
+ ``` cpp
15
+ basic_string& operator+=(basic_string_view<charT, traits> sv);
16
+ ```
17
+
18
+ *Effects:* Calls `append(sv)`.
19
+
20
+ *Returns:* `*this`.
21
+
22
  ``` cpp
23
  basic_string& operator+=(const charT* s);
24
  ```
25
 
26
  *Effects:* Calls `append(s)`.
 
41
 
42
  *Effects:* Calls `append(il)`.
43
 
44
  *Returns:* `*this`.
45
 
46
+ ##### `basic_string::append` <a id="string.append">[[string.append]]</a>
47
 
48
  ``` cpp
49
  basic_string&
50
  append(const basic_string& str);
51
  ```
 
57
  ``` cpp
58
  basic_string&
59
  append(const basic_string& str, size_type pos, size_type n = npos);
60
  ```
61
 
 
 
62
  *Throws:* `out_of_range` if `pos > str.size()`.
63
 
64
  *Effects:* Determines the effective length `rlen` of the string to
65
  append as the smaller of `n` and `str``.size() - ``pos` and calls
66
  `append(str.data() + pos, rlen)`.
67
 
68
  *Returns:* `*this`.
69
 
70
+ ``` cpp
71
+ basic_string& append(basic_string_view<charT, traits> sv);
72
+ ```
73
+
74
+ *Effects:* Equivalent to: `return append(sv.data(), sv.size());`
75
+
76
+ ``` cpp
77
+ template<class T>
78
+ basic_string& append(const T& t, size_type pos, size_type n = npos);
79
+ ```
80
+
81
+ *Throws:* `out_of_range` if `pos > sv.size()`.
82
+
83
+ *Effects:* Creates a variable, `sv`, as if by
84
+ `basic_string_view<charT, traits> sv = t`. Determines the effective
85
+ length `rlen` of the string to append as the smaller of `n` and
86
+ `sv.size() - pos` and calls `append(sv.data() + pos, rlen)`.
87
+
88
+ *Remarks:* This function shall not participate in overload resolution
89
+ unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
90
+ `true` and `is_convertible_v<const T&, const charT*>` is `false`.
91
+
92
+ *Returns:* `*this`.
93
+
94
  ``` cpp
95
  basic_string&
96
  append(const charT* s, size_type n);
97
  ```
98
 
 
131
  basic_string& append(InputIterator first, InputIterator last);
132
  ```
133
 
134
  *Requires:* \[`first`, `last`) is a valid range.
135
 
136
+ *Effects:* Equivalent to
137
+ `append(basic_string(first, last, get_allocator()))`.
138
 
139
  *Returns:* `*this`.
140
 
141
  ``` cpp
142
  basic_string& append(initializer_list<charT> il);
 
150
  void push_back(charT c);
151
  ```
152
 
153
  *Effects:* Equivalent to `append(static_cast<size_type>(1), c)`.
154
 
155
+ ##### `basic_string::assign` <a id="string.assign">[[string.assign]]</a>
156
 
157
  ``` cpp
158
  basic_string& assign(const basic_string& str);
159
  ```
160
 
161
+ *Effects:* Equivalent to `*this = str`.
162
 
163
  *Returns:* `*this`.
164
 
165
  ``` cpp
166
+ basic_string& assign(basic_string&& str)
167
+ noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
168
+ allocator_traits<Allocator>::is_always_equal::value);
169
  ```
170
 
171
+ *Effects:* Equivalent to `*this = std::move(str)`.
 
 
172
 
173
  *Returns:* `*this`.
174
 
175
  ``` cpp
176
  basic_string&
177
  assign(const basic_string& str, size_type pos,
178
  size_type n = npos);
179
  ```
180
 
 
 
181
  *Throws:* `out_of_range` if `pos > str.size()`.
182
 
183
  *Effects:* Determines the effective length `rlen` of the string to
184
  assign as the smaller of `n` and `str``.size() - ``pos` and calls
185
+ `assign(str.data() + pos, rlen)`.
186
+
187
+ *Returns:* `*this`.
188
+
189
+ ``` cpp
190
+ basic_string& assign(basic_string_view<charT, traits> sv);
191
+ ```
192
+
193
+ *Effects:* Equivalent to: `return assign(sv.data(), sv.size());`
194
+
195
+ ``` cpp
196
+ template<class T>
197
+ basic_string& assign(const T& t, size_type pos, size_type n = npos);
198
+ ```
199
+
200
+ *Throws:* `out_of_range` if `pos > sv.size()`.
201
+
202
+ *Effects:* Creates a variable, `sv`, as if by
203
+ `basic_string_view<charT, traits> sv = t`. Determines the effective
204
+ length `rlen` of the string to assign as the smaller of `n` and
205
+ `sv.size() - pos` and calls `assign(sv.data() + pos, rlen)`.
206
+
207
+ *Remarks:* This function shall not participate in overload resolution
208
+ unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
209
+ `true` and `is_convertible_v<const T&, const charT*>` is `false`.
210
 
211
  *Returns:* `*this`.
212
 
213
  ``` cpp
214
  basic_string& assign(const charT* s, size_type n);
 
253
  ``` cpp
254
  template<class InputIterator>
255
  basic_string& assign(InputIterator first, InputIterator last);
256
  ```
257
 
258
+ *Effects:* Equivalent to
259
+ `assign(basic_string(first, last, get_allocator()))`.
260
 
261
  *Returns:* `*this`.
262
 
263
+ ##### `basic_string::insert` <a id="string.insert">[[string.insert]]</a>
264
 
265
  ``` cpp
266
  basic_string&
267
+ insert(size_type pos,
268
  const basic_string& str);
269
  ```
270
 
271
+ *Effects:* Equivalent to: `return insert(pos, str.data(), str.size());`
 
 
 
 
 
 
272
 
273
  ``` cpp
274
  basic_string&
275
  insert(size_type pos1,
276
  const basic_string& str,
277
  size_type pos2, size_type n = npos);
278
  ```
279
 
 
 
280
  *Throws:* `out_of_range` if `pos1 > size()` or `pos2 > str.size()`.
281
 
282
  *Effects:* Determines the effective length `rlen` of the string to
283
  insert as the smaller of `n` and `str.size() - pos2` and calls
284
  `insert(pos1, str.data() + pos2, rlen)`.
285
 
286
  *Returns:* `*this`.
287
 
288
+ ``` cpp
289
+ basic_string& insert(size_type pos, basic_string_view<charT, traits> sv);
290
+ ```
291
+
292
+ *Effects:* Equivalent to: `return insert(pos, sv.data(), sv.size());`
293
+
294
+ ``` cpp
295
+ template<class T>
296
+ basic_string& insert(size_type pos1, const T& t,
297
+ size_type pos2, size_type n = npos);
298
+ ```
299
+
300
+ *Throws:* `out_of_range` if `pos1 > size()` or `pos2 > sv.size()`.
301
+
302
+ *Effects:* Creates a variable, `sv`, as if by
303
+ `basic_string_view<charT, traits> sv = t`. Determines the effective
304
+ length `rlen` of the string to assign as the smaller of `n` and
305
+ `sv.size() - pos2` and calls `insert(pos1, sv.data() + pos2, rlen)`.
306
+
307
+ *Remarks:* This function shall not participate in overload resolution
308
+ unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
309
+ `true` and `is_convertible_v<const T&, const charT*>` is `false`.
310
+
311
+ *Returns:* `*this`.
312
+
313
  ``` cpp
314
  basic_string&
315
  insert(size_type pos, const charT* s, size_type n);
316
  ```
317
 
318
+ *Requires:* `s` points to an array of at least `n` elements of `charT`.
 
319
 
320
  *Throws:* `out_of_range` if `pos > size()` or `length_error` if
321
  `size() + n > max_size()`.
322
 
323
  *Effects:* Replaces the string controlled by `*this` with a string of
 
332
  ``` cpp
333
  basic_string&
334
  insert(size_type pos, const charT* s);
335
  ```
336
 
337
+ *Requires:* `s` points to an array of at least `traits::length(s) + 1`
338
+ elements of `charT`.
339
 
340
+ *Effects:* Equivalent to: `return insert(pos, s, traits::length(s));`
 
 
341
 
342
  ``` cpp
343
  basic_string&
344
  insert(size_type pos, size_type n, charT c);
345
  ```
 
352
  iterator insert(const_iterator p, charT c);
353
  ```
354
 
355
  *Requires:* `p` is a valid iterator on `*this`.
356
 
357
+ *Effects:* Inserts a copy of `c` before the character referred to by
358
  `p`.
359
 
360
  *Returns:* An iterator which refers to the copy of the inserted
361
  character.
362
 
 
364
  iterator insert(const_iterator p, size_type n, charT c);
365
  ```
366
 
367
  *Requires:* `p` is a valid iterator on `*this`.
368
 
369
+ *Effects:* Inserts `n` copies of `c` before the character referred to by
370
  `p`.
371
 
372
  *Returns:* An iterator which refers to the copy of the first inserted
373
  character, or `p` if `n == 0`.
374
 
 
379
 
380
  *Requires:* `p` is a valid iterator on `*this`. `[first, last)` is a
381
  valid range.
382
 
383
  *Effects:* Equivalent to
384
+ `insert(p - begin(), basic_string(first, last, get_allocator()))`.
385
 
386
  *Returns:* An iterator which refers to the copy of the first inserted
387
  character, or `p` if `first == last`.
388
 
389
  ``` cpp
390
  iterator insert(const_iterator p, initializer_list<charT> il);
391
  ```
392
 
393
+ *Effects:* As if by `insert(p, il.begin(), il.end())`.
394
 
395
  *Returns:* An iterator which refers to the copy of the first inserted
396
  character, or `p` if `i1` is empty.
397
 
398
+ ##### `basic_string::erase` <a id="string.erase">[[string.erase]]</a>
399
 
400
  ``` cpp
401
  basic_string& erase(size_type pos = 0, size_type n = npos);
402
  ```
403
 
 
 
404
  *Throws:* `out_of_range` if `pos` `> size()`.
405
 
406
  *Effects:* Determines the effective length `xlen` of the string to be
407
  removed as the smaller of `n` and `size() - pos`.
408
 
 
418
  iterator erase(const_iterator p);
419
  ```
420
 
421
  *Throws:* Nothing.
422
 
423
+ *Effects:* Removes the character referred to by `p`.
424
 
425
  *Returns:* An iterator which points to the element immediately following
426
  `p` prior to the element being erased. If no such element exists,
427
  `end()` is returned.
428
 
 
433
  *Requires:* `first` and `last` are valid iterators on `*this`, defining
434
  a range `[first, last)`.
435
 
436
  *Throws:* Nothing.
437
 
438
+ *Effects:* Removes the characters in the range `[first, last)`.
439
 
440
  *Returns:* An iterator which points to the element pointed to by `last`
441
  prior to the other elements being erased. If no such element exists,
442
  `end()` is returned.
443
 
444
  ``` cpp
445
  void pop_back();
446
  ```
447
 
448
+ *Requires:* `!empty()`.
449
 
450
  *Throws:* Nothing.
451
 
452
  *Effects:* Equivalent to `erase(size() - 1, 1)`.
453
 
454
+ ##### `basic_string::replace` <a id="string.replace">[[string.replace]]</a>
455
 
456
  ``` cpp
457
  basic_string&
458
  replace(size_type pos1, size_type n1,
459
  const basic_string& str);
460
  ```
461
 
462
+ *Effects:* Equivalent to:
463
+ `return replace(pos1, n1, str.data(), str.size());`
 
 
 
 
 
464
 
465
  ``` cpp
466
  basic_string&
467
  replace(size_type pos1, size_type n1,
468
  const basic_string& str,
469
  size_type pos2, size_type n2 = npos);
470
  ```
471
 
 
 
472
  *Throws:* `out_of_range` if `pos1 > size()` or `pos2 > str.size()`.
473
 
474
  *Effects:* Determines the effective length `rlen` of the string to be
475
  inserted as the smaller of `n2` and `str.size() - pos2` and calls
476
  `replace(pos1, n1, str.data() + pos2, rlen)`.
477
 
478
  *Returns:* `*this`.
479
 
480
+ ``` cpp
481
+ basic_string& replace(size_type pos1, size_type n1,
482
+ basic_string_view<charT, traits> sv);
483
+ ```
484
+
485
+ *Effects:* Equivalent to:
486
+ `return replace(pos1, n1, sv.data(), sv.size());`
487
+
488
+ ``` cpp
489
+ template<class T>
490
+ basic_string& replace(size_type pos1, size_type n1, const T& t,
491
+ size_type pos2, size_type n2 = npos);
492
+ ```
493
+
494
+ *Throws:* `out_of_range` if `pos1 > size()` or `pos2 > sv.size()`.
495
+
496
+ *Effects:* Creates a variable, `sv`, as if by
497
+ `basic_string_view<charT, traits> sv = t`. Determines the effective
498
+ length `rlen` of the string to be inserted as the smaller of `n2` and
499
+ `sv.size() - pos2` and calls
500
+ `replace(pos1, n1, sv.data() + pos2, rlen)`.
501
+
502
+ *Remarks:* This function shall not participate in overload resolution
503
+ unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
504
+ `true` and `is_convertible_v<const T&, const charT*>` is `false`.
505
+
506
+ *Returns:* `*this`.
507
+
508
  ``` cpp
509
  basic_string&
510
  replace(size_type pos1, size_type n1, const charT* s, size_type n2);
511
  ```
512
 
513
+ *Requires:* `s` points to an array of at least `n2` elements of `charT`.
 
514
 
515
  *Throws:* `out_of_range` if `pos1 > size()` or `length_error` if the
516
  length of the resulting string would exceed `max_size()` (see below).
517
 
518
  *Effects:* Determines the effective length `xlen` of the string to be
 
530
  ``` cpp
531
  basic_string&
532
  replace(size_type pos, size_type n, const charT* s);
533
  ```
534
 
535
+ *Requires:* `s` points to an array of at least `traits::length(s) + 1`
536
+ elements of `charT`.
537
 
538
+ *Effects:* Equivalent to:
539
+ `return replace(pos, n, s, traits::length(s));`
 
540
 
541
  ``` cpp
542
  basic_string&
543
  replace(size_type pos1, size_type n1,
544
  size_type n2, charT c);
 
556
 
557
  *Effects:* Calls `replace(i1 - begin(), i2 - i1, str)`.
558
 
559
  *Returns:* `*this`.
560
 
561
+ ``` cpp
562
+ basic_string& replace(const_iterator i1, const_iterator i2,
563
+ basic_string_view<charT, traits> sv);
564
+ ```
565
+
566
+ *Requires:* \[`begin()`, `i1`) and \[`i1`, `i2`) are valid ranges.
567
+
568
+ *Effects:* Calls `replace(i1 - begin(), i2 - i1, sv)`.
569
+
570
+ *Returns:* `*this`.
571
+
572
  ``` cpp
573
  basic_string&
574
  replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
575
  ```
576
 
 
611
  ```
612
 
613
  *Requires:* \[`begin()`, `i1`), \[`i1`, `i2`) and \[`j1`, `j2`) are
614
  valid ranges.
615
 
616
+ *Effects:* Calls
617
+ `replace(i1 - begin(), i2 - i1, basic_string(j1, j2, get_allocator()))`.
618
 
619
  *Returns:* `*this`.
620
 
621
  ``` cpp
622
  basic_string& replace(const_iterator i1, const_iterator i2,
 
628
  *Effects:* Calls
629
  `replace(i1 - begin(), i2 - i1, il.begin(), il.size())`.
630
 
631
  *Returns:* `*this`.
632
 
633
+ ##### `basic_string::copy` <a id="string.copy">[[string.copy]]</a>
634
 
635
  ``` cpp
636
  size_type copy(charT* s, size_type n, size_type pos = 0) const;
637
  ```
638
 
639
+ Let `rlen` be the smaller of `n` and `size() - pos`.
640
 
641
  *Throws:* `out_of_range` if `pos > size()`.
642
 
643
+ *Requires:* \[`s`, `s + rlen`) is a valid range.
 
 
644
 
645
+ *Effects:* Equivalent to: `traits::copy(s, data() + pos, rlen)`.
 
 
646
 
647
+ [*Note 1*: This does not terminate `s` with a null
648
+ object. — *end note*]
649
 
650
  *Returns:* `rlen`.
651
 
652
+ ##### `basic_string::swap` <a id="string.swap">[[string.swap]]</a>
653
 
654
  ``` cpp
655
+ void swap(basic_string& s)
656
+ noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
657
+ allocator_traits<Allocator>::is_always_equal::value);
658
  ```
659
 
660
+ *Postconditions:* `*this` contains the same sequence of characters that
661
+ was in `s`, `s` contains the same sequence of characters that was in
662
+ `*this`.
663
 
664
  *Throws:* Nothing.
665
 
666
  *Complexity:* Constant time.
667