File tree 1 file changed +3
-1
lines changed
1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -162,17 +162,19 @@ std::string escape(const std::string &s)
162
162
163
163
// / Replace all occurrences of a string inside a string
164
164
// / \param [out] str: string to search
165
- // / \param from: string to replace
165
+ // / \param from: string to replace; must be non-empty
166
166
// / \param to: string to replace with
167
167
// / Copyright notice:
168
168
// / Attributed to Gauthier Boaglio
169
169
// / Source: https://stackoverflow.com/a/24315631/7501486
170
170
// / Used under MIT license
171
+ // / Note that this has quadratic complexity if from.size() != to.size()
171
172
void replace_all (
172
173
std::string &str,
173
174
const std::string &from,
174
175
const std::string &to)
175
176
{
177
+ PRECONDITION (from.size () != 0 );
176
178
size_t start_pos = 0 ;
177
179
while ((start_pos = str.find (from, start_pos)) != std::string::npos)
178
180
{
You can’t perform that action at this time.
0 commit comments