diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp index 3db78c1736..5d57cbce8c 100644 --- a/src/engine/guidance/post_processing.cpp +++ b/src/engine/guidance/post_processing.cpp @@ -4,6 +4,8 @@ #include "engine/guidance/toolkit.hpp" #include +#include + #include #include @@ -237,18 +239,16 @@ std::vector postProcess(std::vector steps) // finally clean up the post-processed instructions. // Remove all, now NO_TURN instructions for the set of steps - auto pos = steps.begin(); - for (auto check = steps.begin(); check != steps.end(); ++check) + + // keep valid instructions + const auto not_is_valid = [](const RouteStep &step) { - // keep valid instrucstions - if (check->maneuver.instruction != TurnInstruction::NO_TURN() || - check->maneuver.waypoint_type != WaypointType::None) - { - *pos = *check; - ++pos; - } - } - steps.erase(pos, steps.end()); + return step.maneuver.instruction == TurnInstruction::NO_TURN() || + step.maneuver.waypoint_type == WaypointType::None; + }; + + boost::remove_erase_if(steps, not_is_valid); + #if PRINT_DEBUG std::cout << "Merged\n"; print(steps);