Skip to content

Commit

Permalink
Merge pull request pezy#138 from wuwenjun6/master
Browse files Browse the repository at this point in the history
Update ex9_28_TEST.cpp
  • Loading branch information
pezy chen authored Nov 23, 2017
2 parents 80757d8 + 87f4819 commit ac137fd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ch09/ex9_28_TEST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void find_and_insert(forward_list<string> &list, const string& to_find, const st
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 (*curr == to_find) curr=list.insert_after(curr, to_add);
if (size == std::distance(list.begin(), list.end())) list.insert_after(prev, to_add);
}

Expand All @@ -42,4 +42,4 @@ TEST_CASE("multi found", "[find_and_insert]") {
forward_list<string> r{ "a", "b", "g", "c", "d", "b", "g", "f" };
find_and_insert(l, "b", "g");
REQUIRE(l == r);
}
}

0 comments on commit ac137fd

Please sign in to comment.