tmp/tmp6vidwpxd/{from.md → to.md}
RENAMED
|
@@ -1,148 +0,0 @@
|
|
| 1 |
-
#### `basic_string::replace` <a id="string::replace">[[string::replace]]</a>
|
| 2 |
-
|
| 3 |
-
``` cpp
|
| 4 |
-
basic_string&
|
| 5 |
-
replace(size_type pos1, size_type n1,
|
| 6 |
-
const basic_string& str);
|
| 7 |
-
```
|
| 8 |
-
|
| 9 |
-
*Requires:* `pos1 <= size()`.
|
| 10 |
-
|
| 11 |
-
*Throws:* `out_of_range` if `pos1 > size()`.
|
| 12 |
-
|
| 13 |
-
*Effects:* Calls `replace(pos1, n1, str.data(), str.size())`.
|
| 14 |
-
|
| 15 |
-
*Returns:* `*this`.
|
| 16 |
-
|
| 17 |
-
``` cpp
|
| 18 |
-
basic_string&
|
| 19 |
-
replace(size_type pos1, size_type n1,
|
| 20 |
-
const basic_string& str,
|
| 21 |
-
size_type pos2, size_type n2 = npos);
|
| 22 |
-
```
|
| 23 |
-
|
| 24 |
-
*Requires:* `pos1 <= size()` and `pos2 <= str.size()`.
|
| 25 |
-
|
| 26 |
-
*Throws:* `out_of_range` if `pos1 > size()` or `pos2 > str.size()`.
|
| 27 |
-
|
| 28 |
-
*Effects:* Determines the effective length `rlen` of the string to be
|
| 29 |
-
inserted as the smaller of `n2` and `str.size() - pos2` and calls
|
| 30 |
-
`replace(pos1, n1, str.data() + pos2, rlen)`.
|
| 31 |
-
|
| 32 |
-
*Returns:* `*this`.
|
| 33 |
-
|
| 34 |
-
``` cpp
|
| 35 |
-
basic_string&
|
| 36 |
-
replace(size_type pos1, size_type n1, const charT* s, size_type n2);
|
| 37 |
-
```
|
| 38 |
-
|
| 39 |
-
*Requires:* `pos1 <= size()` and `s` points to an array of at least `n2`
|
| 40 |
-
elements of `charT`.
|
| 41 |
-
|
| 42 |
-
*Throws:* `out_of_range` if `pos1 > size()` or `length_error` if the
|
| 43 |
-
length of the resulting string would exceed `max_size()` (see below).
|
| 44 |
-
|
| 45 |
-
*Effects:* Determines the effective length `xlen` of the string to be
|
| 46 |
-
removed as the smaller of `n1` and `size() - pos1`. If
|
| 47 |
-
`size() - xlen >= max_size() - n2` throws `length_error`. Otherwise, the
|
| 48 |
-
function replaces the string controlled by \*`this` with a string of
|
| 49 |
-
length `size() - xlen + n2` whose first `pos1` elements are a copy of
|
| 50 |
-
the initial elements of the original string controlled by `*this`, whose
|
| 51 |
-
next `n2` elements are a copy of the initial `n2` elements of `s`, and
|
| 52 |
-
whose remaining elements are a copy of the elements of the original
|
| 53 |
-
string controlled by `*this` beginning at position `pos + xlen`.
|
| 54 |
-
|
| 55 |
-
*Returns:* `*this`.
|
| 56 |
-
|
| 57 |
-
``` cpp
|
| 58 |
-
basic_string&
|
| 59 |
-
replace(size_type pos, size_type n, const charT* s);
|
| 60 |
-
```
|
| 61 |
-
|
| 62 |
-
*Requires:* `pos <= size()` and `s` points to an array of at least
|
| 63 |
-
`traits::length(s) + 1` elements of `charT`.
|
| 64 |
-
|
| 65 |
-
*Effects:* Calls `replace(pos, n, s, traits::length(s))`.
|
| 66 |
-
|
| 67 |
-
*Returns:* `*this`.
|
| 68 |
-
|
| 69 |
-
``` cpp
|
| 70 |
-
basic_string&
|
| 71 |
-
replace(size_type pos1, size_type n1,
|
| 72 |
-
size_type n2, charT c);
|
| 73 |
-
```
|
| 74 |
-
|
| 75 |
-
*Effects:* Equivalent to `replace(pos1, n1, basic_string(n2, c))`.
|
| 76 |
-
|
| 77 |
-
*Returns:* `*this`.
|
| 78 |
-
|
| 79 |
-
``` cpp
|
| 80 |
-
basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
|
| 81 |
-
```
|
| 82 |
-
|
| 83 |
-
*Requires:* \[`begin()`, `i1`) and \[`i1`, `i2`) are valid ranges.
|
| 84 |
-
|
| 85 |
-
*Effects:* Calls `replace(i1 - begin(), i2 - i1, str)`.
|
| 86 |
-
|
| 87 |
-
*Returns:* `*this`.
|
| 88 |
-
|
| 89 |
-
``` cpp
|
| 90 |
-
basic_string&
|
| 91 |
-
replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
|
| 92 |
-
```
|
| 93 |
-
|
| 94 |
-
*Requires:* \[`begin()`, `i1`) and \[`i1`, `i2`) are valid ranges and
|
| 95 |
-
`s` points to an array of at least `n` elements of `charT`.
|
| 96 |
-
|
| 97 |
-
*Effects:* Calls `replace(i1 - begin(), i2 - i1, s, n)`.
|
| 98 |
-
|
| 99 |
-
*Returns:* `*this`.
|
| 100 |
-
|
| 101 |
-
``` cpp
|
| 102 |
-
basic_string& replace(const_iterator i1, const_iterator i2, const charT* s);
|
| 103 |
-
```
|
| 104 |
-
|
| 105 |
-
*Requires:* \[`begin()`, `i1`) and \[`i1`, `i2`) are valid ranges and
|
| 106 |
-
`s` points to an array of at least `traits::length(s) + 1` elements of
|
| 107 |
-
`charT`.
|
| 108 |
-
|
| 109 |
-
*Effects:* Calls `replace(i1 - begin(), i2 - i1, s, traits::length(s))`.
|
| 110 |
-
|
| 111 |
-
*Returns:* `*this`.
|
| 112 |
-
|
| 113 |
-
``` cpp
|
| 114 |
-
basic_string& replace(const_iterator i1, const_iterator i2, size_type n,
|
| 115 |
-
charT c);
|
| 116 |
-
```
|
| 117 |
-
|
| 118 |
-
*Requires:* \[`begin()`, `i1`) and \[`i1`, `i2`) are valid ranges.
|
| 119 |
-
|
| 120 |
-
*Effects:* Calls `replace(i1 - begin(), i2 - i1, basic_string(n, c))`.
|
| 121 |
-
|
| 122 |
-
*Returns:* `*this`.
|
| 123 |
-
|
| 124 |
-
``` cpp
|
| 125 |
-
template<class InputIterator>
|
| 126 |
-
basic_string& replace(const_iterator i1, const_iterator i2,
|
| 127 |
-
InputIterator j1, InputIterator j2);
|
| 128 |
-
```
|
| 129 |
-
|
| 130 |
-
*Requires:* \[`begin()`, `i1`), \[`i1`, `i2`) and \[`j1`, `j2`) are
|
| 131 |
-
valid ranges.
|
| 132 |
-
|
| 133 |
-
*Effects:* Calls `replace(i1 - begin(), i2 - i1, basic_string(j1, j2))`.
|
| 134 |
-
|
| 135 |
-
*Returns:* `*this`.
|
| 136 |
-
|
| 137 |
-
``` cpp
|
| 138 |
-
basic_string& replace(const_iterator i1, const_iterator i2,
|
| 139 |
-
initializer_list<charT> il);
|
| 140 |
-
```
|
| 141 |
-
|
| 142 |
-
*Requires:* \[`begin()`, `i1`) and \[`i1`, `i2`) are valid ranges.
|
| 143 |
-
|
| 144 |
-
*Effects:* Calls
|
| 145 |
-
`replace(i1 - begin(), i2 - i1, il.begin(), il.size())`.
|
| 146 |
-
|
| 147 |
-
*Returns:* `*this`.
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|