From Jason Turner

[string.ops]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2ag98za3/{from.md → to.md} +169 -88
tmp/tmp2ag98za3/{from.md → to.md} RENAMED
@@ -1,8 +1,8 @@
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
  ```
@@ -13,334 +13,415 @@ const charT* data() const noexcept;
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
  allocator_type get_allocator() const noexcept;
20
  ```
21
 
22
  *Returns:* A copy of the `Allocator` object used to construct the string
23
  or, if that allocator has been replaced, a copy of the most recent
24
  replacement.
25
 
26
- #### `basic_string::find` <a id="string::find">[[string::find]]</a>
27
 
28
  ``` cpp
29
- size_type find(const basic_string& str,
30
- size_type pos = 0) const noexcept;
31
  ```
32
 
33
  *Effects:* Determines the lowest position `xpos`, if possible, such that
34
- both of the following conditions obtain:
35
 
36
- - `pos <= xpos` and `xpos + str.size() <= size()`;
37
- - `traits::eq(at(xpos+I), str.at(I))` for all elements `I` of the string
38
- controlled by `str`.
39
 
40
  *Returns:* `xpos` if the function can determine such a value for `xpos`.
41
  Otherwise, returns `npos`.
42
 
43
- *Remarks:* Uses `traits::eq()`.
 
 
 
 
 
44
 
45
  ``` cpp
46
  size_type find(const charT* s, size_type pos, size_type n) const;
47
  ```
48
 
49
- *Returns:* `find(basic_string(s,n),pos)`.
50
 
51
  ``` cpp
52
  size_type find(const charT* s, size_type pos = 0) const;
53
  ```
54
 
55
  *Requires:* `s` points to an array of at least `traits::length(s) + 1`
56
  elements of `charT`.
57
 
58
- *Returns:* `find(basic_string(s), pos)`.
59
 
60
  ``` cpp
61
  size_type find(charT c, size_type pos = 0) const;
62
  ```
63
 
64
  *Returns:* `find(basic_string(1, c), pos)`.
65
 
66
- #### `basic_string::rfind` <a id="string::rfind">[[string::rfind]]</a>
67
 
68
  ``` cpp
69
- size_type rfind(const basic_string& str,
70
- size_type pos = npos) const noexcept;
71
  ```
72
 
73
  *Effects:* Determines the highest position `xpos`, if possible, such
74
- that both of the following conditions obtain:
75
 
76
- - `xpos <= pos` and `xpos + str.size() <= size()`;
77
- - `traits::eq(at(xpos+I), str.at(I))` for all elements `I` of the string
78
- controlled by `str`.
79
 
80
  *Returns:* `xpos` if the function can determine such a value for `xpos`.
81
  Otherwise, returns `npos`.
82
 
83
- *Remarks:* Uses `traits::eq()`.
 
 
 
 
 
84
 
85
  ``` cpp
86
  size_type rfind(const charT* s, size_type pos, size_type n) const;
87
  ```
88
 
89
- *Returns:* `rfind(basic_string(s, n), pos)`.
90
 
91
  ``` cpp
92
  size_type rfind(const charT* s, size_type pos = npos) const;
93
  ```
94
 
95
- *Requires:* s points to an array of at least `traits::length(s) + 1`
96
  elements of `charT`.
97
 
98
- *Returns:* `rfind(basic_string(s), pos)`.
99
 
100
  ``` cpp
101
  size_type rfind(charT c, size_type pos = npos) const;
102
  ```
103
 
104
  *Returns:* `rfind(basic_string(1, c), pos)`.
105
 
106
- #### `basic_string::find_first_of` <a id="string::find.first.of">[[string::find.first.of]]</a>
107
 
108
  ``` cpp
109
- size_type
110
- find_first_of(const basic_string& str,
111
- size_type pos = 0) const noexcept;
112
  ```
113
 
114
  *Effects:* Determines the lowest position `xpos`, if possible, such that
115
- both of the following conditions obtain:
116
 
117
  - `pos <= xpos` and `xpos < size()`;
118
- - `traits::eq(at(xpos), str.at(I))` for some element `I` of the string
119
- controlled by `str`.
120
 
121
  *Returns:* `xpos` if the function can determine such a value for `xpos`.
122
  Otherwise, returns `npos`.
123
 
124
- *Remarks:* Uses `traits::eq()`.
 
 
 
 
 
125
 
126
  ``` cpp
127
- size_type
128
- find_first_of(const charT* s, size_type pos, size_type n) const;
129
  ```
130
 
131
- *Returns:* `find_first_of(basic_string(s, n), pos)`.
132
 
133
  ``` cpp
134
  size_type find_first_of(const charT* s, size_type pos = 0) const;
135
  ```
136
 
137
  *Requires:* `s` points to an array of at least `traits::length(s) + 1`
138
  elements of `charT`.
139
 
140
- *Returns:* `find_first_of(basic_string(s), pos)`.
141
 
142
  ``` cpp
143
  size_type find_first_of(charT c, size_type pos = 0) const;
144
  ```
145
 
146
  *Returns:* `find_first_of(basic_string(1, c), pos)`.
147
 
148
- #### `basic_string::find_last_of` <a id="string::find.last.of">[[string::find.last.of]]</a>
149
 
150
  ``` cpp
151
- size_type
152
- find_last_of(const basic_string& str,
153
- size_type pos = npos) const noexcept;
154
  ```
155
 
156
  *Effects:* Determines the highest position `xpos`, if possible, such
157
- that both of the following conditions obtain:
158
 
159
  - `xpos <= pos` and `xpos < size()`;
160
- - `traits::eq(at(xpos), str.at(I))` for some element `I` of the string
161
- controlled by `str`.
162
 
163
  *Returns:* `xpos` if the function can determine such a value for `xpos`.
164
  Otherwise, returns `npos`.
165
 
166
- *Remarks:* Uses `traits::eq()`.
 
 
 
 
 
167
 
168
  ``` cpp
169
  size_type find_last_of(const charT* s, size_type pos, size_type n) const;
170
  ```
171
 
172
- *Returns:* `find_last_of(basic_string(s, n), pos)`.
173
 
174
  ``` cpp
175
  size_type find_last_of(const charT* s, size_type pos = npos) const;
176
  ```
177
 
178
  *Requires:* `s` points to an array of at least `traits::length(s) + 1`
179
  elements of `charT`.
180
 
181
- *Returns:* `find_last_of(basic_string(s), pos)`.
182
 
183
  ``` cpp
184
  size_type find_last_of(charT c, size_type pos = npos) const;
185
  ```
186
 
187
  *Returns:* `find_last_of(basic_string(1, c), pos)`.
188
 
189
- #### `basic_string::find_first_not_of` <a id="string::find.first.not.of">[[string::find.first.not.of]]</a>
190
 
191
  ``` cpp
192
- size_type
193
- find_first_not_of(const basic_string& str,
194
  size_type pos = 0) const noexcept;
195
  ```
196
 
197
  *Effects:* Determines the lowest position `xpos`, if possible, such that
198
- both of the following conditions obtain:
199
 
200
  - `pos <= xpos` and `xpos < size()`;
201
- - `traits::eq(at(xpos), str.at(I))` for no element `I` of the string
202
- controlled by `str`.
203
 
204
  *Returns:* `xpos` if the function can determine such a value for `xpos`.
205
  Otherwise, returns `npos`.
206
 
207
- *Remarks:* Uses `traits::eq()`.
 
 
 
 
 
 
 
 
208
 
209
  ``` cpp
210
- size_type
211
- find_first_not_of(const charT* s, size_type pos, size_type n) const;
212
  ```
213
 
214
- *Returns:* `find_first_not_of(basic_string(s, n), pos)`.
 
215
 
216
  ``` cpp
217
  size_type find_first_not_of(const charT* s, size_type pos = 0) const;
218
  ```
219
 
220
  *Requires:* `s` points to an array of at least `traits::length(s) + 1`
221
  elements of `charT`.
222
 
223
- *Returns:* `find_first_not_of(basic_string(s), pos)`.
 
224
 
225
  ``` cpp
226
  size_type find_first_not_of(charT c, size_type pos = 0) const;
227
  ```
228
 
229
  *Returns:* `find_first_not_of(basic_string(1, c), pos)`.
230
 
231
- #### `basic_string::find_last_not_of` <a id="string::find.last.not.of">[[string::find.last.not.of]]</a>
232
 
233
  ``` cpp
234
- size_type
235
- find_last_not_of(const basic_string& str,
236
  size_type pos = npos) const noexcept;
237
  ```
238
 
239
  *Effects:* Determines the highest position `xpos`, if possible, such
240
- that both of the following conditions obtain:
241
 
242
  - `xpos <= pos` and `xpos < size()`;
243
- - `traits::eq(at(xpos), str.at(I))` for no element `I` of the string
244
- controlled by `str`.
245
 
246
  *Returns:* `xpos` if the function can determine such a value for `xpos`.
247
  Otherwise, returns `npos`.
248
 
249
- *Remarks:* Uses `traits::eq()`.
 
 
 
 
 
 
 
 
250
 
251
  ``` cpp
252
- size_type find_last_not_of(const charT* s, size_type pos,
253
- size_type n) const;
254
  ```
255
 
256
- *Returns:* `find_last_not_of(basic_string(s, n), pos)`.
 
257
 
258
  ``` cpp
259
  size_type find_last_not_of(const charT* s, size_type pos = npos) const;
260
  ```
261
 
262
  *Requires:* `s` points to an array of at least `traits::length(s) + 1`
263
  elements of `charT`.
264
 
265
- *Returns:* `find_last_not_of(basic_string(s), pos)`.
266
 
267
  ``` cpp
268
  size_type find_last_not_of(charT c, size_type pos = npos) const;
269
  ```
270
 
271
  *Returns:* `find_last_not_of(basic_string(1, c), pos)`.
272
 
273
- #### `basic_string::substr` <a id="string::substr">[[string::substr]]</a>
274
 
275
  ``` cpp
276
  basic_string substr(size_type pos = 0, size_type n = npos) const;
277
  ```
278
 
279
- *Requires:* `pos <= size()`
280
-
281
  *Throws:* `out_of_range` if `pos > size()`.
282
 
283
  *Effects:* Determines the effective length `rlen` of the string to copy
284
  as the smaller of `n` and `size() - pos`.
285
 
286
  *Returns:* `basic_string(data()+pos, rlen)`.
287
 
288
- #### `basic_string::compare` <a id="string::compare">[[string::compare]]</a>
289
 
290
  ``` cpp
291
- int compare(const basic_string& str) const noexcept;
292
  ```
293
 
294
- *Effects:* Determines the effective length *rlen* of the strings to
295
- compare as the smallest of `size()` and `str.size()`. The function then
296
  compares the two strings by calling
297
- `traits::compare(data(), str.data(), rlen)`.
298
 
299
  *Returns:* The nonzero result if the result of the comparison is
300
  nonzero. Otherwise, returns a value as indicated in
301
  Table  [[tab:strings.compare]].
302
 
303
  **Table: `compare()` results** <a id="tab:strings.compare">[tab:strings.compare]</a>
304
 
305
  | Condition | Return Value |
306
- | ---------------------- | ------------ |
307
- | `size() < str.size()` | `< 0` |
308
- | `size() == str.size()` | ` 0` |
309
- | `size() > str.size()` | `> 0` |
310
 
311
  ``` cpp
312
- int compare(size_type pos1, size_type n1,
313
- const basic_string& str) const;
314
  ```
315
 
316
- *Returns:* `basic_string(*this,pos1,n1).compare(str)`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
 
318
  ``` cpp
319
  int compare(size_type pos1, size_type n1,
320
  const basic_string& str,
321
  size_type pos2, size_type n2 = npos) const;
322
  ```
323
 
324
- *Returns:*
325
- `basic_string(*this, pos1, n1).compare(basic_string(str, pos2, n2))`.
 
 
 
326
 
327
  ``` cpp
328
  int compare(const charT* s) const;
329
  ```
330
 
331
  *Returns:* `compare(basic_string(s))`.
332
 
333
  ``` cpp
334
- int compare(size_type pos, size_type n1,
335
- const charT* s) const;
336
  ```
337
 
338
  *Returns:* `basic_string(*this, pos, n1).compare(basic_string(s))`.
339
 
340
  ``` cpp
341
- int compare(size_type pos, size_type n1,
342
- const charT* s, size_type n2) const;
343
  ```
344
 
345
  *Returns:* `basic_string(*this, pos, n1).compare(basic_string(s, n2))`.
346
 
 
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
  ```
 
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
329
  as the smaller of `n` and `size() - pos`.
330
 
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