tmp/tmpuy2qncou/{from.md → to.md}
RENAMED
|
@@ -1,121 +0,0 @@
|
|
| 1 |
-
#### `basic_string::insert` <a id="string::insert">[[string::insert]]</a>
|
| 2 |
-
|
| 3 |
-
``` cpp
|
| 4 |
-
basic_string&
|
| 5 |
-
insert(size_type pos1,
|
| 6 |
-
const basic_string& str);
|
| 7 |
-
```
|
| 8 |
-
|
| 9 |
-
*Requires:* `pos <= size()`.
|
| 10 |
-
|
| 11 |
-
*Throws:* `out_of_range` if `pos > size()`.
|
| 12 |
-
|
| 13 |
-
*Effects:* Calls `insert(pos, str.data(), str.size())`.
|
| 14 |
-
|
| 15 |
-
*Returns:* `*this`.
|
| 16 |
-
|
| 17 |
-
``` cpp
|
| 18 |
-
basic_string&
|
| 19 |
-
insert(size_type pos1,
|
| 20 |
-
const basic_string& str,
|
| 21 |
-
size_type pos2, size_type n = 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
|
| 29 |
-
insert as the smaller of `n` and `str.size() - pos2` and calls
|
| 30 |
-
`insert(pos1, str.data() + pos2, rlen)`.
|
| 31 |
-
|
| 32 |
-
*Returns:* `*this`.
|
| 33 |
-
|
| 34 |
-
``` cpp
|
| 35 |
-
basic_string&
|
| 36 |
-
insert(size_type pos, const charT* s, size_type n);
|
| 37 |
-
```
|
| 38 |
-
|
| 39 |
-
*Requires:* `s` points to an array of at least `n` elements of `charT`
|
| 40 |
-
and `pos <= size()`.
|
| 41 |
-
|
| 42 |
-
*Throws:* `out_of_range` if `pos > size()` or `length_error` if
|
| 43 |
-
`size() + n > max_size()`.
|
| 44 |
-
|
| 45 |
-
*Effects:* Replaces the string controlled by `*this` with a string of
|
| 46 |
-
length `size() + n` whose first `pos` elements are a copy of the initial
|
| 47 |
-
elements of the original string controlled by `*this` and whose next `n`
|
| 48 |
-
elements are a copy of the elements in `s` and whose remaining elements
|
| 49 |
-
are a copy of the remaining elements of the original string controlled
|
| 50 |
-
by `*this`.
|
| 51 |
-
|
| 52 |
-
*Returns:* `*this`.
|
| 53 |
-
|
| 54 |
-
``` cpp
|
| 55 |
-
basic_string&
|
| 56 |
-
insert(size_type pos, const charT* s);
|
| 57 |
-
```
|
| 58 |
-
|
| 59 |
-
*Requires:* `pos <= size()` and `s` points to an array of at least
|
| 60 |
-
`traits::length(s) + 1` elements of `charT`.
|
| 61 |
-
|
| 62 |
-
*Effects:* Equivalent to `insert(pos, s, traits::length(s))`.
|
| 63 |
-
|
| 64 |
-
*Returns:* `*this`.
|
| 65 |
-
|
| 66 |
-
``` cpp
|
| 67 |
-
basic_string&
|
| 68 |
-
insert(size_type pos, size_type n, charT c);
|
| 69 |
-
```
|
| 70 |
-
|
| 71 |
-
*Effects:* Equivalent to `insert(pos, basic_string(n, c))`.
|
| 72 |
-
|
| 73 |
-
*Returns:* `*this`.
|
| 74 |
-
|
| 75 |
-
``` cpp
|
| 76 |
-
iterator insert(const_iterator p, charT c);
|
| 77 |
-
```
|
| 78 |
-
|
| 79 |
-
*Requires:* `p` is a valid iterator on `*this`.
|
| 80 |
-
|
| 81 |
-
*Effects:* inserts a copy of `c` before the character referred to by
|
| 82 |
-
`p`.
|
| 83 |
-
|
| 84 |
-
*Returns:* An iterator which refers to the copy of the inserted
|
| 85 |
-
character.
|
| 86 |
-
|
| 87 |
-
``` cpp
|
| 88 |
-
iterator insert(const_iterator p, size_type n, charT c);
|
| 89 |
-
```
|
| 90 |
-
|
| 91 |
-
*Requires:* `p` is a valid iterator on `*this`.
|
| 92 |
-
|
| 93 |
-
*Effects:* inserts `n` copies of `c` before the character referred to by
|
| 94 |
-
`p`.
|
| 95 |
-
|
| 96 |
-
*Returns:* An iterator which refers to the copy of the first inserted
|
| 97 |
-
character, or `p` if `n == 0`.
|
| 98 |
-
|
| 99 |
-
``` cpp
|
| 100 |
-
template<class InputIterator>
|
| 101 |
-
iterator insert(const_iterator p, InputIterator first, InputIterator last);
|
| 102 |
-
```
|
| 103 |
-
|
| 104 |
-
*Requires:* `p` is a valid iterator on `*this`. `[first,last)` is a
|
| 105 |
-
valid range.
|
| 106 |
-
|
| 107 |
-
*Effects:* Equivalent to
|
| 108 |
-
`insert(p - begin(), basic_string(first, last))`.
|
| 109 |
-
|
| 110 |
-
*Returns:* An iterator which refers to the copy of the first inserted
|
| 111 |
-
character, or `p` if `first == last`.
|
| 112 |
-
|
| 113 |
-
``` cpp
|
| 114 |
-
iterator insert(const_iterator p, initializer_list<charT> il);
|
| 115 |
-
```
|
| 116 |
-
|
| 117 |
-
*Effects:* `insert(p, il.begin(), il.end())`.
|
| 118 |
-
|
| 119 |
-
*Returns:* An iterator which refers to the copy of the first inserted
|
| 120 |
-
character, or `p` if `i1` is empty.
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|