- tmp/tmp80htf06w/{from.md → to.md} +113 -197
tmp/tmp80htf06w/{from.md → to.md}
RENAMED
|
@@ -1,312 +1,196 @@
|
|
| 1 |
-
###
|
| 2 |
|
| 3 |
-
#### `operator+` <a id="string.op
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
template<class charT, class traits, class Allocator>
|
| 7 |
-
basic_string<charT, traits, Allocator>
|
| 8 |
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
| 9 |
const basic_string<charT, traits, Allocator>& rhs);
|
| 10 |
-
```
|
| 11 |
-
|
| 12 |
-
*Returns:* `basic_string<charT, traits, Allocator>(lhs).append(rhs)`.
|
| 13 |
-
|
| 14 |
-
``` cpp
|
| 15 |
template<class charT, class traits, class Allocator>
|
| 16 |
-
basic_string<charT, traits, Allocator>
|
| 17 |
-
operator+(basic_string<charT, traits, Allocator>&
|
| 18 |
-
const basic_string<charT, traits, Allocator>& rhs);
|
| 19 |
```
|
| 20 |
|
| 21 |
-
*
|
| 22 |
|
| 23 |
``` cpp
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
basic_string<charT, traits, Allocator>&& rhs);
|
| 28 |
```
|
| 29 |
|
| 30 |
-
*Returns:* `std::move(rhs.insert(0, lhs))`.
|
| 31 |
-
|
| 32 |
``` cpp
|
| 33 |
template<class charT, class traits, class Allocator>
|
| 34 |
-
basic_string<charT, traits, Allocator>
|
| 35 |
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
| 36 |
-
basic_string<charT, traits, Allocator>&& rhs);
|
| 37 |
-
```
|
| 38 |
-
|
| 39 |
-
*Returns:* `std::move(lhs.append(rhs))`.
|
| 40 |
-
|
| 41 |
-
[*Note 1*: Or equivalently,
|
| 42 |
-
`std::move(rhs.insert(0, lhs))`. — *end note*]
|
| 43 |
-
|
| 44 |
-
``` cpp
|
| 45 |
-
template<class charT, class traits, class Allocator>
|
| 46 |
-
basic_string<charT, traits, Allocator>
|
| 47 |
-
operator+(const charT* lhs,
|
| 48 |
const basic_string<charT, traits, Allocator>& rhs);
|
| 49 |
-
```
|
| 50 |
-
|
| 51 |
-
*Returns:* `basic_string<charT, traits, Allocator>(lhs) + rhs`.
|
| 52 |
-
|
| 53 |
-
*Remarks:* Uses `traits::length()`.
|
| 54 |
-
|
| 55 |
-
``` cpp
|
| 56 |
template<class charT, class traits, class Allocator>
|
| 57 |
-
basic_string<charT, traits, Allocator>
|
| 58 |
-
operator+(const charT*
|
| 59 |
-
basic_string<charT, traits, Allocator>&& rhs);
|
| 60 |
```
|
| 61 |
|
| 62 |
-
*
|
| 63 |
-
|
| 64 |
-
*Remarks:* Uses `traits::length()`.
|
| 65 |
|
| 66 |
``` cpp
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
operator+(charT lhs,
|
| 70 |
-
const basic_string<charT, traits, Allocator>& rhs);
|
| 71 |
```
|
| 72 |
|
| 73 |
-
*Returns:* `basic_string<charT, traits, Allocator>(1, lhs) + rhs`.
|
| 74 |
-
|
| 75 |
``` cpp
|
| 76 |
template<class charT, class traits, class Allocator>
|
| 77 |
-
basic_string<charT, traits, Allocator>
|
| 78 |
-
operator+(charT lhs,
|
| 79 |
basic_string<charT, traits, Allocator>&& rhs);
|
| 80 |
```
|
| 81 |
|
| 82 |
-
*
|
| 83 |
|
| 84 |
``` cpp
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
| 88 |
-
const charT* rhs);
|
| 89 |
-
```
|
| 90 |
-
|
| 91 |
-
*Returns:* `lhs + basic_string<charT, traits, Allocator>(rhs)`.
|
| 92 |
-
|
| 93 |
-
*Remarks:* Uses `traits::length()`.
|
| 94 |
-
|
| 95 |
-
``` cpp
|
| 96 |
-
template<class charT, class traits, class Allocator>
|
| 97 |
-
basic_string<charT, traits, Allocator>
|
| 98 |
-
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
| 99 |
-
const charT* rhs);
|
| 100 |
```
|
| 101 |
|
| 102 |
-
|
|
|
|
| 103 |
|
| 104 |
-
*
|
|
|
|
| 105 |
|
| 106 |
``` cpp
|
| 107 |
template<class charT, class traits, class Allocator>
|
| 108 |
-
basic_string<charT, traits, Allocator>
|
| 109 |
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
| 110 |
-
charT rhs);
|
| 111 |
-
```
|
| 112 |
-
|
| 113 |
-
*Returns:* `lhs + basic_string<charT, traits, Allocator>(1, rhs)`.
|
| 114 |
-
|
| 115 |
-
``` cpp
|
| 116 |
template<class charT, class traits, class Allocator>
|
| 117 |
-
basic_string<charT, traits, Allocator>
|
| 118 |
-
operator+(basic_string<charT, traits, Allocator>&&
|
| 119 |
-
charT rhs);
|
| 120 |
```
|
| 121 |
|
| 122 |
-
*
|
| 123 |
-
|
| 124 |
-
#### `operator==` <a id="string.operator==">[[string.operator==]]</a>
|
| 125 |
|
| 126 |
``` cpp
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
| 130 |
```
|
| 131 |
|
| 132 |
-
*Returns:* `lhs.compare(rhs) == 0`.
|
| 133 |
-
|
| 134 |
``` cpp
|
| 135 |
template<class charT, class traits, class Allocator>
|
| 136 |
-
|
| 137 |
-
|
| 138 |
```
|
| 139 |
|
| 140 |
-
*
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
```
|
| 147 |
|
| 148 |
-
*Requires:* `rhs` points to an array of at least
|
| 149 |
-
`traits::length(rhs) + 1` elements of `charT`.
|
| 150 |
-
|
| 151 |
-
*Returns:* `lhs.compare(rhs) == 0`.
|
| 152 |
-
|
| 153 |
-
#### `operator!=` <a id="string.op!=">[[string.op!=]]</a>
|
| 154 |
-
|
| 155 |
``` cpp
|
| 156 |
template<class charT, class traits, class Allocator>
|
| 157 |
-
|
| 158 |
-
|
| 159 |
```
|
| 160 |
|
| 161 |
-
*
|
| 162 |
|
| 163 |
``` cpp
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
```
|
| 168 |
|
| 169 |
-
*Returns:* `rhs != lhs`.
|
| 170 |
-
|
| 171 |
``` cpp
|
| 172 |
template<class charT, class traits, class Allocator>
|
| 173 |
-
|
| 174 |
-
|
| 175 |
```
|
| 176 |
|
| 177 |
-
*
|
| 178 |
-
`traits::length(rhs) + 1` elements of `charT`.
|
| 179 |
-
|
| 180 |
-
*Returns:* `lhs.compare(rhs) != 0`.
|
| 181 |
-
|
| 182 |
-
#### `operator<` <a id="string.op<">[[string.op<]]</a>
|
| 183 |
|
| 184 |
``` cpp
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
| 188 |
```
|
| 189 |
|
| 190 |
-
*Returns:* `lhs.compare(rhs) < 0`.
|
| 191 |
-
|
| 192 |
``` cpp
|
| 193 |
template<class charT, class traits, class Allocator>
|
| 194 |
-
|
| 195 |
-
|
| 196 |
```
|
| 197 |
|
| 198 |
-
*
|
| 199 |
|
| 200 |
``` cpp
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
```
|
| 205 |
|
| 206 |
-
*Returns:* `lhs.compare(rhs) < 0`.
|
| 207 |
-
|
| 208 |
-
#### `operator>` <a id="string.op>">[[string.op>]]</a>
|
| 209 |
-
|
| 210 |
``` cpp
|
| 211 |
template<class charT, class traits, class Allocator>
|
| 212 |
-
|
| 213 |
-
|
| 214 |
```
|
| 215 |
|
| 216 |
-
*
|
| 217 |
|
| 218 |
``` cpp
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
const basic_string<charT, traits, Allocator>& rhs);
|
| 222 |
```
|
| 223 |
|
| 224 |
-
|
| 225 |
|
| 226 |
``` cpp
|
| 227 |
template<class charT, class traits, class Allocator>
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
```
|
| 231 |
-
|
| 232 |
-
*Returns:* `lhs.compare(rhs) > 0`.
|
| 233 |
-
|
| 234 |
-
#### `operator<=` <a id="string.op<=">[[string.op<=]]</a>
|
| 235 |
-
|
| 236 |
-
``` cpp
|
| 237 |
-
template<class charT, class traits, class Allocator>
|
| 238 |
-
bool operator<=(const basic_string<charT, traits, Allocator>& lhs,
|
| 239 |
const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
| 240 |
-
```
|
| 241 |
-
|
| 242 |
-
*Returns:* `lhs.compare(rhs) <= 0`.
|
| 243 |
-
|
| 244 |
-
``` cpp
|
| 245 |
template<class charT, class traits, class Allocator>
|
| 246 |
-
bool operator
|
| 247 |
-
const basic_string<charT, traits, Allocator>& rhs);
|
| 248 |
-
```
|
| 249 |
-
|
| 250 |
-
*Returns:* `rhs.compare(lhs) >= 0`.
|
| 251 |
-
|
| 252 |
-
``` cpp
|
| 253 |
-
template<class charT, class traits, class Allocator>
|
| 254 |
-
bool operator<=(const basic_string<charT, traits, Allocator>& lhs,
|
| 255 |
const charT* rhs);
|
| 256 |
-
```
|
| 257 |
|
| 258 |
-
*Returns:* `lhs.compare(rhs) <= 0`.
|
| 259 |
-
|
| 260 |
-
#### `operator>=` <a id="string.op>=">[[string.op>=]]</a>
|
| 261 |
-
|
| 262 |
-
``` cpp
|
| 263 |
template<class charT, class traits, class Allocator>
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
```
|
| 267 |
-
|
| 268 |
-
*Returns:* `lhs.compare(rhs) >= 0`.
|
| 269 |
-
|
| 270 |
-
``` cpp
|
| 271 |
template<class charT, class traits, class Allocator>
|
| 272 |
-
|
| 273 |
-
|
| 274 |
```
|
| 275 |
|
| 276 |
-
*
|
| 277 |
|
| 278 |
``` cpp
|
| 279 |
-
|
| 280 |
-
bool operator>=(const basic_string<charT, traits, Allocator>& lhs,
|
| 281 |
-
const charT* rhs);
|
| 282 |
```
|
| 283 |
|
| 284 |
-
*Returns:* `lhs.compare(rhs) >= 0`.
|
| 285 |
-
|
| 286 |
#### `swap` <a id="string.special">[[string.special]]</a>
|
| 287 |
|
| 288 |
``` cpp
|
| 289 |
template<class charT, class traits, class Allocator>
|
| 290 |
-
|
|
|
|
| 291 |
basic_string<charT, traits, Allocator>& rhs)
|
| 292 |
noexcept(noexcept(lhs.swap(rhs)));
|
| 293 |
```
|
| 294 |
|
| 295 |
-
*Effects:* Equivalent to
|
| 296 |
|
| 297 |
#### Inserters and extractors <a id="string.io">[[string.io]]</a>
|
| 298 |
|
| 299 |
``` cpp
|
| 300 |
template<class charT, class traits, class Allocator>
|
| 301 |
basic_istream<charT, traits>&
|
| 302 |
-
operator>>(basic_istream<charT, traits>& is,
|
| 303 |
-
basic_string<charT, traits, Allocator>& str);
|
| 304 |
```
|
| 305 |
|
| 306 |
*Effects:* Behaves as a formatted input
|
| 307 |
-
function
|
| 308 |
object, if the sentry converts to `true`, calls `str.erase()` and then
|
| 309 |
extracts characters from `is` and appends them to `str` as if by calling
|
| 310 |
`str.append(1, c)`. If `is.width()` is greater than zero, the maximum
|
| 311 |
number `n` of characters appended is `is.width()`; otherwise `n` is
|
| 312 |
`str.max_size()`. Characters are extracted and appended until any of the
|
|
@@ -319,12 +203,12 @@ following occurs:
|
|
| 319 |
|
| 320 |
After the last character (if any) is extracted, `is.width(0)` is called
|
| 321 |
and the `sentry` object is destroyed.
|
| 322 |
|
| 323 |
If the function extracts no characters, it calls
|
| 324 |
-
`is.setstate(
|
| 325 |
-
|
| 326 |
|
| 327 |
*Returns:* `is`.
|
| 328 |
|
| 329 |
``` cpp
|
| 330 |
template<class charT, class traits, class Allocator>
|
|
@@ -348,30 +232,30 @@ template<class charT, class traits, class Allocator>
|
|
| 348 |
basic_string<charT, traits, Allocator>& str,
|
| 349 |
charT delim);
|
| 350 |
```
|
| 351 |
|
| 352 |
*Effects:* Behaves as an unformatted input
|
| 353 |
-
function
|
| 354 |
value returned by subsequent calls to `basic_istream<>::gcount()`. After
|
| 355 |
constructing a `sentry` object, if the sentry converts to `true`, calls
|
| 356 |
`str.erase()` and then extracts characters from `is` and appends them to
|
| 357 |
`str` as if by calling `str.append(1, c)` until any of the following
|
| 358 |
occurs:
|
| 359 |
|
| 360 |
- end-of-file occurs on the input sequence (in which case, the `getline`
|
| 361 |
function calls `is.setstate(ios_base::eofbit)`).
|
| 362 |
- `traits::eq(c, delim)` for the next available input character *c* (in
|
| 363 |
-
which case, *c* is extracted but not appended)
|
| 364 |
- `str.max_size()` characters are stored (in which case, the function
|
| 365 |
-
calls `is.setstate(ios_base::failbit))`
|
| 366 |
|
| 367 |
The conditions are tested in the order shown. In any case, after the
|
| 368 |
last character is extracted, the `sentry` object is destroyed.
|
| 369 |
|
| 370 |
If the function extracts no characters, it calls
|
| 371 |
-
`is.setstate(ios_base::failbit)` which may throw
|
| 372 |
-
|
| 373 |
|
| 374 |
*Returns:* `is`.
|
| 375 |
|
| 376 |
``` cpp
|
| 377 |
template<class charT, class traits, class Allocator>
|
|
@@ -384,5 +268,37 @@ template<class charT, class traits, class Allocator>
|
|
| 384 |
basic_string<charT, traits, Allocator>& str);
|
| 385 |
```
|
| 386 |
|
| 387 |
*Returns:* `getline(is, str, is.widen(’\n’))`.
|
| 388 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Non-member functions <a id="string.nonmembers">[[string.nonmembers]]</a>
|
| 2 |
|
| 3 |
+
#### `operator+` <a id="string.op.plus">[[string.op.plus]]</a>
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
template<class charT, class traits, class Allocator>
|
| 7 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 8 |
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
| 9 |
const basic_string<charT, traits, Allocator>& rhs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
template<class charT, class traits, class Allocator>
|
| 11 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 12 |
+
operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);
|
|
|
|
| 13 |
```
|
| 14 |
|
| 15 |
+
*Effects:* Equivalent to:
|
| 16 |
|
| 17 |
``` cpp
|
| 18 |
+
basic_string<charT, traits, Allocator> r = lhs;
|
| 19 |
+
r.append(rhs);
|
| 20 |
+
return r;
|
|
|
|
| 21 |
```
|
| 22 |
|
|
|
|
|
|
|
| 23 |
``` cpp
|
| 24 |
template<class charT, class traits, class Allocator>
|
| 25 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 26 |
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
const basic_string<charT, traits, Allocator>& rhs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
template<class charT, class traits, class Allocator>
|
| 29 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 30 |
+
operator+(basic_string<charT, traits, Allocator>&& lhs, const charT* rhs);
|
|
|
|
| 31 |
```
|
| 32 |
|
| 33 |
+
*Effects:* Equivalent to:
|
|
|
|
|
|
|
| 34 |
|
| 35 |
``` cpp
|
| 36 |
+
lhs.append(rhs);
|
| 37 |
+
return std::move(lhs);
|
|
|
|
|
|
|
| 38 |
```
|
| 39 |
|
|
|
|
|
|
|
| 40 |
``` cpp
|
| 41 |
template<class charT, class traits, class Allocator>
|
| 42 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 43 |
+
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
| 44 |
basic_string<charT, traits, Allocator>&& rhs);
|
| 45 |
```
|
| 46 |
|
| 47 |
+
*Effects:* Equivalent to:
|
| 48 |
|
| 49 |
``` cpp
|
| 50 |
+
lhs.append(rhs);
|
| 51 |
+
return std::move(lhs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
```
|
| 53 |
|
| 54 |
+
except that both `lhs` and `rhs` are left in valid but unspecified
|
| 55 |
+
states.
|
| 56 |
|
| 57 |
+
[*Note 1*: If `lhs` and `rhs` have equal allocators, the implementation
|
| 58 |
+
may move from either. — *end note*]
|
| 59 |
|
| 60 |
``` cpp
|
| 61 |
template<class charT, class traits, class Allocator>
|
| 62 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 63 |
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
| 64 |
+
basic_string<charT, traits, Allocator>&& rhs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
template<class charT, class traits, class Allocator>
|
| 66 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 67 |
+
operator+(const charT* lhs, basic_string<charT, traits, Allocator>&& rhs);
|
|
|
|
| 68 |
```
|
| 69 |
|
| 70 |
+
*Effects:* Equivalent to:
|
|
|
|
|
|
|
| 71 |
|
| 72 |
``` cpp
|
| 73 |
+
rhs.insert(0, lhs);
|
| 74 |
+
return std::move(rhs);
|
|
|
|
| 75 |
```
|
| 76 |
|
|
|
|
|
|
|
| 77 |
``` cpp
|
| 78 |
template<class charT, class traits, class Allocator>
|
| 79 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 80 |
+
operator+(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs);
|
| 81 |
```
|
| 82 |
|
| 83 |
+
*Effects:* Equivalent to:
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
+
basic_string<charT, traits, Allocator> r = rhs;
|
| 87 |
+
r.insert(0, lhs);
|
| 88 |
+
return r;
|
| 89 |
```
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
``` cpp
|
| 92 |
template<class charT, class traits, class Allocator>
|
| 93 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 94 |
+
operator+(charT lhs, const basic_string<charT, traits, Allocator>& rhs);
|
| 95 |
```
|
| 96 |
|
| 97 |
+
*Effects:* Equivalent to:
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
+
basic_string<charT, traits, Allocator> r = rhs;
|
| 101 |
+
r.insert(r.begin(), lhs);
|
| 102 |
+
return r;
|
| 103 |
```
|
| 104 |
|
|
|
|
|
|
|
| 105 |
``` cpp
|
| 106 |
template<class charT, class traits, class Allocator>
|
| 107 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 108 |
+
operator+(charT lhs, basic_string<charT, traits, Allocator>&& rhs);
|
| 109 |
```
|
| 110 |
|
| 111 |
+
*Effects:* Equivalent to:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
``` cpp
|
| 114 |
+
rhs.insert(rhs.begin(), lhs);
|
| 115 |
+
return std::move(rhs);
|
|
|
|
| 116 |
```
|
| 117 |
|
|
|
|
|
|
|
| 118 |
``` cpp
|
| 119 |
template<class charT, class traits, class Allocator>
|
| 120 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 121 |
+
operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs);
|
| 122 |
```
|
| 123 |
|
| 124 |
+
*Effects:* Equivalent to:
|
| 125 |
|
| 126 |
``` cpp
|
| 127 |
+
basic_string<charT, traits, Allocator> r = lhs;
|
| 128 |
+
r.push_back(rhs);
|
| 129 |
+
return r;
|
| 130 |
```
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
``` cpp
|
| 133 |
template<class charT, class traits, class Allocator>
|
| 134 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 135 |
+
operator+(basic_string<charT, traits, Allocator>&& lhs, charT rhs);
|
| 136 |
```
|
| 137 |
|
| 138 |
+
*Effects:* Equivalent to:
|
| 139 |
|
| 140 |
``` cpp
|
| 141 |
+
lhs.push_back(rhs);
|
| 142 |
+
return std::move(lhs);
|
|
|
|
| 143 |
```
|
| 144 |
|
| 145 |
+
#### Non-member comparison functions <a id="string.cmp">[[string.cmp]]</a>
|
| 146 |
|
| 147 |
``` cpp
|
| 148 |
template<class charT, class traits, class Allocator>
|
| 149 |
+
constexpr bool
|
| 150 |
+
operator==(const basic_string<charT, traits, Allocator>& lhs,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
template<class charT, class traits, class Allocator>
|
| 153 |
+
constexpr bool operator==(const basic_string<charT, traits, Allocator>& lhs,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
const charT* rhs);
|
|
|
|
| 155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
template<class charT, class traits, class Allocator>
|
| 157 |
+
constexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,
|
| 158 |
+
\itcorr const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
template<class charT, class traits, class Allocator>
|
| 160 |
+
constexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,
|
| 161 |
+
\itcorr const charT* rhs);
|
| 162 |
```
|
| 163 |
|
| 164 |
+
*Effects:* Let *`op`* be the operator. Equivalent to:
|
| 165 |
|
| 166 |
``` cpp
|
| 167 |
+
return basic_string_view<charT, traits>(lhs) op basic_string_view<charT, traits>(rhs);
|
|
|
|
|
|
|
| 168 |
```
|
| 169 |
|
|
|
|
|
|
|
| 170 |
#### `swap` <a id="string.special">[[string.special]]</a>
|
| 171 |
|
| 172 |
``` cpp
|
| 173 |
template<class charT, class traits, class Allocator>
|
| 174 |
+
constexpr void
|
| 175 |
+
swap(basic_string<charT, traits, Allocator>& lhs,
|
| 176 |
basic_string<charT, traits, Allocator>& rhs)
|
| 177 |
noexcept(noexcept(lhs.swap(rhs)));
|
| 178 |
```
|
| 179 |
|
| 180 |
+
*Effects:* Equivalent to `lhs.swap(rhs)`.
|
| 181 |
|
| 182 |
#### Inserters and extractors <a id="string.io">[[string.io]]</a>
|
| 183 |
|
| 184 |
``` cpp
|
| 185 |
template<class charT, class traits, class Allocator>
|
| 186 |
basic_istream<charT, traits>&
|
| 187 |
+
operator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
|
|
|
|
| 188 |
```
|
| 189 |
|
| 190 |
*Effects:* Behaves as a formatted input
|
| 191 |
+
function [[istream.formatted.reqmts]]. After constructing a `sentry`
|
| 192 |
object, if the sentry converts to `true`, calls `str.erase()` and then
|
| 193 |
extracts characters from `is` and appends them to `str` as if by calling
|
| 194 |
`str.append(1, c)`. If `is.width()` is greater than zero, the maximum
|
| 195 |
number `n` of characters appended is `is.width()`; otherwise `n` is
|
| 196 |
`str.max_size()`. Characters are extracted and appended until any of the
|
|
|
|
| 203 |
|
| 204 |
After the last character (if any) is extracted, `is.width(0)` is called
|
| 205 |
and the `sentry` object is destroyed.
|
| 206 |
|
| 207 |
If the function extracts no characters, it calls
|
| 208 |
+
`is.setstate(ios_base::failbit)`, which may throw `ios_base::failure`
|
| 209 |
+
[[iostate.flags]].
|
| 210 |
|
| 211 |
*Returns:* `is`.
|
| 212 |
|
| 213 |
``` cpp
|
| 214 |
template<class charT, class traits, class Allocator>
|
|
|
|
| 232 |
basic_string<charT, traits, Allocator>& str,
|
| 233 |
charT delim);
|
| 234 |
```
|
| 235 |
|
| 236 |
*Effects:* Behaves as an unformatted input
|
| 237 |
+
function [[istream.unformatted]], except that it does not affect the
|
| 238 |
value returned by subsequent calls to `basic_istream<>::gcount()`. After
|
| 239 |
constructing a `sentry` object, if the sentry converts to `true`, calls
|
| 240 |
`str.erase()` and then extracts characters from `is` and appends them to
|
| 241 |
`str` as if by calling `str.append(1, c)` until any of the following
|
| 242 |
occurs:
|
| 243 |
|
| 244 |
- end-of-file occurs on the input sequence (in which case, the `getline`
|
| 245 |
function calls `is.setstate(ios_base::eofbit)`).
|
| 246 |
- `traits::eq(c, delim)` for the next available input character *c* (in
|
| 247 |
+
which case, *c* is extracted but not appended) [[iostate.flags]]
|
| 248 |
- `str.max_size()` characters are stored (in which case, the function
|
| 249 |
+
calls `is.setstate(ios_base::failbit))` [[iostate.flags]]
|
| 250 |
|
| 251 |
The conditions are tested in the order shown. In any case, after the
|
| 252 |
last character is extracted, the `sentry` object is destroyed.
|
| 253 |
|
| 254 |
If the function extracts no characters, it calls
|
| 255 |
+
`is.setstate(ios_base::failbit)` which may throw `ios_base::failure`
|
| 256 |
+
[[iostate.flags]].
|
| 257 |
|
| 258 |
*Returns:* `is`.
|
| 259 |
|
| 260 |
``` cpp
|
| 261 |
template<class charT, class traits, class Allocator>
|
|
|
|
| 268 |
basic_string<charT, traits, Allocator>& str);
|
| 269 |
```
|
| 270 |
|
| 271 |
*Returns:* `getline(is, str, is.widen(’\n’))`.
|
| 272 |
|
| 273 |
+
#### Erasure <a id="string.erasure">[[string.erasure]]</a>
|
| 274 |
+
|
| 275 |
+
``` cpp
|
| 276 |
+
template<class charT, class traits, class Allocator, class U>
|
| 277 |
+
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
| 278 |
+
erase(basic_string<charT, traits, Allocator>& c, const U& value);
|
| 279 |
+
```
|
| 280 |
+
|
| 281 |
+
*Effects:* Equivalent to:
|
| 282 |
+
|
| 283 |
+
``` cpp
|
| 284 |
+
auto it = remove(c.begin(), c.end(), value);
|
| 285 |
+
auto r = distance(it, c.end());
|
| 286 |
+
c.erase(it, c.end());
|
| 287 |
+
return r;
|
| 288 |
+
```
|
| 289 |
+
|
| 290 |
+
``` cpp
|
| 291 |
+
template<class charT, class traits, class Allocator, class Predicate>
|
| 292 |
+
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
| 293 |
+
erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred);
|
| 294 |
+
```
|
| 295 |
+
|
| 296 |
+
*Effects:* Equivalent to:
|
| 297 |
+
|
| 298 |
+
``` cpp
|
| 299 |
+
auto it = remove_if(c.begin(), c.end(), pred);
|
| 300 |
+
auto r = distance(it, c.end());
|
| 301 |
+
c.erase(it, c.end());
|
| 302 |
+
return r;
|
| 303 |
+
```
|
| 304 |
+
|