From Jason Turner

[string.replace]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpem3iz_uc/{from.md → to.md} +25 -14
tmp/tmpem3iz_uc/{from.md → to.md} RENAMED
@@ -59,25 +59,25 @@ return replace(pos1, n1, sv.substr(pos2, n2));
59
  constexpr basic_string& replace(size_type pos1, size_type n1, const charT* s, size_type n2);
60
  ```
61
 
62
  *Preconditions:* \[`s`, `s + n2`) is a valid range.
63
 
64
- *Throws:*
65
-
66
- - `out_of_range` if `pos1 > size()`,
67
- - `length_error` if the length of the resulting string would exceed
68
- `max_size()` (see below), or
69
- - any exceptions thrown by `allocator_traits<Allocator>::allocate`.
70
-
71
  *Effects:* Determines the effective length `xlen` of the string to be
72
  removed as the smaller of `n1` and `size() - pos1`. If
73
  `size() - xlen >= max_size() - n2` throws `length_error`. Otherwise, the
74
  function replaces the characters in the range \[`begin() + pos1`,
75
  `begin() + pos1 + xlen`) with a copy of the range \[`s`, `s + n2`).
76
 
77
  *Returns:* `*this`.
78
 
 
 
 
 
 
 
 
79
  ``` cpp
80
  constexpr basic_string& replace(size_type pos, size_type n, const charT* s);
81
  ```
82
 
83
  *Effects:* Equivalent to:
@@ -85,25 +85,25 @@ constexpr basic_string& replace(size_type pos, size_type n, const charT* s);
85
 
86
  ``` cpp
87
  constexpr basic_string& replace(size_type pos1, size_type n1, size_type n2, charT c);
88
  ```
89
 
90
- *Throws:*
91
-
92
- - `out_of_range` if `pos1 > size()`,
93
- - `length_error` if the length of the resulting string would exceed
94
- `max_size()` (see below), or
95
- - any exceptions thrown by `allocator_traits<Allocator>::allocate.`
96
-
97
  *Effects:* Determines the effective length `xlen` of the string to be
98
  removed as the smaller of `n1` and `size() - pos1`. If
99
  `size() - xlen >=` `max_size() - n2` throws `length_error`. Otherwise,
100
  the function replaces the characters in the range \[`begin() + pos1`,
101
  `begin() + pos1 + xlen`) with `n2` copies of `c`.
102
 
103
  *Returns:* `*this`.
104
 
 
 
 
 
 
 
 
105
  ``` cpp
106
  constexpr basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
107
  ```
108
 
109
  *Effects:* Equivalent to:
@@ -161,10 +161,21 @@ template<class InputIterator>
161
  iterator [[container.requirements.general]].
162
 
163
  *Effects:* Equivalent to:
164
  `return replace(i1, i2, basic_string(j1, j2, get_allocator()));`
165
 
 
 
 
 
 
 
 
 
 
 
 
166
  ``` cpp
167
  constexpr basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<charT> il);
168
  ```
169
 
170
  *Effects:* Equivalent to:
 
59
  constexpr basic_string& replace(size_type pos1, size_type n1, const charT* s, size_type n2);
60
  ```
61
 
62
  *Preconditions:* \[`s`, `s + n2`) is a valid range.
63
 
 
 
 
 
 
 
 
64
  *Effects:* Determines the effective length `xlen` of the string to be
65
  removed as the smaller of `n1` and `size() - pos1`. If
66
  `size() - xlen >= max_size() - n2` throws `length_error`. Otherwise, the
67
  function replaces the characters in the range \[`begin() + pos1`,
68
  `begin() + pos1 + xlen`) with a copy of the range \[`s`, `s + n2`).
69
 
70
  *Returns:* `*this`.
71
 
72
+ *Throws:*
73
+
74
+ - `out_of_range` if `pos1 > size()`,
75
+ - `length_error` if the length of the resulting string would exceed
76
+ `max_size()`, or
77
+ - any exceptions thrown by `allocator_traits<Allocator>::allocate`.
78
+
79
  ``` cpp
80
  constexpr basic_string& replace(size_type pos, size_type n, const charT* s);
81
  ```
82
 
83
  *Effects:* Equivalent to:
 
85
 
86
  ``` cpp
87
  constexpr basic_string& replace(size_type pos1, size_type n1, size_type n2, charT c);
88
  ```
89
 
 
 
 
 
 
 
 
90
  *Effects:* Determines the effective length `xlen` of the string to be
91
  removed as the smaller of `n1` and `size() - pos1`. If
92
  `size() - xlen >=` `max_size() - n2` throws `length_error`. Otherwise,
93
  the function replaces the characters in the range \[`begin() + pos1`,
94
  `begin() + pos1 + xlen`) with `n2` copies of `c`.
95
 
96
  *Returns:* `*this`.
97
 
98
+ *Throws:*
99
+
100
+ - `out_of_range` if `pos1 > size()`,
101
+ - `length_error` if the length of the resulting string would
102
+ exceed`max_size()`, or
103
+ - any exceptions thrown by `allocator_traits<Allocator>::allocate.`
104
+
105
  ``` cpp
106
  constexpr basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
107
  ```
108
 
109
  *Effects:* Equivalent to:
 
161
  iterator [[container.requirements.general]].
162
 
163
  *Effects:* Equivalent to:
164
  `return replace(i1, i2, basic_string(j1, j2, get_allocator()));`
165
 
166
+ ``` cpp
167
+ template<container-compatible-range<charT> R>
168
+ constexpr basic_string& replace_with_range(const_iterator i1, const_iterator i2, R&& rg);
169
+ ```
170
+
171
+ *Effects:* Equivalent to:
172
+
173
+ ``` cpp
174
+ return replace(i1, i2, basic_string(from_range, std::forward<R>(rg), get_allocator()));
175
+ ```
176
+
177
  ``` cpp
178
  constexpr basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<charT> il);
179
  ```
180
 
181
  *Effects:* Equivalent to: