We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The loop can't stop if there is a string in the list (type: forward_list) that can match to_find (type: string)
list
to_find
void find_and_insert(forward_list<string> &list, const string& to_find, const string& to_add) { auto prev = list.before_begin(); auto size = std::distance(list.begin(), list.end()); for (auto curr = list.begin(); curr != list.end(); prev = curr++) if (*curr == to_find) list.insert_after(curr, to_add); if (size == std::distance(list.begin(), list.end())) list.insert_after(prev, to_add); }
The code should be modified in this line:
if (*curr == to_find) curr = list.insert_after(curr, to_add);
best regards!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The loop can't stop if there is a string in the
list
(type: forward_list) that can matchto_find
(type: string)The code should be modified in this line:
if (*curr == to_find) curr = list.insert_after(curr, to_add);
best regards!
The text was updated successfully, but these errors were encountered: