tmp/tmpi7b70oy6/{from.md → to.md}
RENAMED
|
@@ -46,36 +46,43 @@ namespace std {
|
|
| 46 |
|
| 47 |
// [string.view.capacity], capacity
|
| 48 |
constexpr size_type size() const noexcept;
|
| 49 |
constexpr size_type length() const noexcept;
|
| 50 |
constexpr size_type max_size() const noexcept;
|
| 51 |
-
|
| 52 |
|
| 53 |
// [string.view.access], element access
|
| 54 |
constexpr const_reference operator[](size_type pos) const;
|
| 55 |
-
constexpr const_reference at(size_type pos) const;
|
| 56 |
constexpr const_reference front() const;
|
| 57 |
constexpr const_reference back() const;
|
| 58 |
constexpr const_pointer data() const noexcept;
|
| 59 |
|
| 60 |
// [string.view.modifiers], modifiers
|
| 61 |
constexpr void remove_prefix(size_type n);
|
| 62 |
constexpr void remove_suffix(size_type n);
|
| 63 |
constexpr void swap(basic_string_view& s) noexcept;
|
| 64 |
|
| 65 |
// [string.view.ops], string operations
|
| 66 |
-
constexpr size_type copy(charT* s, size_type n,
|
|
|
|
| 67 |
|
| 68 |
-
constexpr basic_string_view substr(size_type pos = 0,
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
constexpr int compare(basic_string_view s) const noexcept;
|
| 71 |
-
constexpr int compare(size_type pos1, size_type n1,
|
|
|
|
| 72 |
constexpr int compare(size_type pos1, size_type n1, basic_string_view s,
|
| 73 |
-
size_type pos2, size_type n2) const;
|
| 74 |
constexpr int compare(const charT* s) const;
|
| 75 |
-
constexpr int compare(size_type pos1, size_type n1,
|
| 76 |
-
|
|
|
|
|
|
|
| 77 |
|
| 78 |
constexpr bool starts_with(basic_string_view x) const noexcept;
|
| 79 |
constexpr bool starts_with(charT x) const noexcept;
|
| 80 |
constexpr bool starts_with(const charT* x) const;
|
| 81 |
constexpr bool ends_with(basic_string_view x) const noexcept;
|
|
@@ -139,15 +146,14 @@ same type as `charT`. — *end note*]
|
|
| 139 |
|
| 140 |
For a `basic_string_view str`, any operation that invalidates a pointer
|
| 141 |
in the range
|
| 142 |
|
| 143 |
``` cpp
|
| 144 |
-
{[}str.data(),
|
| 145 |
```
|
| 146 |
|
| 147 |
-
invalidates pointers, iterators, and references
|
| 148 |
-
member functions.
|
| 149 |
|
| 150 |
The complexity of `basic_string_view` member functions is 𝑂(1) unless
|
| 151 |
otherwise specified.
|
| 152 |
|
| 153 |
`basic_string_view<charT, traits>` is a trivially copyable type
|
|
@@ -157,31 +163,31 @@ otherwise specified.
|
|
| 157 |
|
| 158 |
``` cpp
|
| 159 |
constexpr basic_string_view() noexcept;
|
| 160 |
```
|
| 161 |
|
| 162 |
-
*Ensures:* `size_ == 0` and `data_ == nullptr`.
|
| 163 |
|
| 164 |
``` cpp
|
| 165 |
constexpr basic_string_view(const charT* str);
|
| 166 |
```
|
| 167 |
|
| 168 |
*Preconditions:* \[`str`, `str + traits::length(str)`) is a valid range.
|
| 169 |
|
| 170 |
-
*Effects:* Constructs a `basic_string_view`, initializing
|
| 171 |
-
`str` and initializing
|
| 172 |
|
| 173 |
*Complexity:* 𝑂(`traits::length(str)`).
|
| 174 |
|
| 175 |
``` cpp
|
| 176 |
constexpr basic_string_view(const charT* str, size_type len);
|
| 177 |
```
|
| 178 |
|
| 179 |
*Preconditions:* \[`str`, `str + len`) is a valid range.
|
| 180 |
|
| 181 |
-
*Effects:* Constructs a `basic_string_view`, initializing
|
| 182 |
-
`str` and initializing
|
| 183 |
|
| 184 |
``` cpp
|
| 185 |
template<class It, class End>
|
| 186 |
constexpr basic_string_view(It begin, End end);
|
| 187 |
```
|
|
@@ -197,12 +203,12 @@ template<class It, class End>
|
|
| 197 |
|
| 198 |
- \[`begin`, `end`) is a valid range.
|
| 199 |
- `It` models `contiguous_iterator`.
|
| 200 |
- `End` models `sized_sentinel_for<It>`.
|
| 201 |
|
| 202 |
-
*Effects:* Initializes
|
| 203 |
-
|
| 204 |
|
| 205 |
*Throws:* When and what `end - begin` throws.
|
| 206 |
|
| 207 |
``` cpp
|
| 208 |
template<class R>
|
|
@@ -218,11 +224,11 @@ Let `d` be an lvalue of type `remove_cvref_t<R>`.
|
|
| 218 |
- `is_same_v<ranges::range_value_t<R>, charT>` is `true`,
|
| 219 |
- `is_convertible_v<R, const charT*>` is `false`, and
|
| 220 |
- `d.operator ::std::basic_string_view<charT, traits>()` is not a valid
|
| 221 |
expression.
|
| 222 |
|
| 223 |
-
*Effects:* Initializes
|
| 224 |
`ranges::size(r)`.
|
| 225 |
|
| 226 |
*Throws:* Any exception thrown by `ranges::data(r)` and
|
| 227 |
`ranges::size(r)`.
|
| 228 |
|
|
@@ -265,11 +271,11 @@ constexpr const_iterator begin() const noexcept;
|
|
| 265 |
constexpr const_iterator cbegin() const noexcept;
|
| 266 |
```
|
| 267 |
|
| 268 |
*Returns:* An iterator such that
|
| 269 |
|
| 270 |
-
- if `!empty()`, `addressof(*begin()) == data_`,
|
| 271 |
- otherwise, an unspecified value such that \[`begin()`, `end()`) is a
|
| 272 |
valid range.
|
| 273 |
|
| 274 |
``` cpp
|
| 275 |
constexpr const_iterator end() const noexcept;
|
|
@@ -297,74 +303,73 @@ constexpr const_reverse_iterator crend() const noexcept;
|
|
| 297 |
``` cpp
|
| 298 |
constexpr size_type size() const noexcept;
|
| 299 |
constexpr size_type length() const noexcept;
|
| 300 |
```
|
| 301 |
|
| 302 |
-
*Returns:*
|
| 303 |
|
| 304 |
``` cpp
|
| 305 |
constexpr size_type max_size() const noexcept;
|
| 306 |
```
|
| 307 |
|
| 308 |
*Returns:* The largest possible number of char-like objects that can be
|
| 309 |
referred to by a `basic_string_view`.
|
| 310 |
|
| 311 |
``` cpp
|
| 312 |
-
|
| 313 |
```
|
| 314 |
|
| 315 |
-
*Returns:* `size_ == 0`.
|
| 316 |
|
| 317 |
#### Element access <a id="string.view.access">[[string.view.access]]</a>
|
| 318 |
|
| 319 |
``` cpp
|
| 320 |
constexpr const_reference operator[](size_type pos) const;
|
| 321 |
```
|
| 322 |
|
| 323 |
-
|
| 324 |
|
| 325 |
-
*
|
|
|
|
|
|
|
|
|
|
| 326 |
|
| 327 |
*Throws:* Nothing.
|
| 328 |
|
| 329 |
-
[*Note 1*: Unlike `basic_string::operator[]`,
|
| 330 |
-
`basic_string_view::operator[](size())` has undefined behavior instead
|
| 331 |
-
of returning `charT()`. — *end note*]
|
| 332 |
-
|
| 333 |
``` cpp
|
| 334 |
constexpr const_reference at(size_type pos) const;
|
| 335 |
```
|
| 336 |
|
| 337 |
-
*Returns:* `data_[pos]`.
|
| 338 |
|
| 339 |
*Throws:* `out_of_range` if `pos >= size()`.
|
| 340 |
|
| 341 |
``` cpp
|
| 342 |
constexpr const_reference front() const;
|
| 343 |
```
|
| 344 |
|
| 345 |
-
|
| 346 |
|
| 347 |
-
*Returns:* `data_[0]`.
|
| 348 |
|
| 349 |
*Throws:* Nothing.
|
| 350 |
|
| 351 |
``` cpp
|
| 352 |
constexpr const_reference back() const;
|
| 353 |
```
|
| 354 |
|
| 355 |
-
|
| 356 |
|
| 357 |
-
*Returns:* `data_[size() - 1]`.
|
| 358 |
|
| 359 |
*Throws:* Nothing.
|
| 360 |
|
| 361 |
``` cpp
|
| 362 |
constexpr const_pointer data() const noexcept;
|
| 363 |
```
|
| 364 |
|
| 365 |
-
*Returns:*
|
| 366 |
|
| 367 |
[*Note 2*: Unlike `basic_string::data()` and *string-literal*s,
|
| 368 |
`data()` can return a pointer to a buffer that is not null-terminated.
|
| 369 |
Therefore it is typically a mistake to pass `data()` to a function that
|
| 370 |
takes just a `const charT*` and expects a null-terminated
|
|
@@ -374,21 +379,21 @@ string. — *end note*]
|
|
| 374 |
|
| 375 |
``` cpp
|
| 376 |
constexpr void remove_prefix(size_type n);
|
| 377 |
```
|
| 378 |
|
| 379 |
-
|
| 380 |
|
| 381 |
-
*Effects:* Equivalent to: `data_ += n; size_ -= n;`
|
| 382 |
|
| 383 |
``` cpp
|
| 384 |
constexpr void remove_suffix(size_type n);
|
| 385 |
```
|
| 386 |
|
| 387 |
-
|
| 388 |
|
| 389 |
-
*Effects:* Equivalent to: `size_ -= n;`
|
| 390 |
|
| 391 |
``` cpp
|
| 392 |
constexpr void swap(basic_string_view& s) noexcept;
|
| 393 |
```
|
| 394 |
|
|
@@ -412,10 +417,11 @@ Let `rlen` be the smaller of `n` and `size() - pos`.
|
|
| 412 |
|
| 413 |
*Complexity:* 𝑂(`rlen`).
|
| 414 |
|
| 415 |
``` cpp
|
| 416 |
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
|
|
|
|
| 417 |
```
|
| 418 |
|
| 419 |
Let `rlen` be the smaller of `n` and `size() - pos`.
|
| 420 |
|
| 421 |
*Effects:* Determines `rlen`, the effective length of the string to
|
|
@@ -486,11 +492,13 @@ constexpr int compare(size_type pos1, size_type n1, const charT* s, size_type n2
|
|
| 486 |
|
| 487 |
``` cpp
|
| 488 |
constexpr bool starts_with(basic_string_view x) const noexcept;
|
| 489 |
```
|
| 490 |
|
| 491 |
-
|
|
|
|
|
|
|
| 492 |
|
| 493 |
``` cpp
|
| 494 |
constexpr bool starts_with(charT x) const noexcept;
|
| 495 |
```
|
| 496 |
|
|
@@ -504,14 +512,16 @@ constexpr bool starts_with(const charT* x) const;
|
|
| 504 |
|
| 505 |
``` cpp
|
| 506 |
constexpr bool ends_with(basic_string_view x) const noexcept;
|
| 507 |
```
|
| 508 |
|
|
|
|
|
|
|
| 509 |
*Effects:* Equivalent to:
|
| 510 |
|
| 511 |
``` cpp
|
| 512 |
-
return
|
| 513 |
```
|
| 514 |
|
| 515 |
``` cpp
|
| 516 |
constexpr bool ends_with(charT x) const noexcept;
|
| 517 |
```
|
|
@@ -568,12 +578,12 @@ constexpr size_type find(basic_string_view str, size_type pos = 0) const noexcep
|
|
| 568 |
Let `xpos` be the lowest position, if possible, such that the following
|
| 569 |
conditions hold:
|
| 570 |
|
| 571 |
- `pos <= xpos`
|
| 572 |
- `xpos + str.size() <= size()`
|
| 573 |
-
- `traits::eq(
|
| 574 |
-
string referenced by `str`.
|
| 575 |
|
| 576 |
*Effects:* Determines `xpos`.
|
| 577 |
|
| 578 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 579 |
Otherwise, returns `npos`.
|
|
@@ -585,12 +595,12 @@ constexpr size_type rfind(basic_string_view str, size_type pos = npos) const noe
|
|
| 585 |
Let `xpos` be the highest position, if possible, such that the following
|
| 586 |
conditions hold:
|
| 587 |
|
| 588 |
- `xpos <= pos`
|
| 589 |
- `xpos + str.size() <= size()`
|
| 590 |
-
- `traits::eq(
|
| 591 |
-
string referenced by `str`.
|
| 592 |
|
| 593 |
*Effects:* Determines `xpos`.
|
| 594 |
|
| 595 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 596 |
Otherwise, returns `npos`.
|
|
@@ -602,12 +612,12 @@ constexpr size_type find_first_of(basic_string_view str, size_type pos = 0) cons
|
|
| 602 |
Let `xpos` be the lowest position, if possible, such that the following
|
| 603 |
conditions hold:
|
| 604 |
|
| 605 |
- `pos <= xpos`
|
| 606 |
- `xpos < size()`
|
| 607 |
-
- `traits::eq(
|
| 608 |
-
referenced by `str`.
|
| 609 |
|
| 610 |
*Effects:* Determines `xpos`.
|
| 611 |
|
| 612 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 613 |
Otherwise, returns `npos`.
|
|
@@ -619,12 +629,12 @@ constexpr size_type find_last_of(basic_string_view str, size_type pos = npos) co
|
|
| 619 |
Let `xpos` be the highest position, if possible, such that the following
|
| 620 |
conditions hold:
|
| 621 |
|
| 622 |
- `xpos <= pos`
|
| 623 |
- `xpos < size()`
|
| 624 |
-
- `traits::eq(
|
| 625 |
-
referenced by `str`.
|
| 626 |
|
| 627 |
*Effects:* Determines `xpos`.
|
| 628 |
|
| 629 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 630 |
Otherwise, returns `npos`.
|
|
@@ -636,12 +646,12 @@ constexpr size_type find_first_not_of(basic_string_view str, size_type pos = 0)
|
|
| 636 |
Let `xpos` be the lowest position, if possible, such that the following
|
| 637 |
conditions hold:
|
| 638 |
|
| 639 |
- `pos <= xpos`
|
| 640 |
- `xpos < size()`
|
| 641 |
-
- `traits::eq(
|
| 642 |
-
referenced by `str`.
|
| 643 |
|
| 644 |
*Effects:* Determines `xpos`.
|
| 645 |
|
| 646 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 647 |
Otherwise, returns `npos`.
|
|
@@ -653,12 +663,12 @@ constexpr size_type find_last_not_of(basic_string_view str, size_type pos = npos
|
|
| 653 |
Let `xpos` be the highest position, if possible, such that the following
|
| 654 |
conditions hold:
|
| 655 |
|
| 656 |
- `xpos <= pos`
|
| 657 |
- `xpos < size()`
|
| 658 |
-
- `traits::eq(
|
| 659 |
-
referenced by `str`.
|
| 660 |
|
| 661 |
*Effects:* Determines `xpos`.
|
| 662 |
|
| 663 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 664 |
Otherwise, returns `npos`.
|
|
|
|
| 46 |
|
| 47 |
// [string.view.capacity], capacity
|
| 48 |
constexpr size_type size() const noexcept;
|
| 49 |
constexpr size_type length() const noexcept;
|
| 50 |
constexpr size_type max_size() const noexcept;
|
| 51 |
+
constexpr bool empty() const noexcept;
|
| 52 |
|
| 53 |
// [string.view.access], element access
|
| 54 |
constexpr const_reference operator[](size_type pos) const;
|
| 55 |
+
constexpr const_reference at(size_type pos) const; // freestanding-deleted
|
| 56 |
constexpr const_reference front() const;
|
| 57 |
constexpr const_reference back() const;
|
| 58 |
constexpr const_pointer data() const noexcept;
|
| 59 |
|
| 60 |
// [string.view.modifiers], modifiers
|
| 61 |
constexpr void remove_prefix(size_type n);
|
| 62 |
constexpr void remove_suffix(size_type n);
|
| 63 |
constexpr void swap(basic_string_view& s) noexcept;
|
| 64 |
|
| 65 |
// [string.view.ops], string operations
|
| 66 |
+
constexpr size_type copy(charT* s, size_type n,
|
| 67 |
+
size_type pos = 0) const; // freestanding-deleted
|
| 68 |
|
| 69 |
+
constexpr basic_string_view substr(size_type pos = 0,
|
| 70 |
+
size_type n = npos) const; // freestanding-deleted
|
| 71 |
+
constexpr basic_string_view subview(size_type pos = 0,
|
| 72 |
+
size_type n = npos) const; // freestanding-deleted
|
| 73 |
|
| 74 |
constexpr int compare(basic_string_view s) const noexcept;
|
| 75 |
+
constexpr int compare(size_type pos1, size_type n1,
|
| 76 |
+
basic_string_view s) const; // freestanding-deleted
|
| 77 |
constexpr int compare(size_type pos1, size_type n1, basic_string_view s,
|
| 78 |
+
size_type pos2, size_type n2) const; // freestanding-deleted
|
| 79 |
constexpr int compare(const charT* s) const;
|
| 80 |
+
constexpr int compare(size_type pos1, size_type n1,
|
| 81 |
+
const charT* s) const; // freestanding-deleted
|
| 82 |
+
constexpr int compare(size_type pos1, size_type n1, const charT* s,
|
| 83 |
+
size_type n2) const; // freestanding-deleted
|
| 84 |
|
| 85 |
constexpr bool starts_with(basic_string_view x) const noexcept;
|
| 86 |
constexpr bool starts_with(charT x) const noexcept;
|
| 87 |
constexpr bool starts_with(const charT* x) const;
|
| 88 |
constexpr bool ends_with(basic_string_view x) const noexcept;
|
|
|
|
| 146 |
|
| 147 |
For a `basic_string_view str`, any operation that invalidates a pointer
|
| 148 |
in the range
|
| 149 |
|
| 150 |
``` cpp
|
| 151 |
+
{[}str.data(), str.data() + str.size(){)}
|
| 152 |
```
|
| 153 |
|
| 154 |
+
invalidates pointers, iterators, and references to elements of `str`.
|
|
|
|
| 155 |
|
| 156 |
The complexity of `basic_string_view` member functions is 𝑂(1) unless
|
| 157 |
otherwise specified.
|
| 158 |
|
| 159 |
`basic_string_view<charT, traits>` is a trivially copyable type
|
|
|
|
| 163 |
|
| 164 |
``` cpp
|
| 165 |
constexpr basic_string_view() noexcept;
|
| 166 |
```
|
| 167 |
|
| 168 |
+
*Ensures:* *`size_`*` == 0` and *`data_`*` == nullptr`.
|
| 169 |
|
| 170 |
``` cpp
|
| 171 |
constexpr basic_string_view(const charT* str);
|
| 172 |
```
|
| 173 |
|
| 174 |
*Preconditions:* \[`str`, `str + traits::length(str)`) is a valid range.
|
| 175 |
|
| 176 |
+
*Effects:* Constructs a `basic_string_view`, initializing *data\_* with
|
| 177 |
+
`str` and initializing *size\_* with `traits::length(str)`.
|
| 178 |
|
| 179 |
*Complexity:* 𝑂(`traits::length(str)`).
|
| 180 |
|
| 181 |
``` cpp
|
| 182 |
constexpr basic_string_view(const charT* str, size_type len);
|
| 183 |
```
|
| 184 |
|
| 185 |
*Preconditions:* \[`str`, `str + len`) is a valid range.
|
| 186 |
|
| 187 |
+
*Effects:* Constructs a `basic_string_view`, initializing *data\_* with
|
| 188 |
+
`str` and initializing *size\_* with `len`.
|
| 189 |
|
| 190 |
``` cpp
|
| 191 |
template<class It, class End>
|
| 192 |
constexpr basic_string_view(It begin, End end);
|
| 193 |
```
|
|
|
|
| 203 |
|
| 204 |
- \[`begin`, `end`) is a valid range.
|
| 205 |
- `It` models `contiguous_iterator`.
|
| 206 |
- `End` models `sized_sentinel_for<It>`.
|
| 207 |
|
| 208 |
+
*Effects:* Initializes *data\_* with `to_address(begin)` and initializes
|
| 209 |
+
*size\_* with `end - begin`.
|
| 210 |
|
| 211 |
*Throws:* When and what `end - begin` throws.
|
| 212 |
|
| 213 |
``` cpp
|
| 214 |
template<class R>
|
|
|
|
| 224 |
- `is_same_v<ranges::range_value_t<R>, charT>` is `true`,
|
| 225 |
- `is_convertible_v<R, const charT*>` is `false`, and
|
| 226 |
- `d.operator ::std::basic_string_view<charT, traits>()` is not a valid
|
| 227 |
expression.
|
| 228 |
|
| 229 |
+
*Effects:* Initializes *data\_* with `ranges::data(r)` and *size\_* with
|
| 230 |
`ranges::size(r)`.
|
| 231 |
|
| 232 |
*Throws:* Any exception thrown by `ranges::data(r)` and
|
| 233 |
`ranges::size(r)`.
|
| 234 |
|
|
|
|
| 271 |
constexpr const_iterator cbegin() const noexcept;
|
| 272 |
```
|
| 273 |
|
| 274 |
*Returns:* An iterator such that
|
| 275 |
|
| 276 |
+
- if `!empty()`, `addressof(*begin()) == `*`data_`*,
|
| 277 |
- otherwise, an unspecified value such that \[`begin()`, `end()`) is a
|
| 278 |
valid range.
|
| 279 |
|
| 280 |
``` cpp
|
| 281 |
constexpr const_iterator end() const noexcept;
|
|
|
|
| 303 |
``` cpp
|
| 304 |
constexpr size_type size() const noexcept;
|
| 305 |
constexpr size_type length() const noexcept;
|
| 306 |
```
|
| 307 |
|
| 308 |
+
*Returns:* *size\_*.
|
| 309 |
|
| 310 |
``` cpp
|
| 311 |
constexpr size_type max_size() const noexcept;
|
| 312 |
```
|
| 313 |
|
| 314 |
*Returns:* The largest possible number of char-like objects that can be
|
| 315 |
referred to by a `basic_string_view`.
|
| 316 |
|
| 317 |
``` cpp
|
| 318 |
+
constexpr bool empty() const noexcept;
|
| 319 |
```
|
| 320 |
|
| 321 |
+
*Returns:* *`size_`*` == 0`.
|
| 322 |
|
| 323 |
#### Element access <a id="string.view.access">[[string.view.access]]</a>
|
| 324 |
|
| 325 |
``` cpp
|
| 326 |
constexpr const_reference operator[](size_type pos) const;
|
| 327 |
```
|
| 328 |
|
| 329 |
+
`pos < size()` is `true`.
|
| 330 |
|
| 331 |
+
[*Note 1*: This precondition is stronger than the one on
|
| 332 |
+
`basic_string::operator[]`. — *end note*]
|
| 333 |
+
|
| 334 |
+
*Returns:* *`data_`*`[pos]`.
|
| 335 |
|
| 336 |
*Throws:* Nothing.
|
| 337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
``` cpp
|
| 339 |
constexpr const_reference at(size_type pos) const;
|
| 340 |
```
|
| 341 |
|
| 342 |
+
*Returns:* *`data_`*`[pos]`.
|
| 343 |
|
| 344 |
*Throws:* `out_of_range` if `pos >= size()`.
|
| 345 |
|
| 346 |
``` cpp
|
| 347 |
constexpr const_reference front() const;
|
| 348 |
```
|
| 349 |
|
| 350 |
+
`empty()` is `false`.
|
| 351 |
|
| 352 |
+
*Returns:* *`data_`*`[0]`.
|
| 353 |
|
| 354 |
*Throws:* Nothing.
|
| 355 |
|
| 356 |
``` cpp
|
| 357 |
constexpr const_reference back() const;
|
| 358 |
```
|
| 359 |
|
| 360 |
+
`empty()` is `false`.
|
| 361 |
|
| 362 |
+
*Returns:* *`data_`*`[size() - 1]`.
|
| 363 |
|
| 364 |
*Throws:* Nothing.
|
| 365 |
|
| 366 |
``` cpp
|
| 367 |
constexpr const_pointer data() const noexcept;
|
| 368 |
```
|
| 369 |
|
| 370 |
+
*Returns:* *data\_*.
|
| 371 |
|
| 372 |
[*Note 2*: Unlike `basic_string::data()` and *string-literal*s,
|
| 373 |
`data()` can return a pointer to a buffer that is not null-terminated.
|
| 374 |
Therefore it is typically a mistake to pass `data()` to a function that
|
| 375 |
takes just a `const charT*` and expects a null-terminated
|
|
|
|
| 379 |
|
| 380 |
``` cpp
|
| 381 |
constexpr void remove_prefix(size_type n);
|
| 382 |
```
|
| 383 |
|
| 384 |
+
`n <= size()` is `true`.
|
| 385 |
|
| 386 |
+
*Effects:* Equivalent to: *`data_`*` += n; `*`size_`*` -= n;`
|
| 387 |
|
| 388 |
``` cpp
|
| 389 |
constexpr void remove_suffix(size_type n);
|
| 390 |
```
|
| 391 |
|
| 392 |
+
`n <= size()` is `true`.
|
| 393 |
|
| 394 |
+
*Effects:* Equivalent to: *`size_`*` -= n;`
|
| 395 |
|
| 396 |
``` cpp
|
| 397 |
constexpr void swap(basic_string_view& s) noexcept;
|
| 398 |
```
|
| 399 |
|
|
|
|
| 417 |
|
| 418 |
*Complexity:* 𝑂(`rlen`).
|
| 419 |
|
| 420 |
``` cpp
|
| 421 |
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
|
| 422 |
+
constexpr basic_string_view subview(size_type pos = 0, size_type n = npos) const;
|
| 423 |
```
|
| 424 |
|
| 425 |
Let `rlen` be the smaller of `n` and `size() - pos`.
|
| 426 |
|
| 427 |
*Effects:* Determines `rlen`, the effective length of the string to
|
|
|
|
| 492 |
|
| 493 |
``` cpp
|
| 494 |
constexpr bool starts_with(basic_string_view x) const noexcept;
|
| 495 |
```
|
| 496 |
|
| 497 |
+
Let `rlen` be the smaller of `size()` and `x.size()`.
|
| 498 |
+
|
| 499 |
+
*Effects:* Equivalent to: `return basic_string_view(data(), rlen) == x;`
|
| 500 |
|
| 501 |
``` cpp
|
| 502 |
constexpr bool starts_with(charT x) const noexcept;
|
| 503 |
```
|
| 504 |
|
|
|
|
| 512 |
|
| 513 |
``` cpp
|
| 514 |
constexpr bool ends_with(basic_string_view x) const noexcept;
|
| 515 |
```
|
| 516 |
|
| 517 |
+
Let `rlen` be the smaller of `size()` and `x.size()`.
|
| 518 |
+
|
| 519 |
*Effects:* Equivalent to:
|
| 520 |
|
| 521 |
``` cpp
|
| 522 |
+
return basic_string_view(data() + (size() - rlen), rlen) == x;
|
| 523 |
```
|
| 524 |
|
| 525 |
``` cpp
|
| 526 |
constexpr bool ends_with(charT x) const noexcept;
|
| 527 |
```
|
|
|
|
| 578 |
Let `xpos` be the lowest position, if possible, such that the following
|
| 579 |
conditions hold:
|
| 580 |
|
| 581 |
- `pos <= xpos`
|
| 582 |
- `xpos + str.size() <= size()`
|
| 583 |
+
- `traits::eq(`*`data_`*`[xpos + I], str[I])` for all elements `I` of
|
| 584 |
+
the string referenced by `str`.
|
| 585 |
|
| 586 |
*Effects:* Determines `xpos`.
|
| 587 |
|
| 588 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 589 |
Otherwise, returns `npos`.
|
|
|
|
| 595 |
Let `xpos` be the highest position, if possible, such that the following
|
| 596 |
conditions hold:
|
| 597 |
|
| 598 |
- `xpos <= pos`
|
| 599 |
- `xpos + str.size() <= size()`
|
| 600 |
+
- `traits::eq(`*`data_`*`[xpos + I], str[I])` for all elements `I` of
|
| 601 |
+
the string referenced by `str`.
|
| 602 |
|
| 603 |
*Effects:* Determines `xpos`.
|
| 604 |
|
| 605 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 606 |
Otherwise, returns `npos`.
|
|
|
|
| 612 |
Let `xpos` be the lowest position, if possible, such that the following
|
| 613 |
conditions hold:
|
| 614 |
|
| 615 |
- `pos <= xpos`
|
| 616 |
- `xpos < size()`
|
| 617 |
+
- `traits::eq(`*`data_`*`[xpos], str[I])` for some element `I` of the
|
| 618 |
+
string referenced by `str`.
|
| 619 |
|
| 620 |
*Effects:* Determines `xpos`.
|
| 621 |
|
| 622 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 623 |
Otherwise, returns `npos`.
|
|
|
|
| 629 |
Let `xpos` be the highest position, if possible, such that the following
|
| 630 |
conditions hold:
|
| 631 |
|
| 632 |
- `xpos <= pos`
|
| 633 |
- `xpos < size()`
|
| 634 |
+
- `traits::eq(`*`data_`*`[xpos], str[I])` for some element `I` of the
|
| 635 |
+
string referenced by `str`.
|
| 636 |
|
| 637 |
*Effects:* Determines `xpos`.
|
| 638 |
|
| 639 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 640 |
Otherwise, returns `npos`.
|
|
|
|
| 646 |
Let `xpos` be the lowest position, if possible, such that the following
|
| 647 |
conditions hold:
|
| 648 |
|
| 649 |
- `pos <= xpos`
|
| 650 |
- `xpos < size()`
|
| 651 |
+
- `traits::eq(`*`data_`*`[xpos], str[I])` for no element `I` of the
|
| 652 |
+
string referenced by `str`.
|
| 653 |
|
| 654 |
*Effects:* Determines `xpos`.
|
| 655 |
|
| 656 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 657 |
Otherwise, returns `npos`.
|
|
|
|
| 663 |
Let `xpos` be the highest position, if possible, such that the following
|
| 664 |
conditions hold:
|
| 665 |
|
| 666 |
- `xpos <= pos`
|
| 667 |
- `xpos < size()`
|
| 668 |
+
- `traits::eq(`*`data_`*`[xpos], str[I])` for no element `I` of the
|
| 669 |
+
string referenced by `str`.
|
| 670 |
|
| 671 |
*Effects:* Determines `xpos`.
|
| 672 |
|
| 673 |
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 674 |
Otherwise, returns `npos`.
|