From Jason Turner

[string.insert]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4risfkh0/{from.md → to.md} +135 -0
tmp/tmp4risfkh0/{from.md → to.md} RENAMED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##### `basic_string::insert` <a id="string.insert">[[string.insert]]</a>
2
+
3
+ ``` cpp
4
+ basic_string&
5
+ insert(size_type pos,
6
+ const basic_string& str);
7
+ ```
8
+
9
+ *Effects:* Equivalent to: `return insert(pos, str.data(), str.size());`
10
+
11
+ ``` cpp
12
+ basic_string&
13
+ insert(size_type pos1,
14
+ const basic_string& str,
15
+ size_type pos2, size_type n = npos);
16
+ ```
17
+
18
+ *Throws:* `out_of_range` if `pos1 > size()` or `pos2 > str.size()`.
19
+
20
+ *Effects:* Determines the effective length `rlen` of the string to
21
+ insert as the smaller of `n` and `str.size() - pos2` and calls
22
+ `insert(pos1, str.data() + pos2, rlen)`.
23
+
24
+ *Returns:* `*this`.
25
+
26
+ ``` cpp
27
+ basic_string& insert(size_type pos, basic_string_view<charT, traits> sv);
28
+ ```
29
+
30
+ *Effects:* Equivalent to: `return insert(pos, sv.data(), sv.size());`
31
+
32
+ ``` cpp
33
+ template<class T>
34
+ basic_string& insert(size_type pos1, const T& t,
35
+ size_type pos2, size_type n = npos);
36
+ ```
37
+
38
+ *Throws:* `out_of_range` if `pos1 > size()` or `pos2 > sv.size()`.
39
+
40
+ *Effects:* Creates a variable, `sv`, as if by
41
+ `basic_string_view<charT, traits> sv = t`. Determines the effective
42
+ length `rlen` of the string to assign as the smaller of `n` and
43
+ `sv.size() - pos2` and calls `insert(pos1, sv.data() + pos2, rlen)`.
44
+
45
+ *Remarks:* This function shall not participate in overload resolution
46
+ unless `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
47
+ `true` and `is_convertible_v<const T&, const charT*>` is `false`.
48
+
49
+ *Returns:* `*this`.
50
+
51
+ ``` cpp
52
+ basic_string&
53
+ insert(size_type pos, const charT* s, size_type n);
54
+ ```
55
+
56
+ *Requires:* `s` points to an array of at least `n` elements of `charT`.
57
+
58
+ *Throws:* `out_of_range` if `pos > size()` or `length_error` if
59
+ `size() + n > max_size()`.
60
+
61
+ *Effects:* Replaces the string controlled by `*this` with a string of
62
+ length `size() + n` whose first `pos` elements are a copy of the initial
63
+ elements of the original string controlled by `*this` and whose next `n`
64
+ elements are a copy of the elements in `s` and whose remaining elements
65
+ are a copy of the remaining elements of the original string controlled
66
+ by `*this`.
67
+
68
+ *Returns:* `*this`.
69
+
70
+ ``` cpp
71
+ basic_string&
72
+ insert(size_type pos, const charT* s);
73
+ ```
74
+
75
+ *Requires:* `s` points to an array of at least `traits::length(s) + 1`
76
+ elements of `charT`.
77
+
78
+ *Effects:* Equivalent to: `return insert(pos, s, traits::length(s));`
79
+
80
+ ``` cpp
81
+ basic_string&
82
+ insert(size_type pos, size_type n, charT c);
83
+ ```
84
+
85
+ *Effects:* Equivalent to `insert(pos, basic_string(n, c))`.
86
+
87
+ *Returns:* `*this`.
88
+
89
+ ``` cpp
90
+ iterator insert(const_iterator p, charT c);
91
+ ```
92
+
93
+ *Requires:* `p` is a valid iterator on `*this`.
94
+
95
+ *Effects:* Inserts a copy of `c` before the character referred to by
96
+ `p`.
97
+
98
+ *Returns:* An iterator which refers to the copy of the inserted
99
+ character.
100
+
101
+ ``` cpp
102
+ iterator insert(const_iterator p, size_type n, charT c);
103
+ ```
104
+
105
+ *Requires:* `p` is a valid iterator on `*this`.
106
+
107
+ *Effects:* Inserts `n` copies of `c` before the character referred to by
108
+ `p`.
109
+
110
+ *Returns:* An iterator which refers to the copy of the first inserted
111
+ character, or `p` if `n == 0`.
112
+
113
+ ``` cpp
114
+ template<class InputIterator>
115
+ iterator insert(const_iterator p, InputIterator first, InputIterator last);
116
+ ```
117
+
118
+ *Requires:* `p` is a valid iterator on `*this`. `[first, last)` is a
119
+ valid range.
120
+
121
+ *Effects:* Equivalent to
122
+ `insert(p - begin(), basic_string(first, last, get_allocator()))`.
123
+
124
+ *Returns:* An iterator which refers to the copy of the first inserted
125
+ character, or `p` if `first == last`.
126
+
127
+ ``` cpp
128
+ iterator insert(const_iterator p, initializer_list<charT> il);
129
+ ```
130
+
131
+ *Effects:* As if by `insert(p, il.begin(), il.end())`.
132
+
133
+ *Returns:* An iterator which refers to the copy of the first inserted
134
+ character, or `p` if `i1` is empty.
135
+