From Jason Turner

[string.ops]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp94ybq_65/{from.md → to.md} +124 -298
tmp/tmp94ybq_65/{from.md → to.md} RENAMED
@@ -1,328 +1,120 @@
1
- #### `basic_string` string operations <a id="string.ops">[[string.ops]]</a>
2
 
3
- ##### `basic_string` accessors <a id="string.accessors">[[string.accessors]]</a>
4
 
5
  ``` cpp
6
- const charT* c_str() const noexcept;
7
- const charT* data() const noexcept;
8
  ```
9
 
10
- *Returns:* A pointer `p` such that `p + i == &operator[](i)` for each
11
- `i` in \[`0`, `size()`\].
12
 
13
  *Complexity:* Constant time.
14
 
15
- *Requires:* The program shall not alter any of the values stored in the
16
- character array.
17
 
18
  ``` cpp
19
- charT* data() noexcept;
20
  ```
21
 
22
- *Returns:* A pointer `p` such that `p + i == &operator[](i)` for each
23
- `i` in \[`0`, `size()`\].
24
 
25
  *Complexity:* Constant time.
26
 
27
- *Requires:* The program shall not alter the value stored at
28
- `p + size()`.
29
 
30
  ``` cpp
31
- operator basic_string_view<charT, traits>() const noexcept;
32
  ```
33
 
34
  *Effects:* Equivalent to:
35
  `return basic_string_view<charT, traits>(data(), size());`
36
 
37
  ``` cpp
38
- allocator_type get_allocator() const noexcept;
39
  ```
40
 
41
  *Returns:* A copy of the `Allocator` object used to construct the string
42
  or, if that allocator has been replaced, a copy of the most recent
43
  replacement.
44
 
45
- ##### `basic_string::find` <a id="string.find">[[string.find]]</a>
46
 
47
- ``` cpp
48
- size_type find(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
49
- ```
50
-
51
- *Effects:* Determines the lowest position `xpos`, if possible, such that
52
- both of the following conditions hold:
53
-
54
- - `pos <= xpos` and `xpos + sv.size() <= size()`;
55
- - `traits::eq(at(xpos + I), sv.at(I))` for all elements `I` of the data
56
- referenced by `sv`.
57
-
58
- *Returns:* `xpos` if the function can determine such a value for `xpos`.
59
- Otherwise, returns `npos`.
60
-
61
- ``` cpp
62
- size_type find(const basic_string& str, size_type pos = 0) const noexcept;
63
- ```
64
-
65
- *Effects:* Equivalent to:
66
- `return find(basic_string_view<charT, traits>(str), pos);`
67
-
68
- ``` cpp
69
- size_type find(const charT* s, size_type pos, size_type n) const;
70
- ```
71
-
72
- *Returns:* `find(basic_string_view<charT, traits>(s, n), pos)`.
73
-
74
- ``` cpp
75
- size_type find(const charT* s, size_type pos = 0) const;
76
- ```
77
-
78
- *Requires:* `s` points to an array of at least `traits::length(s) + 1`
79
- elements of `charT`.
80
-
81
- *Returns:* `find(basic_string_view<charT, traits>(s), pos)`.
82
-
83
- ``` cpp
84
- size_type find(charT c, size_type pos = 0) const;
85
- ```
86
-
87
- *Returns:* `find(basic_string(1, c), pos)`.
88
-
89
- ##### `basic_string::rfind` <a id="string.rfind">[[string.rfind]]</a>
90
-
91
- ``` cpp
92
- size_type rfind(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
93
- ```
94
-
95
- *Effects:* Determines the highest position `xpos`, if possible, such
96
- that both of the following conditions hold:
97
-
98
- - `xpos <= pos` and `xpos + sv.size() <= size()`;
99
- - `traits::eq(at(xpos + I), sv.at(I))` for all elements `I` of the data
100
- referenced by `sv`.
101
-
102
- *Returns:* `xpos` if the function can determine such a value for `xpos`.
103
- Otherwise, returns `npos`.
104
-
105
- ``` cpp
106
- size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
107
- ```
108
-
109
- *Effects:* Equivalent to:
110
- `return rfind(basic_string_view<charT, traits>(str), pos);`
111
-
112
- ``` cpp
113
- size_type rfind(const charT* s, size_type pos, size_type n) const;
114
- ```
115
-
116
- *Returns:* `rfind(basic_string_view<charT, traits>(s, n), pos)`.
117
 
 
118
  ``` cpp
119
- size_type rfind(const charT* s, size_type pos = npos) const;
120
  ```
121
 
122
- *Requires:* `s` points to an array of at least `traits::length(s) + 1`
123
- elements of `charT`.
124
-
125
- *Returns:* `rfind(basic_string_view<charT, traits>(s), pos)`.
126
-
127
  ``` cpp
128
- size_type rfind(charT c, size_type pos = npos) const;
129
  ```
130
 
131
- *Returns:* `rfind(basic_string(1, c), pos)`.
132
-
133
- ##### `basic_string::find_first_of` <a id="string.find.first.of">[[string.find.first.of]]</a>
134
-
135
  ``` cpp
136
- size_type find_first_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
137
  ```
138
 
139
- *Effects:* Determines the lowest position `xpos`, if possible, such that
140
- both of the following conditions hold:
141
-
142
- - `pos <= xpos` and `xpos < size()`;
143
- - `traits::eq(at(xpos), sv.at(I))` for some element `I` of the data
144
- referenced by `sv`.
145
-
146
- *Returns:* `xpos` if the function can determine such a value for `xpos`.
147
- Otherwise, returns `npos`.
148
-
149
  ``` cpp
150
- size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;
151
  ```
152
 
153
- *Effects:* Equivalent to:
154
- `return find_first_of(basic_string_view<charT, traits>(str), pos);`
155
-
156
  ``` cpp
157
- size_type find_first_of(const charT* s, size_type pos, size_type n) const;
158
  ```
159
 
160
- *Returns:* `find_first_of(basic_string_view<charT, traits>(s, n), pos)`.
161
-
162
- ``` cpp
163
- size_type find_first_of(const charT* s, size_type pos = 0) const;
164
- ```
165
-
166
- *Requires:* `s` points to an array of at least `traits::length(s) + 1`
167
- elements of `charT`.
168
-
169
- *Returns:* `find_first_of(basic_string_view<charT, traits>(s), pos)`.
170
-
171
- ``` cpp
172
- size_type find_first_of(charT c, size_type pos = 0) const;
173
- ```
174
-
175
- *Returns:* `find_first_of(basic_string(1, c), pos)`.
176
-
177
- ##### `basic_string::find_last_of` <a id="string.find.last.of">[[string.find.last.of]]</a>
178
-
179
- ``` cpp
180
- size_type find_last_of(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
181
- ```
182
-
183
- *Effects:* Determines the highest position `xpos`, if possible, such
184
- that both of the following conditions hold:
185
-
186
- - `xpos <= pos` and `xpos < size()`;
187
- - `traits::eq(at(xpos), sv.at(I))` for some element `I` of the data
188
- referenced by `sv`.
189
-
190
- *Returns:* `xpos` if the function can determine such a value for `xpos`.
191
- Otherwise, returns `npos`.
192
-
193
  ``` cpp
194
- size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
 
 
 
 
 
 
 
 
 
 
 
195
  ```
196
 
197
- *Effects:* Equivalent to:
198
- `return find_last_of(basic_string_view<charT, traits>(str), pos);`
199
-
200
- ``` cpp
201
- size_type find_last_of(const charT* s, size_type pos, size_type n) const;
202
- ```
203
-
204
- *Returns:* `find_last_of(basic_string_view<charT, traits>(s, n), pos)`.
205
-
206
- ``` cpp
207
- size_type find_last_of(const charT* s, size_type pos = npos) const;
208
- ```
209
-
210
- *Requires:* `s` points to an array of at least `traits::length(s) + 1`
211
- elements of `charT`.
212
-
213
- *Returns:* `find_last_of(basic_string_view<charT, traits>(s), pos)`.
214
-
215
- ``` cpp
216
- size_type find_last_of(charT c, size_type pos = npos) const;
217
- ```
218
-
219
- *Returns:* `find_last_of(basic_string(1, c), pos)`.
220
-
221
- ##### `basic_string::find_first_not_of` <a id="string.find.first.not.of">[[string.find.first.not.of]]</a>
222
-
223
- ``` cpp
224
- size_type find_first_not_of(basic_string_view<charT, traits> sv,
225
- size_type pos = 0) const noexcept;
226
- ```
227
-
228
- *Effects:* Determines the lowest position `xpos`, if possible, such that
229
- both of the following conditions hold:
230
-
231
- - `pos <= xpos` and `xpos < size()`;
232
- - `traits::eq(at(xpos), sv.at(I))` for no element `I` of the data
233
- referenced by `sv`.
234
-
235
- *Returns:* `xpos` if the function can determine such a value for `xpos`.
236
- Otherwise, returns `npos`.
237
-
238
- ``` cpp
239
- size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept;
240
- ```
241
-
242
- *Effects:* Equivalent to:
243
-
244
- ``` cpp
245
- return find_first_not_of(basic_string_view<charT, traits>(str), pos);
246
- ```
247
-
248
- ``` cpp
249
- size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
250
- ```
251
-
252
- *Returns:*
253
- `find_first_not_of(basic_string_view<charT, traits>(s, n), pos)`.
254
-
255
- ``` cpp
256
- size_type find_first_not_of(const charT* s, size_type pos = 0) const;
257
- ```
258
-
259
- *Requires:* `s` points to an array of at least `traits::length(s) + 1`
260
- elements of `charT`.
261
-
262
- *Returns:*
263
- `find_first_not_of(basic_string_view<charT, traits>(s), pos)`.
264
-
265
- ``` cpp
266
- size_type find_first_not_of(charT c, size_type pos = 0) const;
267
- ```
268
-
269
- *Returns:* `find_first_not_of(basic_string(1, c), pos)`.
270
-
271
- ##### `basic_string::find_last_not_of` <a id="string.find.last.not.of">[[string.find.last.not.of]]</a>
272
-
273
- ``` cpp
274
- size_type find_last_not_of(basic_string_view<charT, traits> sv,
275
- size_type pos = npos) const noexcept;
276
- ```
277
-
278
- *Effects:* Determines the highest position `xpos`, if possible, such
279
- that both of the following conditions hold:
280
-
281
- - `xpos <= pos` and `xpos < size()`;
282
- - `traits::eq(at(xpos), sv.at(I))` for no element `I` of the data
283
- referenced by `sv`.
284
-
285
- *Returns:* `xpos` if the function can determine such a value for `xpos`.
286
- Otherwise, returns `npos`.
287
-
288
- ``` cpp
289
- size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
290
- ```
291
-
292
- *Effects:* Equivalent to:
293
-
294
- ``` cpp
295
- return find_last_not_of(basic_string_view<charT, traits>(str), pos);
296
- ```
297
-
298
- ``` cpp
299
- size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
300
- ```
301
-
302
- *Returns:*
303
- `find_last_not_of(basic_string_view<charT, traits>(s, n), pos)`.
304
-
305
- ``` cpp
306
- size_type find_last_not_of(const charT* s, size_type pos = npos) const;
307
- ```
308
 
309
- *Requires:* `s` points to an array of at least `traits::length(s) + 1`
310
- elements of `charT`.
 
311
 
312
- *Returns:* `find_last_not_of(basic_string_view<charT, traits>(s), pos)`.
313
 
314
  ``` cpp
315
- size_type find_last_not_of(charT c, size_type pos = npos) const;
 
316
  ```
317
 
318
- *Returns:* `find_last_not_of(basic_string(1, c), pos)`.
 
319
 
320
  ##### `basic_string::substr` <a id="string.substr">[[string.substr]]</a>
321
 
322
  ``` cpp
323
- basic_string substr(size_type pos = 0, size_type n = npos) const;
324
  ```
325
 
326
  *Throws:* `out_of_range` if `pos > size()`.
327
 
328
  *Effects:* Determines the effective length `rlen` of the string to copy
@@ -331,97 +123,131 @@ as the smaller of `n` and `size() - pos`.
331
  *Returns:* `basic_string(data()+pos, rlen)`.
332
 
333
  ##### `basic_string::compare` <a id="string.compare">[[string.compare]]</a>
334
 
335
  ``` cpp
336
- int compare(basic_string_view<charT, traits> sv) const noexcept;
 
337
  ```
338
 
339
- *Effects:* Determines the effective length `rlen` of the strings to
340
- compare as the smaller of `size()` and `sv.size()`. The function then
341
- compares the two strings by calling
342
- `traits::compare(data(), sv.data(), rlen)`.
343
 
344
- *Returns:* The nonzero result if the result of the comparison is
345
- nonzero. Otherwise, returns a value as indicated in
346
- Table  [[tab:strings.compare]].
347
 
348
- **Table: `compare()` results** <a id="tab:strings.compare">[tab:strings.compare]</a>
 
349
 
350
- | Condition | Return Value |
351
- | --------------------- | ------------ |
352
- | `size() < sv.size()` | `< 0` |
353
- | `size() == sv.size()` | ` 0` |
354
- | `size() > sv.size()` | `> 0` |
355
 
356
  ``` cpp
357
- int compare(size_type pos1, size_type n1, basic_string_view<charT, traits> sv) const;
 
358
  ```
359
 
 
 
 
 
 
 
360
  *Effects:* Equivalent to:
361
 
362
  ``` cpp
363
- return basic_string_view<charT, traits>(data(), size()).substr(pos1, n1).compare(sv);
364
  ```
365
 
366
  ``` cpp
367
  template<class T>
368
- int compare(size_type pos1, size_type n1, const T& t,
369
  size_type pos2, size_type n2 = npos) const;
370
  ```
371
 
 
 
 
 
 
 
372
  *Effects:* Equivalent to:
373
 
374
  ``` cpp
375
- basic_string_view<charT, traits> sv = t;
376
- return basic_string_view<charT, traits>(
377
- data(), size()).substr(pos1, n1).compare(sv.substr(pos2, n2));
378
  ```
379
 
380
- *Remarks:* This function shall not participate in overload resolution
381
- unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
382
- `true` and `is_convertible_v<const T&, const charT*>` is `false`.
383
-
384
  ``` cpp
385
- int compare(const basic_string& str) const noexcept;
386
  ```
387
 
388
  *Effects:* Equivalent to:
389
  `return compare(basic_string_view<charT, traits>(str));`
390
 
391
  ``` cpp
392
- int compare(size_type pos1, size_type n1, const basic_string& str) const;
393
  ```
394
 
395
  *Effects:* Equivalent to:
396
  `return compare(pos1, n1, basic_string_view<charT, traits>(str));`
397
 
398
  ``` cpp
399
- int compare(size_type pos1, size_type n1,
400
- const basic_string& str,
401
  size_type pos2, size_type n2 = npos) const;
402
  ```
403
 
404
  *Effects:* Equivalent to:
405
 
406
  ``` cpp
407
  return compare(pos1, n1, basic_string_view<charT, traits>(str), pos2, n2);
408
  ```
409
 
410
  ``` cpp
411
- int compare(const charT* s) const;
412
  ```
413
 
414
- *Returns:* `compare(basic_string(s))`.
 
415
 
416
  ``` cpp
417
- int compare(size_type pos, size_type n1, const charT* s) const;
418
  ```
419
 
420
- *Returns:* `basic_string(*this, pos, n1).compare(basic_string(s))`.
 
421
 
422
  ``` cpp
423
- int compare(size_type pos, size_type n1, const charT* s, size_type n2) const;
424
  ```
425
 
426
- *Returns:* `basic_string(*this, pos, n1).compare(basic_string(s, n2))`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
427
 
 
1
+ #### String operations <a id="string.ops">[[string.ops]]</a>
2
 
3
+ ##### Accessors <a id="string.accessors">[[string.accessors]]</a>
4
 
5
  ``` cpp
6
+ constexpr const charT* c_str() const noexcept;
7
+ constexpr const charT* data() const noexcept;
8
  ```
9
 
10
+ *Returns:* A pointer `p` such that `p + i == addressof(operator[](i))`
11
+ for each `i` in \[`0`, `size()`\].
12
 
13
  *Complexity:* Constant time.
14
 
15
+ *Remarks:* The program shall not modify any of the values stored in the
16
+ character array; otherwise, the behavior is undefined.
17
 
18
  ``` cpp
19
+ constexpr charT* data() noexcept;
20
  ```
21
 
22
+ *Returns:* A pointer `p` such that `p + i == addressof(operator[](i))`
23
+ for each `i` in \[`0`, `size()`\].
24
 
25
  *Complexity:* Constant time.
26
 
27
+ *Remarks:* The program shall not modify the value stored at `p + size()`
28
+ to any value other than `charT()`; otherwise, the behavior is undefined.
29
 
30
  ``` cpp
31
+ constexpr operator basic_string_view<charT, traits>() const noexcept;
32
  ```
33
 
34
  *Effects:* Equivalent to:
35
  `return basic_string_view<charT, traits>(data(), size());`
36
 
37
  ``` cpp
38
+ constexpr allocator_type get_allocator() const noexcept;
39
  ```
40
 
41
  *Returns:* A copy of the `Allocator` object used to construct the string
42
  or, if that allocator has been replaced, a copy of the most recent
43
  replacement.
44
 
45
+ ##### Searching <a id="string.find">[[string.find]]</a>
46
 
47
+ Let *F* be one of `find`, `rfind`, `find_first_of`, `find_last_of`,
48
+ `find_first_not_of`, and `find_last_not_of`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
+ - Each member function of the form
51
  ``` cpp
52
+ constexpr size_type F(const basic_string& str, size_type pos) const noexcept;
53
  ```
54
 
55
+ has effects equivalent to:
56
+ `return F(basic_string_view<charT, traits>(str), pos);`
57
+ - Each member function of the form
 
 
58
  ``` cpp
59
+ constexpr size_type F(const charT* s, size_type pos) const;
60
  ```
61
 
62
+ has effects equivalent to:
63
+ `return F(basic_string_view<charT, traits>(s), pos);`
64
+ - Each member function of the form
 
65
  ``` cpp
66
+ constexpr size_type F(const charT* s, size_type pos, size_type n) const;
67
  ```
68
 
69
+ has effects equivalent to:
70
+ `return F(basic_string_view<charT, traits>(s, n), pos);`
71
+ - Each member function of the form
 
 
 
 
 
 
 
72
  ``` cpp
73
+ constexpr size_type F(charT c, size_type pos) const noexcept;
74
  ```
75
 
76
+ has effects equivalent to:
 
 
77
  ``` cpp
78
+ return F(basic_string_view<charT, traits>(addressof(c), 1), pos);
79
  ```
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  ``` cpp
82
+ template<class T>
83
+ constexpr size_type find(const T& t, size_type pos = 0) const noexcept(see below);
84
+ template<class T>
85
+ constexpr size_type rfind(const T& t, size_type pos = npos) const noexcept(see below);
86
+ template<class T>
87
+ constexpr size_type find_first_of(const T& t, size_type pos = 0) const noexcept(see below);
88
+ template<class T>
89
+ constexpr size_type find_last_of(const T& t, size_type pos = npos) const noexcept(see below);
90
+ template<class T>
91
+ constexpr size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept(see below);
92
+ template<class T>
93
+ constexpr size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept(see below);
94
  ```
95
 
96
+ *Constraints:*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
+ - `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
99
+ `true` and
100
+ - `is_convertible_v<const T&, const charT*>` is `false`.
101
 
102
+ *Effects:* Let *G* be the name of the function. Equivalent to:
103
 
104
  ``` cpp
105
+ basic_string_view<charT, traits> s = *this, sv = t;
106
+ return s.G(sv, pos);
107
  ```
108
 
109
+ *Remarks:* The expression inside `noexcept` is equivalent to
110
+ `is_nothrow_convertible_v<const T&, basic_string_view<charT, traits>>`.
111
 
112
  ##### `basic_string::substr` <a id="string.substr">[[string.substr]]</a>
113
 
114
  ``` cpp
115
+ constexpr basic_string substr(size_type pos = 0, size_type n = npos) const;
116
  ```
117
 
118
  *Throws:* `out_of_range` if `pos > size()`.
119
 
120
  *Effects:* Determines the effective length `rlen` of the string to copy
 
123
  *Returns:* `basic_string(data()+pos, rlen)`.
124
 
125
  ##### `basic_string::compare` <a id="string.compare">[[string.compare]]</a>
126
 
127
  ``` cpp
128
+ template<class T>
129
+ constexpr int compare(const T& t) const noexcept(see below);
130
  ```
131
 
132
+ *Constraints:*
 
 
 
133
 
134
+ - `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
135
+ `true` and
136
+ - `is_convertible_v<const T&, const charT*>` is `false`.
137
 
138
+ *Effects:* Equivalent to:
139
+ `return basic_string_view<charT, traits>(*this).compare(t);`
140
 
141
+ *Remarks:* The expression inside `noexcept` is equivalent to
142
+ `is_nothrow_convertible_v<const T&, basic_string_view<charT, traits>>`.
 
 
 
143
 
144
  ``` cpp
145
+ template<class T>
146
+ constexpr int compare(size_type pos1, size_type n1, const T& t) const;
147
  ```
148
 
149
+ *Constraints:*
150
+
151
+ - `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
152
+ `true` and
153
+ - `is_convertible_v<const T&, const charT*>` is `false`.
154
+
155
  *Effects:* Equivalent to:
156
 
157
  ``` cpp
158
+ return basic_string_view<charT, traits>(*this).substr(pos1, n1).compare(t);
159
  ```
160
 
161
  ``` cpp
162
  template<class T>
163
+ constexpr int compare(size_type pos1, size_type n1, const T& t,
164
  size_type pos2, size_type n2 = npos) const;
165
  ```
166
 
167
+ *Constraints:*
168
+
169
+ - `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
170
+ `true` and
171
+ - `is_convertible_v<const T&, const charT*>` is `false`.
172
+
173
  *Effects:* Equivalent to:
174
 
175
  ``` cpp
176
+ basic_string_view<charT, traits> s = *this, sv = t;
177
+ return s.substr(pos1, n1).compare(sv.substr(pos2, n2));
 
178
  ```
179
 
 
 
 
 
180
  ``` cpp
181
+ constexpr int compare(const basic_string& str) const noexcept;
182
  ```
183
 
184
  *Effects:* Equivalent to:
185
  `return compare(basic_string_view<charT, traits>(str));`
186
 
187
  ``` cpp
188
+ constexpr int compare(size_type pos1, size_type n1, const basic_string& str) const;
189
  ```
190
 
191
  *Effects:* Equivalent to:
192
  `return compare(pos1, n1, basic_string_view<charT, traits>(str));`
193
 
194
  ``` cpp
195
+ constexpr int compare(size_type pos1, size_type n1, const basic_string& str,
 
196
  size_type pos2, size_type n2 = npos) const;
197
  ```
198
 
199
  *Effects:* Equivalent to:
200
 
201
  ``` cpp
202
  return compare(pos1, n1, basic_string_view<charT, traits>(str), pos2, n2);
203
  ```
204
 
205
  ``` cpp
206
+ constexpr int compare(const charT* s) const;
207
  ```
208
 
209
+ *Effects:* Equivalent to:
210
+ `return compare(basic_string_view<charT, traits>(s));`
211
 
212
  ``` cpp
213
+ constexpr int compare(size_type pos, size_type n1, const charT* s) const;
214
  ```
215
 
216
+ *Effects:* Equivalent to:
217
+ `return compare(pos, n1, basic_string_view<charT, traits>(s));`
218
 
219
  ``` cpp
220
+ constexpr int compare(size_type pos, size_type n1, const charT* s, size_type n2) const;
221
  ```
222
 
223
+ *Effects:* Equivalent to:
224
+ `return compare(pos, n1, basic_string_view<charT, traits>(s, n2));`
225
+
226
+ ##### `basic_string::starts_with` <a id="string.starts.with">[[string.starts.with]]</a>
227
+
228
+ ``` cpp
229
+ constexpr bool starts_with(basic_string_view<charT, traits> x) const noexcept;
230
+ constexpr bool starts_with(charT x) const noexcept;
231
+ constexpr bool starts_with(const charT* x) const;
232
+ ```
233
+
234
+ *Effects:* Equivalent to:
235
+
236
+ ``` cpp
237
+ return basic_string_view<charT, traits>(data(), size()).starts_with(x);
238
+ ```
239
+
240
+ ##### `basic_string::ends_with` <a id="string.ends.with">[[string.ends.with]]</a>
241
+
242
+ ``` cpp
243
+ constexpr bool ends_with(basic_string_view<charT, traits> x) const noexcept;
244
+ constexpr bool ends_with(charT x) const noexcept;
245
+ constexpr bool ends_with(const charT* x) const;
246
+ ```
247
+
248
+ *Effects:* Equivalent to:
249
+
250
+ ``` cpp
251
+ return basic_string_view<charT, traits>(data(), size()).ends_with(x);
252
+ ```
253