From 1079bf7843dd77c5eaa4831023c90c2c47d84e3a Mon Sep 17 00:00:00 2001 From: alex85k Date: Thu, 5 Jun 2014 23:02:34 +0600 Subject: [PATCH] sort vectors before using std::set_difference discussed in https://github.com/DennisOSRM/Project-OSRM/pull/998#issuecomment-45238338 The vectors are better to be sorted up to ``name_id_comperator`` before running std::set_difference. Elsewhere we get debug checked iterator assertions on Windows and theretically possible incorrect results. --- Algorithms/ExtractRouteNames.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Algorithms/ExtractRouteNames.h b/Algorithms/ExtractRouteNames.h index dee7a1a86..2847da96b 100644 --- a/Algorithms/ExtractRouteNames.h +++ b/Algorithms/ExtractRouteNames.h @@ -75,6 +75,8 @@ template struct ExtractRouteNames } std::vector shortest_path_set_difference(shortest_path_segments.size()); std::vector alternative_path_set_difference(alternative_path_segments.size()); + std::sort(shortest_path_segments.begin(), shortest_path_segments.end(), name_id_comperator); + std::sort(alternative_path_segments.begin(), alternative_path_segments.end(), name_id_comperator); std::set_difference(shortest_path_segments.begin(), shortest_path_segments.end(), alternative_path_segments.begin(),