From Jason Turner

[string.insert]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpwtyq4ari/{from.md → to.md} +69 -66
tmp/tmpwtyq4ari/{from.md → to.md} RENAMED
@@ -1,135 +1,138 @@
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
 
 
1
  ##### `basic_string::insert` <a id="string.insert">[[string.insert]]</a>
2
 
3
  ``` cpp
4
+ constexpr basic_string& insert(size_type pos, const basic_string& str);
 
 
5
  ```
6
 
7
  *Effects:* Equivalent to: `return insert(pos, str.data(), str.size());`
8
 
9
  ``` cpp
10
+ constexpr basic_string& insert(size_type pos1, const basic_string& str,
 
 
11
  size_type pos2, size_type n = npos);
12
  ```
13
 
14
+ *Effects:* Equivalent to:
15
 
16
+ ``` cpp
17
+ return insert(pos1, basic_string_view<charT, traits>(str), pos2, n);
18
+ ```
 
 
19
 
20
  ``` cpp
21
+ template<class T>
22
+ constexpr basic_string& insert(size_type pos, const T& t);
23
  ```
24
 
25
+ *Constraints:*
26
+
27
+ - `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
28
+ `true` and
29
+ - `is_convertible_v<const T&, const charT*>` is `false`.
30
+
31
+ *Effects:* Equivalent to:
32
+
33
+ ``` cpp
34
+ basic_string_view<charT, traits> sv = t;
35
+ return insert(pos, sv.data(), sv.size());
36
+ ```
37
 
38
  ``` cpp
39
  template<class T>
40
+ constexpr basic_string& insert(size_type pos1, const T& t,
41
  size_type pos2, size_type n = npos);
42
  ```
43
 
44
+ *Constraints:*
45
 
46
+ - `is_convertible_v<const T&, basic_string_view<charT, traits>>` is
47
+ `true` and
48
+ - `is_convertible_v<const T&, const charT*>` is `false`.
 
49
 
50
+ *Effects:* Equivalent to:
 
 
51
 
52
+ ``` cpp
53
+ basic_string_view<charT, traits> sv = t;
54
+ return insert(pos1, sv.substr(pos2, n));
55
+ ```
56
 
57
  ``` cpp
58
+ constexpr basic_string& insert(size_type pos, const charT* s, size_type n);
 
59
  ```
60
 
61
+ *Preconditions:* \[`s`, `s + n`) is a valid range.
62
+
63
+ *Throws:*
64
 
65
+ - `out_of_range` if `pos > size()`,
66
+ - `length_error` if `n > max_size() - size()`, or
67
+ - any exceptions thrown by `allocator_traits<Allocator>::allocate`.
68
 
69
+ *Effects:* Inserts a copy of the range \[`s`, `s + n`) immediately
70
+ before the character at position `pos` if `pos < size()`, or otherwise
71
+ at the end of the string.
 
 
 
72
 
73
  *Returns:* `*this`.
74
 
75
  ``` cpp
76
+ constexpr basic_string& insert(size_type pos, const charT* s);
 
77
  ```
78
 
 
 
 
79
  *Effects:* Equivalent to: `return insert(pos, s, traits::length(s));`
80
 
81
  ``` cpp
82
+ constexpr basic_string& insert(size_type pos, size_type n, charT c);
 
83
  ```
84
 
85
+ *Effects:* Inserts `n` copies of `c` before the character at position
86
+ `pos` if `pos < size()`, or otherwise at the end of the string.
87
 
88
+ *Returns:* `*this`
89
+
90
+ *Throws:*
91
+
92
+ - `out_of_range` if `pos > size()`,
93
+ - `length_error` if `n > max_size() - size()`, or
94
+ - any exceptions thrown by `allocator_traits<Allocator>::allocate`.
95
 
96
  ``` cpp
97
+ constexpr iterator insert(const_iterator p, charT c);
98
  ```
99
 
100
+ *Preconditions:* `p` is a valid iterator on `*this`.
101
 
102
+ *Effects:* Inserts a copy of `c` at the position `p`.
 
103
 
104
+ *Returns:* An iterator which refers to the inserted character.
 
105
 
106
  ``` cpp
107
+ constexpr iterator insert(const_iterator p, size_type n, charT c);
108
  ```
109
 
110
+ *Preconditions:* `p` is a valid iterator on `*this`.
111
 
112
+ *Effects:* Inserts `n` copies of `c` at the position `p`.
 
113
 
114
+ *Returns:* An iterator which refers to the first inserted character, or
115
+ `p` if `n == 0`.
116
 
117
  ``` cpp
118
  template<class InputIterator>
119
+ constexpr iterator insert(const_iterator p, InputIterator first, InputIterator last);
120
  ```
121
 
122
+ *Constraints:* `InputIterator` is a type that qualifies as an input
123
+ iterator [[container.requirements.general]].
124
+
125
+ *Preconditions:* `p` is a valid iterator on `*this`.
126
 
127
  *Effects:* Equivalent to
128
  `insert(p - begin(), basic_string(first, last, get_allocator()))`.
129
 
130
+ *Returns:* An iterator which refers to the first inserted character, or
131
+ `p` if `first == last`.
132
 
133
  ``` cpp
134
+ constexpr iterator insert(const_iterator p, initializer_list<charT> il);
135
  ```
136
 
137
+ *Effects:* Equivalent to: `return insert(p, il.begin(), il.end());`
 
 
 
138