diff --git a/ch09/ex9_28_TEST.cpp b/ch09/ex9_28_TEST.cpp index d31553f1..232d6a6f 100644 --- a/ch09/ex9_28_TEST.cpp +++ b/ch09/ex9_28_TEST.cpp @@ -19,7 +19,7 @@ void find_and_insert(forward_list &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); } @@ -42,4 +42,4 @@ TEST_CASE("multi found", "[find_and_insert]") { forward_list r{ "a", "b", "g", "c", "d", "b", "g", "f" }; find_and_insert(l, "b", "g"); REQUIRE(l == r); -} \ No newline at end of file +}