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
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
|
Β
|
|
Β
|
|
| 1 |
+
### Class template `basic_string_view` <a id="string.view.template">[[string.view.template]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
template<class charT, class traits = char_traits<charT>>
|
| 5 |
+
class basic_string_view {
|
| 6 |
+
public:
|
| 7 |
+
// types
|
| 8 |
+
using traits_type = traits;
|
| 9 |
+
using value_type = charT;
|
| 10 |
+
using pointer = value_type*;
|
| 11 |
+
using const_pointer = const value_type*;
|
| 12 |
+
using reference = value_type&;
|
| 13 |
+
using const_reference = const value_type&;
|
| 14 |
+
using const_iterator = implementation-defined // type of basic_string_view::const_iterator; // see [string.view.iterators]
|
| 15 |
+
using iterator = const_iterator;\footnote{Because basic_string_view refers to a constant sequence, iterator and const_iterator are the same type.}
|
| 16 |
+
using const_reverse_iterator = reverse_iterator<const_iterator>;
|
| 17 |
+
using reverse_iterator = const_reverse_iterator;
|
| 18 |
+
using size_type = size_t;
|
| 19 |
+
using difference_type = ptrdiff_t;
|
| 20 |
+
static constexpr size_type npos = size_type(-1);
|
| 21 |
+
|
| 22 |
+
// [string.view.cons], construction and assignment
|
| 23 |
+
constexpr basic_string_view() noexcept;
|
| 24 |
+
constexpr basic_string_view(const basic_string_view&) noexcept = default;
|
| 25 |
+
constexpr basic_string_view& operator=(const basic_string_view&) noexcept = default;
|
| 26 |
+
constexpr basic_string_view(const charT* str);
|
| 27 |
+
constexpr basic_string_view(const charT* str, size_type len);
|
| 28 |
+
|
| 29 |
+
// [string.view.iterators], iterator support
|
| 30 |
+
constexpr const_iterator begin() const noexcept;
|
| 31 |
+
constexpr const_iterator end() const noexcept;
|
| 32 |
+
constexpr const_iterator cbegin() const noexcept;
|
| 33 |
+
constexpr const_iterator cend() const noexcept;
|
| 34 |
+
constexpr const_reverse_iterator rbegin() const noexcept;
|
| 35 |
+
constexpr const_reverse_iterator rend() const noexcept;
|
| 36 |
+
constexpr const_reverse_iterator crbegin() const noexcept;
|
| 37 |
+
constexpr const_reverse_iterator crend() const noexcept;
|
| 38 |
+
|
| 39 |
+
// [string.view.capacity], capacity
|
| 40 |
+
constexpr size_type size() const noexcept;
|
| 41 |
+
constexpr size_type length() const noexcept;
|
| 42 |
+
constexpr size_type max_size() const noexcept;
|
| 43 |
+
constexpr bool empty() const noexcept;
|
| 44 |
+
|
| 45 |
+
// [string.view.access], element access
|
| 46 |
+
constexpr const_reference operator[](size_type pos) const;
|
| 47 |
+
constexpr const_reference at(size_type pos) const;
|
| 48 |
+
constexpr const_reference front() const;
|
| 49 |
+
constexpr const_reference back() const;
|
| 50 |
+
constexpr const_pointer data() const noexcept;
|
| 51 |
+
|
| 52 |
+
// [string.view.modifiers], modifiers
|
| 53 |
+
constexpr void remove_prefix(size_type n);
|
| 54 |
+
constexpr void remove_suffix(size_type n);
|
| 55 |
+
constexpr void swap(basic_string_view& s) noexcept;
|
| 56 |
+
|
| 57 |
+
// [string.view.ops], string operations
|
| 58 |
+
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
| 59 |
+
|
| 60 |
+
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
|
| 61 |
+
constexpr int compare(basic_string_view s) const noexcept;
|
| 62 |
+
constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
|
| 63 |
+
constexpr int compare(size_type pos1, size_type n1, basic_string_view s,
|
| 64 |
+
size_type pos2, size_type n2) const;
|
| 65 |
+
constexpr int compare(const charT* s) const;
|
| 66 |
+
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
|
| 67 |
+
constexpr int compare(size_type pos1, size_type n1, const charT* s,
|
| 68 |
+
size_type n2) const;
|
| 69 |
+
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
|
| 70 |
+
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
|
| 71 |
+
constexpr size_type find(const charT* s, size_type pos, size_type n) const;
|
| 72 |
+
constexpr size_type find(const charT* s, size_type pos = 0) const;
|
| 73 |
+
constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
|
| 74 |
+
constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
|
| 75 |
+
constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
|
| 76 |
+
constexpr size_type rfind(const charT* s, size_type pos = npos) const;
|
| 77 |
+
constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
|
| 78 |
+
constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
|
| 79 |
+
constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
|
| 80 |
+
constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
|
| 81 |
+
constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
|
| 82 |
+
constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
|
| 83 |
+
constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
|
| 84 |
+
constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
|
| 85 |
+
constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
|
| 86 |
+
constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
|
| 87 |
+
constexpr size_type find_first_not_of(const charT* s, size_type pos,
|
| 88 |
+
size_type n) const;
|
| 89 |
+
constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
|
| 90 |
+
constexpr size_type find_last_not_of(basic_string_view s,
|
| 91 |
+
size_type pos = npos) const noexcept;
|
| 92 |
+
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
|
| 93 |
+
constexpr size_type find_last_not_of(const charT* s, size_type pos,
|
| 94 |
+
size_type n) const;
|
| 95 |
+
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
|
| 96 |
+
|
| 97 |
+
private:
|
| 98 |
+
const_pointer data_; // exposition only
|
| 99 |
+
size_type size_; // exposition only
|
| 100 |
+
};
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
In every specialization `basic_string_view<charT, traits>`, the type
|
| 104 |
+
`traits` shall satisfy the character traits requirements (
|
| 105 |
+
[[char.traits]]), and the type `traits::char_type` shall name the same
|
| 106 |
+
type as `charT`.
|
| 107 |
+
|
| 108 |
+
#### Construction and assignment <a id="string.view.cons">[[string.view.cons]]</a>
|
| 109 |
+
|
| 110 |
+
``` cpp
|
| 111 |
+
constexpr basic_string_view() noexcept;
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
*Effects:* Constructs an empty `basic_string_view`.
|
| 115 |
+
|
| 116 |
+
*Postconditions:* `size_ == 0` and `data_ == nullptr`.
|
| 117 |
+
|
| 118 |
+
``` cpp
|
| 119 |
+
constexpr basic_string_view(const charT* str);
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
*Requires:* \[`str`, `str + traits::length(str)`) is a valid range.
|
| 123 |
+
|
| 124 |
+
*Effects:* Constructs a `basic_string_view`, with the postconditions in
|
| 125 |
+
TableΒ [[tab:string.view.ctr.2]].
|
| 126 |
+
|
| 127 |
+
*Complexity:* π(`traits::length(str)`).
|
| 128 |
+
|
| 129 |
+
``` cpp
|
| 130 |
+
constexpr basic_string_view(const charT* str, size_type len);
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
*Requires:* \[`str`, `str + len`) is a valid range.
|
| 134 |
+
|
| 135 |
+
*Effects:* Constructs a `basic_string_view`, with the postconditions in
|
| 136 |
+
TableΒ [[tab:string.view.ctr.3]].
|
| 137 |
+
|
| 138 |
+
#### Iterator support <a id="string.view.iterators">[[string.view.iterators]]</a>
|
| 139 |
+
|
| 140 |
+
``` cpp
|
| 141 |
+
using const_iterator = implementation-defined // type of basic_string_view::const_iterator;
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
A type that meets the requirements of a constant random access
|
| 145 |
+
iteratorΒ ([[random.access.iterators]]) and of a contiguous
|
| 146 |
+
iteratorΒ ([[iterator.requirements.general]]) whose `value_type` is the
|
| 147 |
+
template parameter `charT`.
|
| 148 |
+
|
| 149 |
+
For a `basic_string_view str`, any operation that invalidates a pointer
|
| 150 |
+
in the range \[`str.data()`, `str.data() + str.size()`) invalidates
|
| 151 |
+
pointers, iterators, and references returned from `str`βs methods.
|
| 152 |
+
|
| 153 |
+
All requirements on container iterators ([[container.requirements]])
|
| 154 |
+
apply to `basic_string_view::const_iterator` as well.
|
| 155 |
+
|
| 156 |
+
``` cpp
|
| 157 |
+
constexpr const_iterator begin() const noexcept;
|
| 158 |
+
constexpr const_iterator cbegin() const noexcept;
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
*Returns:* An iterator such that
|
| 162 |
+
|
| 163 |
+
- if `!empty()`, `&*begin() == data_`,
|
| 164 |
+
- otherwise, an unspecified value such that \[`begin()`, `end()`) is a
|
| 165 |
+
valid range.
|
| 166 |
+
|
| 167 |
+
``` cpp
|
| 168 |
+
constexpr const_iterator end() const noexcept;
|
| 169 |
+
constexpr const_iterator cend() const noexcept;
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
+
*Returns:* `begin() + size()`.
|
| 173 |
+
|
| 174 |
+
``` cpp
|
| 175 |
+
constexpr const_reverse_iterator rbegin() const noexcept;
|
| 176 |
+
constexpr const_reverse_iterator crbegin() const noexcept;
|
| 177 |
+
```
|
| 178 |
+
|
| 179 |
+
*Returns:* `const_reverse_iterator(end())`.
|
| 180 |
+
|
| 181 |
+
``` cpp
|
| 182 |
+
constexpr const_reverse_iterator rend() const noexcept;
|
| 183 |
+
constexpr const_reverse_iterator crend() const noexcept;
|
| 184 |
+
```
|
| 185 |
+
|
| 186 |
+
*Returns:* `const_reverse_iterator(begin())`.
|
| 187 |
+
|
| 188 |
+
#### Capacity <a id="string.view.capacity">[[string.view.capacity]]</a>
|
| 189 |
+
|
| 190 |
+
``` cpp
|
| 191 |
+
constexpr size_type size() const noexcept;
|
| 192 |
+
```
|
| 193 |
+
|
| 194 |
+
*Returns:* `size_`.
|
| 195 |
+
|
| 196 |
+
``` cpp
|
| 197 |
+
constexpr size_type length() const noexcept;
|
| 198 |
+
```
|
| 199 |
+
|
| 200 |
+
*Returns:* `size_`.
|
| 201 |
+
|
| 202 |
+
``` cpp
|
| 203 |
+
constexpr size_type max_size() const noexcept;
|
| 204 |
+
```
|
| 205 |
+
|
| 206 |
+
*Returns:* The largest possible number of char-like objects that can be
|
| 207 |
+
referred to by a `basic_string_view`.
|
| 208 |
+
|
| 209 |
+
``` cpp
|
| 210 |
+
constexpr bool empty() const noexcept;
|
| 211 |
+
```
|
| 212 |
+
|
| 213 |
+
*Returns:* `size_ == 0`.
|
| 214 |
+
|
| 215 |
+
#### Element access <a id="string.view.access">[[string.view.access]]</a>
|
| 216 |
+
|
| 217 |
+
``` cpp
|
| 218 |
+
constexpr const_reference operator[](size_type pos) const;
|
| 219 |
+
```
|
| 220 |
+
|
| 221 |
+
*Requires:* `pos < size()`.
|
| 222 |
+
|
| 223 |
+
*Returns:* `data_[pos]`.
|
| 224 |
+
|
| 225 |
+
*Throws:* Nothing.
|
| 226 |
+
|
| 227 |
+
[*Note 1*: Unlike `basic_string::operator[]`,
|
| 228 |
+
`basic_string_view::operator[](size())` has undefined behavior instead
|
| 229 |
+
of returning `charT()`. β *end note*]
|
| 230 |
+
|
| 231 |
+
``` cpp
|
| 232 |
+
constexpr const_reference at(size_type pos) const;
|
| 233 |
+
```
|
| 234 |
+
|
| 235 |
+
*Throws:* `out_of_range` if `pos >= size()`.
|
| 236 |
+
|
| 237 |
+
*Returns:* `data_[pos]`.
|
| 238 |
+
|
| 239 |
+
``` cpp
|
| 240 |
+
constexpr const_reference front() const;
|
| 241 |
+
```
|
| 242 |
+
|
| 243 |
+
*Requires:* `!empty()`.
|
| 244 |
+
|
| 245 |
+
*Returns:* `data_[0]`.
|
| 246 |
+
|
| 247 |
+
*Throws:* Nothing.
|
| 248 |
+
|
| 249 |
+
``` cpp
|
| 250 |
+
constexpr const_reference back() const;
|
| 251 |
+
```
|
| 252 |
+
|
| 253 |
+
*Requires:* `!empty()`.
|
| 254 |
+
|
| 255 |
+
*Returns:* `data_[size() - 1]`.
|
| 256 |
+
|
| 257 |
+
*Throws:* Nothing.
|
| 258 |
+
|
| 259 |
+
``` cpp
|
| 260 |
+
constexpr const_pointer data() const noexcept;
|
| 261 |
+
```
|
| 262 |
+
|
| 263 |
+
*Returns:* `data_`.
|
| 264 |
+
|
| 265 |
+
[*Note 2*: Unlike `basic_string::data()` and string literals, `data()`
|
| 266 |
+
may return a pointer to a buffer that is not null-terminated. Therefore
|
| 267 |
+
it is typically a mistake to pass `data()` to a function that takes just
|
| 268 |
+
a `const charT*` and expects a null-terminated string. β *end note*]
|
| 269 |
+
|
| 270 |
+
#### Modifiers <a id="string.view.modifiers">[[string.view.modifiers]]</a>
|
| 271 |
+
|
| 272 |
+
``` cpp
|
| 273 |
+
constexpr void remove_prefix(size_type n);
|
| 274 |
+
```
|
| 275 |
+
|
| 276 |
+
*Requires:* `n <= size()`.
|
| 277 |
+
|
| 278 |
+
*Effects:* Equivalent to: `data_ += n; size_ -= n;`
|
| 279 |
+
|
| 280 |
+
``` cpp
|
| 281 |
+
constexpr void remove_suffix(size_type n);
|
| 282 |
+
```
|
| 283 |
+
|
| 284 |
+
*Requires:* `n <= size()`.
|
| 285 |
+
|
| 286 |
+
*Effects:* Equivalent to: `size_ -= n;`
|
| 287 |
+
|
| 288 |
+
``` cpp
|
| 289 |
+
constexpr void swap(basic_string_view& s) noexcept;
|
| 290 |
+
```
|
| 291 |
+
|
| 292 |
+
*Effects:* Exchanges the values of `*this` and `s`.
|
| 293 |
+
|
| 294 |
+
#### String operations <a id="string.view.ops">[[string.view.ops]]</a>
|
| 295 |
+
|
| 296 |
+
``` cpp
|
| 297 |
+
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
| 298 |
+
```
|
| 299 |
+
|
| 300 |
+
Let `rlen` be the smaller of `n` and `size() - pos`.
|
| 301 |
+
|
| 302 |
+
*Throws:* `out_of_range` if `pos > size()`.
|
| 303 |
+
|
| 304 |
+
*Requires:* \[`s`, `s + rlen`) is a valid range.
|
| 305 |
+
|
| 306 |
+
*Effects:* Equivalent to `traits::copy(s, data() + pos, rlen)`.
|
| 307 |
+
|
| 308 |
+
*Returns:* `rlen`.
|
| 309 |
+
|
| 310 |
+
*Complexity:* π(`rlen`).
|
| 311 |
+
|
| 312 |
+
``` cpp
|
| 313 |
+
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
|
| 314 |
+
```
|
| 315 |
+
|
| 316 |
+
Let `rlen` be the smaller of `n` and `size() - pos`.
|
| 317 |
+
|
| 318 |
+
*Throws:* `out_of_range` if `pos > size()`.
|
| 319 |
+
|
| 320 |
+
*Effects:* Determines `rlen`, the effective length of the string to
|
| 321 |
+
reference.
|
| 322 |
+
|
| 323 |
+
*Returns:* `basic_string_view(data() + pos, rlen)`.
|
| 324 |
+
|
| 325 |
+
``` cpp
|
| 326 |
+
constexpr int compare(basic_string_view str) const noexcept;
|
| 327 |
+
```
|
| 328 |
+
|
| 329 |
+
Let `rlen` be the smaller of `size()` and `str.size()`.
|
| 330 |
+
|
| 331 |
+
*Effects:* Determines `rlen`, the effective length of the strings to
|
| 332 |
+
compare. The function then compares the two strings by calling
|
| 333 |
+
`traits::compare(data(), str.data(), rlen)`.
|
| 334 |
+
|
| 335 |
+
*Complexity:* π(`rlen`).
|
| 336 |
+
|
| 337 |
+
*Returns:* The nonzero result if the result of the comparison is
|
| 338 |
+
nonzero. Otherwise, returns a value as indicated in
|
| 339 |
+
TableΒ [[tab:string.view.compare]].
|
| 340 |
+
|
| 341 |
+
**Table: `compare()` results** <a id="tab:string.view.compare">[tab:string.view.compare]</a>
|
| 342 |
+
|
| 343 |
+
| Condition | Return Value |
|
| 344 |
+
| ---------------------- | ------------ |
|
| 345 |
+
| `size() < str.size()` | `< 0` |
|
| 346 |
+
| `size() == str.size()` | ` 0` |
|
| 347 |
+
| `size() > str.size()` | `> 0` |
|
| 348 |
+
|
| 349 |
+
``` cpp
|
| 350 |
+
constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
|
| 351 |
+
```
|
| 352 |
+
|
| 353 |
+
*Effects:* Equivalent to: `return substr(pos1, n1).compare(str);`
|
| 354 |
+
|
| 355 |
+
``` cpp
|
| 356 |
+
constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
|
| 357 |
+
size_type pos2, size_type n2) const;
|
| 358 |
+
```
|
| 359 |
+
|
| 360 |
+
*Effects:* Equivalent to:
|
| 361 |
+
`return substr(pos1, n1).compare(str.substr(pos2, n2));`
|
| 362 |
+
|
| 363 |
+
``` cpp
|
| 364 |
+
constexpr int compare(const charT* s) const;
|
| 365 |
+
```
|
| 366 |
+
|
| 367 |
+
*Effects:* Equivalent to: `return compare(basic_string_view(s));`
|
| 368 |
+
|
| 369 |
+
``` cpp
|
| 370 |
+
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
|
| 371 |
+
```
|
| 372 |
+
|
| 373 |
+
*Effects:* Equivalent to:
|
| 374 |
+
`return substr(pos1, n1).compare(basic_string_view(s));`
|
| 375 |
+
|
| 376 |
+
``` cpp
|
| 377 |
+
constexpr int compare(size_type pos1, size_type n1,
|
| 378 |
+
const charT* s, size_type n2) const;
|
| 379 |
+
```
|
| 380 |
+
|
| 381 |
+
*Effects:* Equivalent to:
|
| 382 |
+
`return substr(pos1, n1).compare(basic_string_view(s, n2));`
|
| 383 |
+
|
| 384 |
+
#### Searching <a id="string.view.find">[[string.view.find]]</a>
|
| 385 |
+
|
| 386 |
+
This section specifies the `basic_string_view` member functions named
|
| 387 |
+
`find`, `rfind`, `find_first_of`, `find_last_of`, `find_first_not_of`,
|
| 388 |
+
and `find_last_not_of`.
|
| 389 |
+
|
| 390 |
+
Member functions in this section have complexity
|
| 391 |
+
π(`size() * str.size()`) at worst, although implementations are
|
| 392 |
+
encouraged to do better.
|
| 393 |
+
|
| 394 |
+
Each member function of the form
|
| 395 |
+
|
| 396 |
+
``` cpp
|
| 397 |
+
constexpr return-type F(const charT* s, size_type pos);
|
| 398 |
+
```
|
| 399 |
+
|
| 400 |
+
is equivalent to `return F(basic_string_view(s), pos);`
|
| 401 |
+
|
| 402 |
+
Each member function of the form
|
| 403 |
+
|
| 404 |
+
``` cpp
|
| 405 |
+
constexpr return-type F(const charT* s, size_type pos, size_type n);
|
| 406 |
+
```
|
| 407 |
+
|
| 408 |
+
is equivalent to `return F(basic_string_view(s, n), pos);`
|
| 409 |
+
|
| 410 |
+
Each member function of the form
|
| 411 |
+
|
| 412 |
+
``` cpp
|
| 413 |
+
constexpr return-type F(charT c, size_type pos);
|
| 414 |
+
```
|
| 415 |
+
|
| 416 |
+
is equivalent to `return F(basic_string_view(&c, 1), pos);`
|
| 417 |
+
|
| 418 |
+
``` cpp
|
| 419 |
+
constexpr size_type find(basic_string_view str, size_type pos = 0) const noexcept;
|
| 420 |
+
```
|
| 421 |
+
|
| 422 |
+
Let `xpos` be the lowest position, if possible, such that the following
|
| 423 |
+
conditions hold:
|
| 424 |
+
|
| 425 |
+
- `pos <= xpos`
|
| 426 |
+
- `xpos + str.size() <= size()`
|
| 427 |
+
- `traits::eq(at(xpos + I), str.at(I))` for all elements `I` of the
|
| 428 |
+
string referenced by `str`.
|
| 429 |
+
|
| 430 |
+
*Effects:* Determines `xpos`.
|
| 431 |
+
|
| 432 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 433 |
+
Otherwise, returns `npos`.
|
| 434 |
+
|
| 435 |
+
``` cpp
|
| 436 |
+
constexpr size_type rfind(basic_string_view str, size_type pos = npos) const noexcept;
|
| 437 |
+
```
|
| 438 |
+
|
| 439 |
+
Let `xpos` be the highest position, if possible, such that the following
|
| 440 |
+
conditions hold:
|
| 441 |
+
|
| 442 |
+
- `xpos <= pos`
|
| 443 |
+
- `xpos + str.size() <= size()`
|
| 444 |
+
- `traits::eq(at(xpos + I), str.at(I))` for all elements `I` of the
|
| 445 |
+
string referenced by `str`.
|
| 446 |
+
|
| 447 |
+
*Effects:* Determines `xpos`.
|
| 448 |
+
|
| 449 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 450 |
+
Otherwise, returns `npos`.
|
| 451 |
+
|
| 452 |
+
``` cpp
|
| 453 |
+
constexpr size_type find_first_of(basic_string_view str, size_type pos = 0) const noexcept;
|
| 454 |
+
```
|
| 455 |
+
|
| 456 |
+
Let `xpos` be the lowest position, if possible, such that the following
|
| 457 |
+
conditions hold:
|
| 458 |
+
|
| 459 |
+
- `pos <= xpos`
|
| 460 |
+
- `xpos < size()`
|
| 461 |
+
- `traits::eq(at(xpos), str.at(I))` for some element `I` of the string
|
| 462 |
+
referenced by `str`.
|
| 463 |
+
|
| 464 |
+
*Effects:* Determines `xpos`.
|
| 465 |
+
|
| 466 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 467 |
+
Otherwise, returns `npos`.
|
| 468 |
+
|
| 469 |
+
``` cpp
|
| 470 |
+
constexpr size_type find_last_of(basic_string_view str, size_type pos = npos) const noexcept;
|
| 471 |
+
```
|
| 472 |
+
|
| 473 |
+
Let `xpos` be the highest position, if possible, such that the following
|
| 474 |
+
conditions hold:
|
| 475 |
+
|
| 476 |
+
- `xpos <= pos`
|
| 477 |
+
- `xpos < size()`
|
| 478 |
+
- `traits::eq(at(xpos), str.at(I))` for some element `I` of the string
|
| 479 |
+
referenced by `str`.
|
| 480 |
+
|
| 481 |
+
*Effects:* Determines `xpos`.
|
| 482 |
+
|
| 483 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 484 |
+
Otherwise, returns `npos`.
|
| 485 |
+
|
| 486 |
+
``` cpp
|
| 487 |
+
constexpr size_type find_first_not_of(basic_string_view str, size_type pos = 0) const noexcept;
|
| 488 |
+
```
|
| 489 |
+
|
| 490 |
+
Let `xpos` be the lowest position, if possible, such that the following
|
| 491 |
+
conditions hold:
|
| 492 |
+
|
| 493 |
+
- `pos <= xpos`
|
| 494 |
+
- `xpos < size()`
|
| 495 |
+
- `traits::eq(at(xpos), str.at(I))` for no element `I` of the string
|
| 496 |
+
referenced by `str`.
|
| 497 |
+
|
| 498 |
+
*Effects:* Determines `xpos`.
|
| 499 |
+
|
| 500 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 501 |
+
Otherwise, returns `npos`.
|
| 502 |
+
|
| 503 |
+
``` cpp
|
| 504 |
+
constexpr size_type find_last_not_of(basic_string_view str, size_type pos = npos) const noexcept;
|
| 505 |
+
```
|
| 506 |
+
|
| 507 |
+
Let `xpos` be the highest position, if possible, such that the following
|
| 508 |
+
conditions hold:
|
| 509 |
+
|
| 510 |
+
- `xpos <= pos`
|
| 511 |
+
- `xpos < size()`
|
| 512 |
+
- `traits::eq(at(xpos), str.at(I))` for no element `I` of the string
|
| 513 |
+
referenced by `str`.
|
| 514 |
+
|
| 515 |
+
*Effects:* Determines `xpos`.
|
| 516 |
+
|
| 517 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 518 |
+
Otherwise, returns `npos`.
|
| 519 |
+
|