From Jason Turner

[string.modifiers]

Diff to HTML by rtfpessoa

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