tmp/tmp3a943cl5/{from.md → to.md}
RENAMED
|
@@ -1,16 +1,16 @@
|
|
| 1 |
#### String operations <a id="string.view.ops">[[string.view.ops]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
-
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
| 5 |
```
|
| 6 |
|
| 7 |
Let `rlen` be the smaller of `n` and `size() - pos`.
|
| 8 |
|
| 9 |
*Throws:* `out_of_range` if `pos > size()`.
|
| 10 |
|
| 11 |
-
*
|
| 12 |
|
| 13 |
*Effects:* Equivalent to `traits::copy(s, data() + pos, rlen)`.
|
| 14 |
|
| 15 |
*Returns:* `rlen`.
|
| 16 |
|
|
@@ -41,13 +41,13 @@ compare. The function then compares the two strings by calling
|
|
| 41 |
|
| 42 |
*Complexity:* 𝑂(`rlen`).
|
| 43 |
|
| 44 |
*Returns:* The nonzero result if the result of the comparison is
|
| 45 |
nonzero. Otherwise, returns a value as indicated in
|
| 46 |
-
|
| 47 |
|
| 48 |
-
**Table: `compare()` results** <a id="
|
| 49 |
|
| 50 |
| Condition | Return Value |
|
| 51 |
| ---------------------- | ------------ |
|
| 52 |
| `size() < str.size()` | `< 0` |
|
| 53 |
| `size() == str.size()` | ` 0` |
|
|
@@ -79,12 +79,51 @@ constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
|
|
| 79 |
|
| 80 |
*Effects:* Equivalent to:
|
| 81 |
`return substr(pos1, n1).compare(basic_string_view(s));`
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
-
constexpr int compare(size_type pos1, size_type n1,
|
| 85 |
-
const charT* s, size_type n2) const;
|
| 86 |
```
|
| 87 |
|
| 88 |
*Effects:* Equivalent to:
|
| 89 |
`return substr(pos1, n1).compare(basic_string_view(s, n2));`
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#### String operations <a id="string.view.ops">[[string.view.ops]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
+
constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
| 5 |
```
|
| 6 |
|
| 7 |
Let `rlen` be the smaller of `n` and `size() - pos`.
|
| 8 |
|
| 9 |
*Throws:* `out_of_range` if `pos > size()`.
|
| 10 |
|
| 11 |
+
*Preconditions:* \[`s`, `s + rlen`) is a valid range.
|
| 12 |
|
| 13 |
*Effects:* Equivalent to `traits::copy(s, data() + pos, rlen)`.
|
| 14 |
|
| 15 |
*Returns:* `rlen`.
|
| 16 |
|
|
|
|
| 41 |
|
| 42 |
*Complexity:* 𝑂(`rlen`).
|
| 43 |
|
| 44 |
*Returns:* The nonzero result if the result of the comparison is
|
| 45 |
nonzero. Otherwise, returns a value as indicated in
|
| 46 |
+
[[string.view.compare]].
|
| 47 |
|
| 48 |
+
**Table: `compare()` results** <a id="string.view.compare">[string.view.compare]</a>
|
| 49 |
|
| 50 |
| Condition | Return Value |
|
| 51 |
| ---------------------- | ------------ |
|
| 52 |
| `size() < str.size()` | `< 0` |
|
| 53 |
| `size() == str.size()` | ` 0` |
|
|
|
|
| 79 |
|
| 80 |
*Effects:* Equivalent to:
|
| 81 |
`return substr(pos1, n1).compare(basic_string_view(s));`
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
+
constexpr int compare(size_type pos1, size_type n1, const charT* s, size_type n2) const;
|
|
|
|
| 85 |
```
|
| 86 |
|
| 87 |
*Effects:* Equivalent to:
|
| 88 |
`return substr(pos1, n1).compare(basic_string_view(s, n2));`
|
| 89 |
|
| 90 |
+
``` cpp
|
| 91 |
+
constexpr bool starts_with(basic_string_view x) const noexcept;
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
*Effects:* Equivalent to: `return substr(0, x.size()) == x;`
|
| 95 |
+
|
| 96 |
+
``` cpp
|
| 97 |
+
constexpr bool starts_with(charT x) const noexcept;
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
*Effects:* Equivalent to: `return !empty() && traits::eq(front(), x);`
|
| 101 |
+
|
| 102 |
+
``` cpp
|
| 103 |
+
constexpr bool starts_with(const charT* x) const;
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
*Effects:* Equivalent to: `return starts_with(basic_string_view(x));`
|
| 107 |
+
|
| 108 |
+
``` cpp
|
| 109 |
+
constexpr bool ends_with(basic_string_view x) const noexcept;
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
*Effects:* Equivalent to:
|
| 113 |
+
|
| 114 |
+
``` cpp
|
| 115 |
+
return size() >= x.size() && compare(size() - x.size(), npos, x) == 0;
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
``` cpp
|
| 119 |
+
constexpr bool ends_with(charT x) const noexcept;
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
*Effects:* Equivalent to: `return !empty() && traits::eq(back(), x);`
|
| 123 |
+
|
| 124 |
+
``` cpp
|
| 125 |
+
constexpr bool ends_with(const charT* x) const;
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
*Effects:* Equivalent to: `return ends_with(basic_string_view(x));`
|
| 129 |
+
|