- tmp/tmpc7nl_fq4/{from.md → to.md} +137 -60
tmp/tmpc7nl_fq4/{from.md → to.md}
RENAMED
|
@@ -15,16 +15,16 @@ manipulating varying-length sequences of char-like objects and five
|
|
| 15 |
#include <compare> // see [compare.syn]
|
| 16 |
#include <initializer_list> // see [initializer.list.syn]
|
| 17 |
|
| 18 |
namespace std {
|
| 19 |
// [char.traits], character traits
|
| 20 |
-
template<class charT> struct char_traits;
|
| 21 |
-
template<> struct char_traits<char>;
|
| 22 |
-
template<> struct char_traits<char8_t>;
|
| 23 |
-
template<> struct char_traits<char16_t>;
|
| 24 |
-
template<> struct char_traits<char32_t>;
|
| 25 |
-
template<> struct char_traits<wchar_t>;
|
| 26 |
|
| 27 |
// [basic.string], basic_string
|
| 28 |
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
|
| 29 |
class basic_string;
|
| 30 |
|
|
@@ -74,10 +74,26 @@ namespace std {
|
|
| 74 |
charT rhs);
|
| 75 |
template<class charT, class traits, class Allocator>
|
| 76 |
constexpr basic_string<charT, traits, Allocator>
|
| 77 |
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
| 78 |
charT rhs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
template<class charT, class traits, class Allocator>
|
| 81 |
constexpr bool
|
| 82 |
operator==(const basic_string<charT, traits, Allocator>& lhs,
|
| 83 |
const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
|
@@ -126,11 +142,11 @@ namespace std {
|
|
| 126 |
basic_istream<charT, traits>&
|
| 127 |
getline(basic_istream<charT, traits>&& is,
|
| 128 |
basic_string<charT, traits, Allocator>& str);
|
| 129 |
|
| 130 |
// [string.erasure], erasure
|
| 131 |
-
template<class charT, class traits, class Allocator, class U>
|
| 132 |
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
| 133 |
erase(basic_string<charT, traits, Allocator>& c, const U& value);
|
| 134 |
template<class charT, class traits, class Allocator, class Predicate>
|
| 135 |
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
| 136 |
erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred);
|
|
@@ -238,14 +254,14 @@ namespace std {
|
|
| 238 |
public:
|
| 239 |
// types
|
| 240 |
using traits_type = traits;
|
| 241 |
using value_type = charT;
|
| 242 |
using allocator_type = Allocator;
|
| 243 |
-
using size_type =
|
| 244 |
-
using difference_type =
|
| 245 |
-
using pointer =
|
| 246 |
-
using const_pointer =
|
| 247 |
using reference = value_type&;
|
| 248 |
using const_reference = const value_type&;
|
| 249 |
|
| 250 |
using iterator = implementation-defined // type of basic_string::iterator; // see [container.requirements]
|
| 251 |
using const_iterator = implementation-defined // type of basic_string::const_iterator; // see [container.requirements]
|
|
@@ -321,11 +337,11 @@ namespace std {
|
|
| 321 |
template<class Operation> constexpr void resize_and_overwrite(size_type n, Operation op);
|
| 322 |
constexpr size_type capacity() const noexcept;
|
| 323 |
constexpr void reserve(size_type res_arg);
|
| 324 |
constexpr void shrink_to_fit();
|
| 325 |
constexpr void clear() noexcept;
|
| 326 |
-
|
| 327 |
|
| 328 |
// [string.access], element access
|
| 329 |
constexpr const_reference operator[](size_type pos) const;
|
| 330 |
constexpr reference operator[](size_type pos);
|
| 331 |
constexpr const_reference at(size_type n) const;
|
|
@@ -487,10 +503,12 @@ namespace std {
|
|
| 487 |
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
|
| 488 |
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
|
| 489 |
|
| 490 |
constexpr basic_string substr(size_type pos = 0, size_type n = npos) const &;
|
| 491 |
constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&;
|
|
|
|
|
|
|
| 492 |
|
| 493 |
template<class T>
|
| 494 |
constexpr int compare(const T& t) const noexcept(see below);
|
| 495 |
template<class T>
|
| 496 |
constexpr int compare(size_type pos1, size_type n1, const T& t) const;
|
|
@@ -560,24 +578,23 @@ operation throws an exception object of type `length_error`.
|
|
| 560 |
|
| 561 |
If any member function or operator of `basic_string` throws an
|
| 562 |
exception, that function or operator has no other effect on the
|
| 563 |
`basic_string` object.
|
| 564 |
|
| 565 |
-
|
| 566 |
-
type `
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
`Allocator` to allocate and free storage for the contained `charT`
|
| 570 |
-
objects as needed. The `Allocator` object used is obtained as described
|
| 571 |
-
in [[container.requirements.general]]. In every specialization
|
| 572 |
`basic_string<charT, traits, Allocator>`, the type `traits` shall meet
|
| 573 |
the character traits requirements [[char.traits]].
|
| 574 |
|
| 575 |
[*Note 1*: Every specialization
|
| 576 |
-
`basic_string<charT, traits, Allocator>` is an allocator-aware
|
| 577 |
-
container, but does not use the allocator’s `construct`
|
| 578 |
-
member functions [[container.requirements.
|
|
|
|
|
|
|
| 579 |
|
| 580 |
[*Note 2*: The program is ill-formed if `traits::char_type` is not the
|
| 581 |
same type as `charT`. — *end note*]
|
| 582 |
|
| 583 |
References, pointers, and iterators referring to the elements of a
|
|
@@ -683,11 +700,11 @@ is equal to `0`.
|
|
| 683 |
``` cpp
|
| 684 |
constexpr basic_string(const charT* s, const Allocator& a = Allocator());
|
| 685 |
```
|
| 686 |
|
| 687 |
*Constraints:* `Allocator` is a type that qualifies as an
|
| 688 |
-
allocator [[container.
|
| 689 |
|
| 690 |
[*Note 1*: This affects class template argument
|
| 691 |
deduction. — *end note*]
|
| 692 |
|
| 693 |
*Effects:* Equivalent to: `basic_string(s, traits::length(s), a)`.
|
|
@@ -695,11 +712,11 @@ deduction. — *end note*]
|
|
| 695 |
``` cpp
|
| 696 |
constexpr basic_string(size_type n, charT c, const Allocator& a = Allocator());
|
| 697 |
```
|
| 698 |
|
| 699 |
*Constraints:* `Allocator` is a type that qualifies as an
|
| 700 |
-
allocator [[container.
|
| 701 |
|
| 702 |
[*Note 2*: This affects class template argument
|
| 703 |
deduction. — *end note*]
|
| 704 |
|
| 705 |
*Effects:* Constructs an object whose value consists of `n` copies of
|
|
@@ -709,11 +726,11 @@ deduction. — *end note*]
|
|
| 709 |
template<class InputIterator>
|
| 710 |
constexpr basic_string(InputIterator begin, InputIterator end, const Allocator& a = Allocator());
|
| 711 |
```
|
| 712 |
|
| 713 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 714 |
-
iterator [[container.
|
| 715 |
|
| 716 |
*Effects:* Constructs a string from the values in the range \[`begin`,
|
| 717 |
`end`), as specified in [[sequence.reqmts]].
|
| 718 |
|
| 719 |
``` cpp
|
|
@@ -751,11 +768,11 @@ template<class InputIterator,
|
|
| 751 |
Allocator>;
|
| 752 |
```
|
| 753 |
|
| 754 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 755 |
iterator, and `Allocator` is a type that qualifies as an
|
| 756 |
-
allocator [[container.
|
| 757 |
|
| 758 |
``` cpp
|
| 759 |
template<class charT,
|
| 760 |
class traits,
|
| 761 |
class Allocator = allocator<charT>>
|
|
@@ -770,11 +787,11 @@ template<class charT,
|
|
| 770 |
const Allocator& = Allocator())
|
| 771 |
-> basic_string<charT, traits, Allocator>;
|
| 772 |
```
|
| 773 |
|
| 774 |
*Constraints:* `Allocator` is a type that qualifies as an
|
| 775 |
-
allocator [[container.
|
| 776 |
|
| 777 |
``` cpp
|
| 778 |
constexpr basic_string& operator=(const basic_string& str);
|
| 779 |
```
|
| 780 |
|
|
@@ -787,13 +804,12 @@ Otherwise, replaces the value of `*this` with a copy of `str`.
|
|
| 787 |
constexpr basic_string& operator=(basic_string&& str)
|
| 788 |
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
|
| 789 |
allocator_traits<Allocator>::is_always_equal::value);
|
| 790 |
```
|
| 791 |
|
| 792 |
-
*Effects:* Move assigns as a sequence
|
| 793 |
-
|
| 794 |
-
and references may be invalidated.
|
| 795 |
|
| 796 |
*Returns:* `*this`.
|
| 797 |
|
| 798 |
``` cpp
|
| 799 |
template<class T>
|
|
@@ -959,14 +975,14 @@ constexpr size_type capacity() const noexcept;
|
|
| 959 |
constexpr void reserve(size_type res_arg);
|
| 960 |
```
|
| 961 |
|
| 962 |
*Effects:* A directive that informs a `basic_string` of a planned change
|
| 963 |
in size, so that the storage allocation can be managed accordingly.
|
| 964 |
-
|
| 965 |
-
`reserve` if reallocation happens; and equal to the previous
|
| 966 |
-
`capacity()` otherwise. Reallocation happens at this point if
|
| 967 |
-
if the current capacity is less than the argument of `reserve
|
| 968 |
|
| 969 |
*Throws:* `length_error` if `res_arg > max_size()` or any exceptions
|
| 970 |
thrown by `allocator_traits` `<Allocator>::allocate`.
|
| 971 |
|
| 972 |
``` cpp
|
|
@@ -997,11 +1013,11 @@ constexpr void clear() noexcept;
|
|
| 997 |
```
|
| 998 |
|
| 999 |
*Effects:* Equivalent to: `erase(begin(), end());`
|
| 1000 |
|
| 1001 |
``` cpp
|
| 1002 |
-
|
| 1003 |
```
|
| 1004 |
|
| 1005 |
*Effects:* Equivalent to: `return size() == 0;`
|
| 1006 |
|
| 1007 |
#### Element access <a id="string.access">[[string.access]]</a>
|
|
@@ -1009,11 +1025,11 @@ constexpr void clear() noexcept;
|
|
| 1009 |
``` cpp
|
| 1010 |
constexpr const_reference operator[](size_type pos) const;
|
| 1011 |
constexpr reference operator[](size_type pos);
|
| 1012 |
```
|
| 1013 |
|
| 1014 |
-
|
| 1015 |
|
| 1016 |
*Returns:* `*(begin() + pos)` if `pos < size()`. Otherwise, returns a
|
| 1017 |
reference to an object of type `charT` with value `charT()`, where
|
| 1018 |
modifying the object to any value other than `charT()` leads to
|
| 1019 |
undefined behavior.
|
|
@@ -1034,20 +1050,20 @@ constexpr reference at(size_type pos);
|
|
| 1034 |
``` cpp
|
| 1035 |
constexpr const charT& front() const;
|
| 1036 |
constexpr charT& front();
|
| 1037 |
```
|
| 1038 |
|
| 1039 |
-
|
| 1040 |
|
| 1041 |
*Effects:* Equivalent to: `return operator[](0);`
|
| 1042 |
|
| 1043 |
``` cpp
|
| 1044 |
constexpr const charT& back() const;
|
| 1045 |
constexpr charT& back();
|
| 1046 |
```
|
| 1047 |
|
| 1048 |
-
|
| 1049 |
|
| 1050 |
*Effects:* Equivalent to: `return operator[](size() - 1);`
|
| 1051 |
|
| 1052 |
#### Modifiers <a id="string.modifiers">[[string.modifiers]]</a>
|
| 1053 |
|
|
@@ -1177,11 +1193,11 @@ constexpr basic_string& append(size_type n, charT c);
|
|
| 1177 |
template<class InputIterator>
|
| 1178 |
constexpr basic_string& append(InputIterator first, InputIterator last);
|
| 1179 |
```
|
| 1180 |
|
| 1181 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 1182 |
-
iterator [[container.
|
| 1183 |
|
| 1184 |
*Effects:* Equivalent to:
|
| 1185 |
`return append(basic_string(first, last, get_allocator()));`
|
| 1186 |
|
| 1187 |
``` cpp
|
|
@@ -1305,11 +1321,11 @@ return *this;
|
|
| 1305 |
template<class InputIterator>
|
| 1306 |
constexpr basic_string& assign(InputIterator first, InputIterator last);
|
| 1307 |
```
|
| 1308 |
|
| 1309 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 1310 |
-
iterator [[container.
|
| 1311 |
|
| 1312 |
*Effects:* Equivalent to:
|
| 1313 |
`return assign(basic_string(first, last, get_allocator()));`
|
| 1314 |
|
| 1315 |
``` cpp
|
|
@@ -1405,11 +1421,11 @@ constexpr basic_string& insert(size_type pos, size_type n, charT c);
|
|
| 1405 |
```
|
| 1406 |
|
| 1407 |
*Effects:* Inserts `n` copies of `c` before the character at position
|
| 1408 |
`pos` if `pos < size()`, or otherwise at the end of the string.
|
| 1409 |
|
| 1410 |
-
*Returns:* `*this`
|
| 1411 |
|
| 1412 |
*Throws:*
|
| 1413 |
|
| 1414 |
- `out_of_range` if `pos > size()`,
|
| 1415 |
- `length_error` if `n > max_size() - size()`, or
|
|
@@ -1440,11 +1456,11 @@ constexpr iterator insert(const_iterator p, size_type n, charT c);
|
|
| 1440 |
template<class InputIterator>
|
| 1441 |
constexpr iterator insert(const_iterator p, InputIterator first, InputIterator last);
|
| 1442 |
```
|
| 1443 |
|
| 1444 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 1445 |
-
iterator [[container.
|
| 1446 |
|
| 1447 |
*Preconditions:* `p` is a valid iterator on `*this`.
|
| 1448 |
|
| 1449 |
*Effects:* Equivalent to
|
| 1450 |
`insert(p - begin(), basic_string(first, last, get_allocator()))`.
|
|
@@ -1504,11 +1520,11 @@ constexpr iterator erase(const_iterator first, const_iterator last);
|
|
| 1504 |
```
|
| 1505 |
|
| 1506 |
*Preconditions:* `first` and `last` are valid iterators on `*this`.
|
| 1507 |
\[`first`, `last`) is a valid range.
|
| 1508 |
|
| 1509 |
-
*Effects:* Removes the characters in the range
|
| 1510 |
|
| 1511 |
*Returns:* An iterator which points to the element pointed to by `last`
|
| 1512 |
prior to the other elements being erased. If no such element exists,
|
| 1513 |
`end()` is returned.
|
| 1514 |
|
|
@@ -1516,11 +1532,11 @@ prior to the other elements being erased. If no such element exists,
|
|
| 1516 |
|
| 1517 |
``` cpp
|
| 1518 |
constexpr void pop_back();
|
| 1519 |
```
|
| 1520 |
|
| 1521 |
-
|
| 1522 |
|
| 1523 |
*Effects:* Equivalent to `erase(end() - 1)`.
|
| 1524 |
|
| 1525 |
*Throws:* Nothing.
|
| 1526 |
|
|
@@ -1622,12 +1638,12 @@ the function replaces the characters in the range \[`begin() + pos1`,
|
|
| 1622 |
*Returns:* `*this`.
|
| 1623 |
|
| 1624 |
*Throws:*
|
| 1625 |
|
| 1626 |
- `out_of_range` if `pos1 > size()`,
|
| 1627 |
-
- `length_error` if the length of the resulting string would
|
| 1628 |
-
|
| 1629 |
- any exceptions thrown by `allocator_traits<Allocator>::allocate.`
|
| 1630 |
|
| 1631 |
``` cpp
|
| 1632 |
constexpr basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
|
| 1633 |
```
|
|
@@ -1682,11 +1698,11 @@ template<class InputIterator>
|
|
| 1682 |
constexpr basic_string& replace(const_iterator i1, const_iterator i2,
|
| 1683 |
InputIterator j1, InputIterator j2);
|
| 1684 |
```
|
| 1685 |
|
| 1686 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 1687 |
-
iterator [[container.
|
| 1688 |
|
| 1689 |
*Effects:* Equivalent to:
|
| 1690 |
`return replace(i1, i2, basic_string(j1, j2, get_allocator()));`
|
| 1691 |
|
| 1692 |
``` cpp
|
|
@@ -1862,10 +1878,17 @@ constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&;
|
|
| 1862 |
```
|
| 1863 |
|
| 1864 |
*Effects:* Equivalent to:
|
| 1865 |
`return basic_string(std::move(*this), pos, n);`
|
| 1866 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1867 |
##### `basic_string::compare` <a id="string.compare">[[string.compare]]</a>
|
| 1868 |
|
| 1869 |
``` cpp
|
| 1870 |
template<class T>
|
| 1871 |
constexpr int compare(const T& t) const noexcept(see below);
|
|
@@ -2149,10 +2172,74 @@ template<class charT, class traits, class Allocator>
|
|
| 2149 |
``` cpp
|
| 2150 |
lhs.push_back(rhs);
|
| 2151 |
return std::move(lhs);
|
| 2152 |
```
|
| 2153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2154 |
#### Non-member comparison operator functions <a id="string.cmp">[[string.cmp]]</a>
|
| 2155 |
|
| 2156 |
``` cpp
|
| 2157 |
template<class charT, class traits, class Allocator>
|
| 2158 |
constexpr bool
|
|
@@ -2277,11 +2364,11 @@ template<class charT, class traits, class Allocator>
|
|
| 2277 |
*Returns:* `getline(is, str, is.widen(’\n’))`.
|
| 2278 |
|
| 2279 |
#### Erasure <a id="string.erasure">[[string.erasure]]</a>
|
| 2280 |
|
| 2281 |
``` cpp
|
| 2282 |
-
template<class charT, class traits, class Allocator, class U>
|
| 2283 |
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
| 2284 |
erase(basic_string<charT, traits, Allocator>& c, const U& value);
|
| 2285 |
```
|
| 2286 |
|
| 2287 |
*Effects:* Equivalent to:
|
|
@@ -2367,16 +2454,11 @@ string to_string(unsigned long long val);
|
|
| 2367 |
string to_string(float val);
|
| 2368 |
string to_string(double val);
|
| 2369 |
string to_string(long double val);
|
| 2370 |
```
|
| 2371 |
|
| 2372 |
-
*Returns:*
|
| 2373 |
-
representation of the value of its argument that would be generated by
|
| 2374 |
-
calling `sprintf(buf, fmt, val)` with a format specifier of `"%d"`,
|
| 2375 |
-
`"%u"`, `"%ld"`, `"%lu"`, `"%lld"`, `"%llu"`, `"%f"`, `"%f"`, or
|
| 2376 |
-
`"%Lf"`, respectively, where `buf` designates an internal character
|
| 2377 |
-
buffer of sufficient size.
|
| 2378 |
|
| 2379 |
``` cpp
|
| 2380 |
int stoi(const wstring& str, size_t* idx = nullptr, int base = 10);
|
| 2381 |
long stol(const wstring& str, size_t* idx = nullptr, int base = 10);
|
| 2382 |
unsigned long stoul(const wstring& str, size_t* idx = nullptr, int base = 10);
|
|
@@ -2431,16 +2513,11 @@ wstring to_wstring(unsigned long long val);
|
|
| 2431 |
wstring to_wstring(float val);
|
| 2432 |
wstring to_wstring(double val);
|
| 2433 |
wstring to_wstring(long double val);
|
| 2434 |
```
|
| 2435 |
|
| 2436 |
-
*Returns:*
|
| 2437 |
-
character representation of the value of its argument that would be
|
| 2438 |
-
generated by calling `swprintf(buf, buffsz, fmt, val)` with a format
|
| 2439 |
-
specifier of `L"%d"`, `L"%u"`, `L"%ld"`, `L"%lu"`, `L"%lld"`, `L"%llu"`,
|
| 2440 |
-
`L"%f"`, `L"%f"`, or `L"%Lf"`, respectively, where `buf` designates an
|
| 2441 |
-
internal character buffer of sufficient size `buffsz`.
|
| 2442 |
|
| 2443 |
### Hash support <a id="basic.string.hash">[[basic.string.hash]]</a>
|
| 2444 |
|
| 2445 |
``` cpp
|
| 2446 |
template<class A> struct hash<basic_string<char, char_traits<char>, A>>;
|
|
|
|
| 15 |
#include <compare> // see [compare.syn]
|
| 16 |
#include <initializer_list> // see [initializer.list.syn]
|
| 17 |
|
| 18 |
namespace std {
|
| 19 |
// [char.traits], character traits
|
| 20 |
+
template<class charT> struct char_traits; // freestanding
|
| 21 |
+
template<> struct char_traits<char>; // freestanding
|
| 22 |
+
template<> struct char_traits<char8_t>; // freestanding
|
| 23 |
+
template<> struct char_traits<char16_t>; // freestanding
|
| 24 |
+
template<> struct char_traits<char32_t>; // freestanding
|
| 25 |
+
template<> struct char_traits<wchar_t>; // freestanding
|
| 26 |
|
| 27 |
// [basic.string], basic_string
|
| 28 |
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
|
| 29 |
class basic_string;
|
| 30 |
|
|
|
|
| 74 |
charT rhs);
|
| 75 |
template<class charT, class traits, class Allocator>
|
| 76 |
constexpr basic_string<charT, traits, Allocator>
|
| 77 |
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
| 78 |
charT rhs);
|
| 79 |
+
template<class charT, class traits, class Allocator>
|
| 80 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 81 |
+
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
| 82 |
+
type_identity_t<basic_string_view<charT, traits>> rhs);
|
| 83 |
+
template<class charT, class traits, class Allocator>
|
| 84 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 85 |
+
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
| 86 |
+
type_identity_t<basic_string_view<charT, traits>> rhs);
|
| 87 |
+
template<class charT, class traits, class Allocator>
|
| 88 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 89 |
+
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
|
| 90 |
+
const basic_string<charT, traits, Allocator>& rhs);
|
| 91 |
+
template<class charT, class traits, class Allocator>
|
| 92 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 93 |
+
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
|
| 94 |
+
basic_string<charT, traits, Allocator>&& rhs);
|
| 95 |
|
| 96 |
template<class charT, class traits, class Allocator>
|
| 97 |
constexpr bool
|
| 98 |
operator==(const basic_string<charT, traits, Allocator>& lhs,
|
| 99 |
const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
|
|
|
| 142 |
basic_istream<charT, traits>&
|
| 143 |
getline(basic_istream<charT, traits>&& is,
|
| 144 |
basic_string<charT, traits, Allocator>& str);
|
| 145 |
|
| 146 |
// [string.erasure], erasure
|
| 147 |
+
template<class charT, class traits, class Allocator, class U = charT>
|
| 148 |
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
| 149 |
erase(basic_string<charT, traits, Allocator>& c, const U& value);
|
| 150 |
template<class charT, class traits, class Allocator, class Predicate>
|
| 151 |
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
| 152 |
erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred);
|
|
|
|
| 254 |
public:
|
| 255 |
// types
|
| 256 |
using traits_type = traits;
|
| 257 |
using value_type = charT;
|
| 258 |
using allocator_type = Allocator;
|
| 259 |
+
using size_type = allocator_traits<Allocator>::size_type;
|
| 260 |
+
using difference_type = allocator_traits<Allocator>::difference_type;
|
| 261 |
+
using pointer = allocator_traits<Allocator>::pointer;
|
| 262 |
+
using const_pointer = allocator_traits<Allocator>::const_pointer;
|
| 263 |
using reference = value_type&;
|
| 264 |
using const_reference = const value_type&;
|
| 265 |
|
| 266 |
using iterator = implementation-defined // type of basic_string::iterator; // see [container.requirements]
|
| 267 |
using const_iterator = implementation-defined // type of basic_string::const_iterator; // see [container.requirements]
|
|
|
|
| 337 |
template<class Operation> constexpr void resize_and_overwrite(size_type n, Operation op);
|
| 338 |
constexpr size_type capacity() const noexcept;
|
| 339 |
constexpr void reserve(size_type res_arg);
|
| 340 |
constexpr void shrink_to_fit();
|
| 341 |
constexpr void clear() noexcept;
|
| 342 |
+
constexpr bool empty() const noexcept;
|
| 343 |
|
| 344 |
// [string.access], element access
|
| 345 |
constexpr const_reference operator[](size_type pos) const;
|
| 346 |
constexpr reference operator[](size_type pos);
|
| 347 |
constexpr const_reference at(size_type n) const;
|
|
|
|
| 503 |
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
|
| 504 |
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
|
| 505 |
|
| 506 |
constexpr basic_string substr(size_type pos = 0, size_type n = npos) const &;
|
| 507 |
constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&;
|
| 508 |
+
constexpr basic_string_view<charT, traits> subview(size_type pos = 0,
|
| 509 |
+
size_type n = npos) const;
|
| 510 |
|
| 511 |
template<class T>
|
| 512 |
constexpr int compare(const T& t) const noexcept(see below);
|
| 513 |
template<class T>
|
| 514 |
constexpr int compare(size_type pos1, size_type n1, const T& t) const;
|
|
|
|
| 578 |
|
| 579 |
If any member function or operator of `basic_string` throws an
|
| 580 |
exception, that function or operator has no other effect on the
|
| 581 |
`basic_string` object.
|
| 582 |
|
| 583 |
+
Every object of type `basic_string<charT, traits, Allocator>` uses an
|
| 584 |
+
object of type `Allocator` to allocate and free storage for the
|
| 585 |
+
contained `charT` objects as needed. The `Allocator` object used is
|
| 586 |
+
obtained as described in [[container.reqmts]]. In every specialization
|
|
|
|
|
|
|
|
|
|
| 587 |
`basic_string<charT, traits, Allocator>`, the type `traits` shall meet
|
| 588 |
the character traits requirements [[char.traits]].
|
| 589 |
|
| 590 |
[*Note 1*: Every specialization
|
| 591 |
+
`basic_string<charT, traits, Allocator>` is an allocator-aware container
|
| 592 |
+
[[container.alloc.reqmts]], but does not use the allocator’s `construct`
|
| 593 |
+
and `destroy` member functions [[container.requirements.pre]]. The
|
| 594 |
+
program is ill-formed if `Allocator::value_type` is not the same type as
|
| 595 |
+
`charT`. — *end note*]
|
| 596 |
|
| 597 |
[*Note 2*: The program is ill-formed if `traits::char_type` is not the
|
| 598 |
same type as `charT`. — *end note*]
|
| 599 |
|
| 600 |
References, pointers, and iterators referring to the elements of a
|
|
|
|
| 700 |
``` cpp
|
| 701 |
constexpr basic_string(const charT* s, const Allocator& a = Allocator());
|
| 702 |
```
|
| 703 |
|
| 704 |
*Constraints:* `Allocator` is a type that qualifies as an
|
| 705 |
+
allocator [[container.reqmts]].
|
| 706 |
|
| 707 |
[*Note 1*: This affects class template argument
|
| 708 |
deduction. — *end note*]
|
| 709 |
|
| 710 |
*Effects:* Equivalent to: `basic_string(s, traits::length(s), a)`.
|
|
|
|
| 712 |
``` cpp
|
| 713 |
constexpr basic_string(size_type n, charT c, const Allocator& a = Allocator());
|
| 714 |
```
|
| 715 |
|
| 716 |
*Constraints:* `Allocator` is a type that qualifies as an
|
| 717 |
+
allocator [[container.reqmts]].
|
| 718 |
|
| 719 |
[*Note 2*: This affects class template argument
|
| 720 |
deduction. — *end note*]
|
| 721 |
|
| 722 |
*Effects:* Constructs an object whose value consists of `n` copies of
|
|
|
|
| 726 |
template<class InputIterator>
|
| 727 |
constexpr basic_string(InputIterator begin, InputIterator end, const Allocator& a = Allocator());
|
| 728 |
```
|
| 729 |
|
| 730 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 731 |
+
iterator [[container.reqmts]].
|
| 732 |
|
| 733 |
*Effects:* Constructs a string from the values in the range \[`begin`,
|
| 734 |
`end`), as specified in [[sequence.reqmts]].
|
| 735 |
|
| 736 |
``` cpp
|
|
|
|
| 768 |
Allocator>;
|
| 769 |
```
|
| 770 |
|
| 771 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 772 |
iterator, and `Allocator` is a type that qualifies as an
|
| 773 |
+
allocator [[container.reqmts]].
|
| 774 |
|
| 775 |
``` cpp
|
| 776 |
template<class charT,
|
| 777 |
class traits,
|
| 778 |
class Allocator = allocator<charT>>
|
|
|
|
| 787 |
const Allocator& = Allocator())
|
| 788 |
-> basic_string<charT, traits, Allocator>;
|
| 789 |
```
|
| 790 |
|
| 791 |
*Constraints:* `Allocator` is a type that qualifies as an
|
| 792 |
+
allocator [[container.reqmts]].
|
| 793 |
|
| 794 |
``` cpp
|
| 795 |
constexpr basic_string& operator=(const basic_string& str);
|
| 796 |
```
|
| 797 |
|
|
|
|
| 804 |
constexpr basic_string& operator=(basic_string&& str)
|
| 805 |
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
|
| 806 |
allocator_traits<Allocator>::is_always_equal::value);
|
| 807 |
```
|
| 808 |
|
| 809 |
+
*Effects:* Move assigns as a sequence container [[sequence.reqmts]],
|
| 810 |
+
except that iterators, pointers and references may be invalidated.
|
|
|
|
| 811 |
|
| 812 |
*Returns:* `*this`.
|
| 813 |
|
| 814 |
``` cpp
|
| 815 |
template<class T>
|
|
|
|
| 975 |
constexpr void reserve(size_type res_arg);
|
| 976 |
```
|
| 977 |
|
| 978 |
*Effects:* A directive that informs a `basic_string` of a planned change
|
| 979 |
in size, so that the storage allocation can be managed accordingly.
|
| 980 |
+
Following a call to `reserve`, `capacity()` is greater or equal to the
|
| 981 |
+
argument of `reserve` if reallocation happens; and equal to the previous
|
| 982 |
+
value of `capacity()` otherwise. Reallocation happens at this point if
|
| 983 |
+
and only if the current capacity is less than the argument of `reserve`.
|
| 984 |
|
| 985 |
*Throws:* `length_error` if `res_arg > max_size()` or any exceptions
|
| 986 |
thrown by `allocator_traits` `<Allocator>::allocate`.
|
| 987 |
|
| 988 |
``` cpp
|
|
|
|
| 1013 |
```
|
| 1014 |
|
| 1015 |
*Effects:* Equivalent to: `erase(begin(), end());`
|
| 1016 |
|
| 1017 |
``` cpp
|
| 1018 |
+
constexpr bool empty() const noexcept;
|
| 1019 |
```
|
| 1020 |
|
| 1021 |
*Effects:* Equivalent to: `return size() == 0;`
|
| 1022 |
|
| 1023 |
#### Element access <a id="string.access">[[string.access]]</a>
|
|
|
|
| 1025 |
``` cpp
|
| 1026 |
constexpr const_reference operator[](size_type pos) const;
|
| 1027 |
constexpr reference operator[](size_type pos);
|
| 1028 |
```
|
| 1029 |
|
| 1030 |
+
`pos <= size()` is `true`.
|
| 1031 |
|
| 1032 |
*Returns:* `*(begin() + pos)` if `pos < size()`. Otherwise, returns a
|
| 1033 |
reference to an object of type `charT` with value `charT()`, where
|
| 1034 |
modifying the object to any value other than `charT()` leads to
|
| 1035 |
undefined behavior.
|
|
|
|
| 1050 |
``` cpp
|
| 1051 |
constexpr const charT& front() const;
|
| 1052 |
constexpr charT& front();
|
| 1053 |
```
|
| 1054 |
|
| 1055 |
+
`empty()` is `false`.
|
| 1056 |
|
| 1057 |
*Effects:* Equivalent to: `return operator[](0);`
|
| 1058 |
|
| 1059 |
``` cpp
|
| 1060 |
constexpr const charT& back() const;
|
| 1061 |
constexpr charT& back();
|
| 1062 |
```
|
| 1063 |
|
| 1064 |
+
`empty()` is `false`.
|
| 1065 |
|
| 1066 |
*Effects:* Equivalent to: `return operator[](size() - 1);`
|
| 1067 |
|
| 1068 |
#### Modifiers <a id="string.modifiers">[[string.modifiers]]</a>
|
| 1069 |
|
|
|
|
| 1193 |
template<class InputIterator>
|
| 1194 |
constexpr basic_string& append(InputIterator first, InputIterator last);
|
| 1195 |
```
|
| 1196 |
|
| 1197 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 1198 |
+
iterator [[container.reqmts]].
|
| 1199 |
|
| 1200 |
*Effects:* Equivalent to:
|
| 1201 |
`return append(basic_string(first, last, get_allocator()));`
|
| 1202 |
|
| 1203 |
``` cpp
|
|
|
|
| 1321 |
template<class InputIterator>
|
| 1322 |
constexpr basic_string& assign(InputIterator first, InputIterator last);
|
| 1323 |
```
|
| 1324 |
|
| 1325 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 1326 |
+
iterator [[container.reqmts]].
|
| 1327 |
|
| 1328 |
*Effects:* Equivalent to:
|
| 1329 |
`return assign(basic_string(first, last, get_allocator()));`
|
| 1330 |
|
| 1331 |
``` cpp
|
|
|
|
| 1421 |
```
|
| 1422 |
|
| 1423 |
*Effects:* Inserts `n` copies of `c` before the character at position
|
| 1424 |
`pos` if `pos < size()`, or otherwise at the end of the string.
|
| 1425 |
|
| 1426 |
+
*Returns:* `*this`.
|
| 1427 |
|
| 1428 |
*Throws:*
|
| 1429 |
|
| 1430 |
- `out_of_range` if `pos > size()`,
|
| 1431 |
- `length_error` if `n > max_size() - size()`, or
|
|
|
|
| 1456 |
template<class InputIterator>
|
| 1457 |
constexpr iterator insert(const_iterator p, InputIterator first, InputIterator last);
|
| 1458 |
```
|
| 1459 |
|
| 1460 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 1461 |
+
iterator [[container.reqmts]].
|
| 1462 |
|
| 1463 |
*Preconditions:* `p` is a valid iterator on `*this`.
|
| 1464 |
|
| 1465 |
*Effects:* Equivalent to
|
| 1466 |
`insert(p - begin(), basic_string(first, last, get_allocator()))`.
|
|
|
|
| 1520 |
```
|
| 1521 |
|
| 1522 |
*Preconditions:* `first` and `last` are valid iterators on `*this`.
|
| 1523 |
\[`first`, `last`) is a valid range.
|
| 1524 |
|
| 1525 |
+
*Effects:* Removes the characters in the range \[`first`, `last`).
|
| 1526 |
|
| 1527 |
*Returns:* An iterator which points to the element pointed to by `last`
|
| 1528 |
prior to the other elements being erased. If no such element exists,
|
| 1529 |
`end()` is returned.
|
| 1530 |
|
|
|
|
| 1532 |
|
| 1533 |
``` cpp
|
| 1534 |
constexpr void pop_back();
|
| 1535 |
```
|
| 1536 |
|
| 1537 |
+
`empty()` is `false`.
|
| 1538 |
|
| 1539 |
*Effects:* Equivalent to `erase(end() - 1)`.
|
| 1540 |
|
| 1541 |
*Throws:* Nothing.
|
| 1542 |
|
|
|
|
| 1638 |
*Returns:* `*this`.
|
| 1639 |
|
| 1640 |
*Throws:*
|
| 1641 |
|
| 1642 |
- `out_of_range` if `pos1 > size()`,
|
| 1643 |
+
- `length_error` if the length of the resulting string would exceed
|
| 1644 |
+
`max_size()`, or
|
| 1645 |
- any exceptions thrown by `allocator_traits<Allocator>::allocate.`
|
| 1646 |
|
| 1647 |
``` cpp
|
| 1648 |
constexpr basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
|
| 1649 |
```
|
|
|
|
| 1698 |
constexpr basic_string& replace(const_iterator i1, const_iterator i2,
|
| 1699 |
InputIterator j1, InputIterator j2);
|
| 1700 |
```
|
| 1701 |
|
| 1702 |
*Constraints:* `InputIterator` is a type that qualifies as an input
|
| 1703 |
+
iterator [[container.reqmts]].
|
| 1704 |
|
| 1705 |
*Effects:* Equivalent to:
|
| 1706 |
`return replace(i1, i2, basic_string(j1, j2, get_allocator()));`
|
| 1707 |
|
| 1708 |
``` cpp
|
|
|
|
| 1878 |
```
|
| 1879 |
|
| 1880 |
*Effects:* Equivalent to:
|
| 1881 |
`return basic_string(std::move(*this), pos, n);`
|
| 1882 |
|
| 1883 |
+
``` cpp
|
| 1884 |
+
constexpr basic_string_view<charT, traits> subview(size_type pos = 0, size_type n = npos) const;
|
| 1885 |
+
```
|
| 1886 |
+
|
| 1887 |
+
*Effects:* Equivalent to:
|
| 1888 |
+
`return basic_string_view<charT, traits>(*this).subview(pos, n);`
|
| 1889 |
+
|
| 1890 |
##### `basic_string::compare` <a id="string.compare">[[string.compare]]</a>
|
| 1891 |
|
| 1892 |
``` cpp
|
| 1893 |
template<class T>
|
| 1894 |
constexpr int compare(const T& t) const noexcept(see below);
|
|
|
|
| 2172 |
``` cpp
|
| 2173 |
lhs.push_back(rhs);
|
| 2174 |
return std::move(lhs);
|
| 2175 |
```
|
| 2176 |
|
| 2177 |
+
``` cpp
|
| 2178 |
+
template<class charT, class traits, class Allocator>
|
| 2179 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 2180 |
+
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
| 2181 |
+
type_identity_t<basic_string_view<charT, traits>> rhs);
|
| 2182 |
+
```
|
| 2183 |
+
|
| 2184 |
+
Equivalent to:
|
| 2185 |
+
|
| 2186 |
+
``` cpp
|
| 2187 |
+
basic_string<charT, traits, Allocator> r = lhs;
|
| 2188 |
+
r.append(rhs);
|
| 2189 |
+
return r;
|
| 2190 |
+
```
|
| 2191 |
+
|
| 2192 |
+
``` cpp
|
| 2193 |
+
template<class charT, class traits, class Allocator>
|
| 2194 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 2195 |
+
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
| 2196 |
+
type_identity_t<basic_string_view<charT, traits>> rhs);
|
| 2197 |
+
```
|
| 2198 |
+
|
| 2199 |
+
Equivalent to:
|
| 2200 |
+
|
| 2201 |
+
``` cpp
|
| 2202 |
+
lhs.append(rhs);
|
| 2203 |
+
return std::move(lhs);
|
| 2204 |
+
```
|
| 2205 |
+
|
| 2206 |
+
``` cpp
|
| 2207 |
+
template<class charT, class traits, class Allocator>
|
| 2208 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 2209 |
+
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
|
| 2210 |
+
const basic_string<charT, traits, Allocator>& rhs);
|
| 2211 |
+
```
|
| 2212 |
+
|
| 2213 |
+
Equivalent to:
|
| 2214 |
+
|
| 2215 |
+
``` cpp
|
| 2216 |
+
basic_string<charT, traits, Allocator> r = rhs;
|
| 2217 |
+
r.insert(0, lhs);
|
| 2218 |
+
return r;
|
| 2219 |
+
```
|
| 2220 |
+
|
| 2221 |
+
``` cpp
|
| 2222 |
+
template<class charT, class traits, class Allocator>
|
| 2223 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 2224 |
+
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
|
| 2225 |
+
basic_string<charT, traits, Allocator>&& rhs);
|
| 2226 |
+
```
|
| 2227 |
+
|
| 2228 |
+
Equivalent to:
|
| 2229 |
+
|
| 2230 |
+
``` cpp
|
| 2231 |
+
rhs.insert(0, lhs);
|
| 2232 |
+
return std::move(rhs);
|
| 2233 |
+
```
|
| 2234 |
+
|
| 2235 |
+
[*Note 1*: Using a specialization of `type_identity_t` as a parameter
|
| 2236 |
+
type ensures that an object of type
|
| 2237 |
+
`basic_string<charT, traits, Allocator>` can be concatenated with an
|
| 2238 |
+
object of a type `T` having an implicit conversion to
|
| 2239 |
+
`basic_string_view<charT, traits>` [[over.match.oper]]. — *end note*]
|
| 2240 |
+
|
| 2241 |
#### Non-member comparison operator functions <a id="string.cmp">[[string.cmp]]</a>
|
| 2242 |
|
| 2243 |
``` cpp
|
| 2244 |
template<class charT, class traits, class Allocator>
|
| 2245 |
constexpr bool
|
|
|
|
| 2364 |
*Returns:* `getline(is, str, is.widen(’\n’))`.
|
| 2365 |
|
| 2366 |
#### Erasure <a id="string.erasure">[[string.erasure]]</a>
|
| 2367 |
|
| 2368 |
``` cpp
|
| 2369 |
+
template<class charT, class traits, class Allocator, class U = charT>
|
| 2370 |
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
| 2371 |
erase(basic_string<charT, traits, Allocator>& c, const U& value);
|
| 2372 |
```
|
| 2373 |
|
| 2374 |
*Effects:* Equivalent to:
|
|
|
|
| 2454 |
string to_string(float val);
|
| 2455 |
string to_string(double val);
|
| 2456 |
string to_string(long double val);
|
| 2457 |
```
|
| 2458 |
|
| 2459 |
+
*Returns:* `format("{}", val)`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2460 |
|
| 2461 |
``` cpp
|
| 2462 |
int stoi(const wstring& str, size_t* idx = nullptr, int base = 10);
|
| 2463 |
long stol(const wstring& str, size_t* idx = nullptr, int base = 10);
|
| 2464 |
unsigned long stoul(const wstring& str, size_t* idx = nullptr, int base = 10);
|
|
|
|
| 2513 |
wstring to_wstring(float val);
|
| 2514 |
wstring to_wstring(double val);
|
| 2515 |
wstring to_wstring(long double val);
|
| 2516 |
```
|
| 2517 |
|
| 2518 |
+
*Returns:* `format(L"{}", val)`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2519 |
|
| 2520 |
### Hash support <a id="basic.string.hash">[[basic.string.hash]]</a>
|
| 2521 |
|
| 2522 |
``` cpp
|
| 2523 |
template<class A> struct hash<basic_string<char, char_traits<char>, A>>;
|