From 74166538747f77cb679bfa46d4a79eafad68dc4b Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Tue, 12 Apr 2016 12:42:16 +0200 Subject: [PATCH] Force correct type deduction for irange on windows --- include/contractor/graph_contractor.hpp | 6 +-- include/engine/api/route_api.hpp | 4 +- include/engine/api/table_api.hpp | 2 +- include/engine/api/trip_api.hpp | 4 +- .../map_matching/hidden_markov_model.hpp | 4 +- include/engine/plugins/plugin_base.hpp | 6 +-- .../routing_algorithms/alternative_path.hpp | 40 ++++++++++++------- .../routing_algorithms/map_matching.hpp | 4 +- .../routing_algorithms/shortest_path.hpp | 2 +- src/contractor/contractor.cpp | 2 +- src/engine/plugins/match.cpp | 2 +- src/extractor/extractor.cpp | 2 +- 12 files changed, 45 insertions(+), 33 deletions(-) diff --git a/include/contractor/graph_contractor.hpp b/include/contractor/graph_contractor.hpp index 26be61d6b..ce33d268a 100644 --- a/include/contractor/graph_contractor.hpp +++ b/include/contractor/graph_contractor.hpp @@ -342,7 +342,7 @@ class GraphContractor // remaining graph std::vector new_node_id_from_orig_id_map(number_of_nodes, SPECIAL_NODEID); - for (const auto new_node_id : util::irange(0, remaining_nodes.size())) + for (const auto new_node_id : util::irange(0UL, remaining_nodes.size())) { auto &node = remaining_nodes[new_node_id]; BOOST_ASSERT(node_priorities.size() > node.id); @@ -352,7 +352,7 @@ class GraphContractor } // build forward and backward renumbering map and remap ids in remaining_nodes - for (const auto new_node_id : util::irange(0, remaining_nodes.size())) + for (const auto new_node_id : util::irange(0UL, remaining_nodes.size())) { auto &node = remaining_nodes[new_node_id]; // create renumbering maps in both directions @@ -362,7 +362,7 @@ class GraphContractor } // walk over all nodes for (const auto source : - util::irange(0, contractor_graph->GetNumberOfNodes())) + util::irange(0UL, contractor_graph->GetNumberOfNodes())) { for (auto current_edge : contractor_graph->GetAdjacentEdgeRange(source)) { diff --git a/include/engine/api/route_api.hpp b/include/engine/api/route_api.hpp index bf4938879..479d59646 100644 --- a/include/engine/api/route_api.hpp +++ b/include/engine/api/route_api.hpp @@ -82,7 +82,7 @@ class RouteAPI : public BaseAPI legs.reserve(number_of_legs); leg_geometries.reserve(number_of_legs); - for (auto idx : util::irange(0UL, number_of_legs)) + for (auto idx : util::irange(0UL, number_of_legs)) { const auto &phantoms = segment_end_coordinates[idx]; const auto &path_data = unpacked_path_segments[idx]; @@ -155,7 +155,7 @@ class RouteAPI : public BaseAPI } std::vector step_geometries; - for (const auto idx : util::irange(0UL, legs.size())) + for (const auto idx : util::irange(0UL, legs.size())) { auto &leg_geometry = leg_geometries[idx]; std::transform( diff --git a/include/engine/api/table_api.hpp b/include/engine/api/table_api.hpp index 20d45db5d..ce84b0baa 100644 --- a/include/engine/api/table_api.hpp +++ b/include/engine/api/table_api.hpp @@ -103,7 +103,7 @@ class TableAPI final : public BaseAPI std::size_t number_of_columns) const { util::json::Array json_table; - for (const auto row : util::irange(0, number_of_rows)) + for (const auto row : util::irange(0UL, number_of_rows)) { util::json::Array json_row; auto row_begin_iterator = values.begin() + (row * number_of_columns); diff --git a/include/engine/api/trip_api.hpp b/include/engine/api/trip_api.hpp index 8398f0683..50176af6a 100644 --- a/include/engine/api/trip_api.hpp +++ b/include/engine/api/trip_api.hpp @@ -77,10 +77,10 @@ class TripAPI final : public RouteAPI }; std::vector input_idx_to_trip_idx(parameters.coordinates.size()); - for (auto sub_trip_index : util::irange(0u, static_cast(sub_trips.size()))) + for (auto sub_trip_index : util::irange(0u, sub_trips.size())) { for (auto point_index : - util::irange(0u, static_cast(sub_trips[sub_trip_index].size()))) + util::irange(0u, sub_trips[sub_trip_index].size())) { input_idx_to_trip_idx[sub_trips[sub_trip_index][point_index]] = TripIndex{sub_trip_index, point_index}; diff --git a/include/engine/map_matching/hidden_markov_model.hpp b/include/engine/map_matching/hidden_markov_model.hpp index 303a83578..9b3634313 100644 --- a/include/engine/map_matching/hidden_markov_model.hpp +++ b/include/engine/map_matching/hidden_markov_model.hpp @@ -69,7 +69,7 @@ template struct HiddenMarkovModel path_distances.resize(candidates_list.size()); pruned.resize(candidates_list.size()); breakage.resize(candidates_list.size()); - for (const auto i : util::irange(0u, candidates_list.size())) + for (const auto i : util::irange(0UL, candidates_list.size())) { const auto &num_candidates = candidates_list[i].size(); // add empty vectors @@ -107,7 +107,7 @@ template struct HiddenMarkovModel { BOOST_ASSERT(initial_timestamp < num_points); - for (const auto s : util::irange(0u, viterbi[initial_timestamp].size())) + for (const auto s : util::irange(0UL, viterbi[initial_timestamp].size())) { viterbi[initial_timestamp][s] = emission_log_probabilities[initial_timestamp][s]; parents[initial_timestamp][s] = std::make_pair(initial_timestamp, s); diff --git a/include/engine/plugins/plugin_base.hpp b/include/engine/plugins/plugin_base.hpp index aec9dd02a..bd00f0c5d 100644 --- a/include/engine/plugins/plugin_base.hpp +++ b/include/engine/plugins/plugin_base.hpp @@ -122,7 +122,7 @@ class BasePlugin const bool use_hints = !parameters.hints.empty(); const bool use_bearings = !parameters.bearings.empty(); - for (const auto i : util::irange(0, parameters.coordinates.size())) + for (const auto i : util::irange(0UL, parameters.coordinates.size())) { if (use_hints && parameters.hints[i] && parameters.hints[i]->IsValid(parameters.coordinates[i], facade)) @@ -161,7 +161,7 @@ class BasePlugin const bool use_radiuses = !parameters.radiuses.empty(); BOOST_ASSERT(parameters.IsValid()); - for (const auto i : util::irange(0, parameters.coordinates.size())) + for (const auto i : util::irange(0UL, parameters.coordinates.size())) { if (use_hints && parameters.hints[i] && parameters.hints[i]->IsValid(parameters.coordinates[i], facade)) @@ -221,7 +221,7 @@ class BasePlugin const bool use_radiuses = !parameters.radiuses.empty(); BOOST_ASSERT(parameters.IsValid()); - for (const auto i : util::irange(0, parameters.coordinates.size())) + for (const auto i : util::irange(0UL, parameters.coordinates.size())) { if (use_hints && parameters.hints[i] && parameters.hints[i]->IsValid(parameters.coordinates[i], facade)) diff --git a/include/engine/routing_algorithms/alternative_path.hpp b/include/engine/routing_algorithms/alternative_path.hpp index 8dcc123ec..493d62f0d 100644 --- a/include/engine/routing_algorithms/alternative_path.hpp +++ b/include/engine/routing_algorithms/alternative_path.hpp @@ -84,19 +84,25 @@ class AlternativeRouting final int upper_bound_to_shortest_path_distance = INVALID_EDGE_WEIGHT; NodeID middle_node = SPECIAL_NODEID; const EdgeWeight min_edge_offset = - std::min(phantom_node_pair.source_phantom.forward_segment_id.enabled ? -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset() : 0, - phantom_node_pair.source_phantom.reverse_segment_id.enabled ? -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset() : 0); + std::min(phantom_node_pair.source_phantom.forward_segment_id.enabled + ? -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset() + : 0, + phantom_node_pair.source_phantom.reverse_segment_id.enabled + ? -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset() + : 0); if (phantom_node_pair.source_phantom.forward_segment_id.enabled) { - BOOST_ASSERT(phantom_node_pair.source_phantom.forward_segment_id.id != SPECIAL_SEGMENTID); + BOOST_ASSERT(phantom_node_pair.source_phantom.forward_segment_id.id != + SPECIAL_SEGMENTID); forward_heap1.Insert(phantom_node_pair.source_phantom.forward_segment_id.id, -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(), phantom_node_pair.source_phantom.forward_segment_id.id); } if (phantom_node_pair.source_phantom.reverse_segment_id.enabled) { - BOOST_ASSERT(phantom_node_pair.source_phantom.reverse_segment_id.id != SPECIAL_SEGMENTID); + BOOST_ASSERT(phantom_node_pair.source_phantom.reverse_segment_id.id != + SPECIAL_SEGMENTID); forward_heap1.Insert(phantom_node_pair.source_phantom.reverse_segment_id.id, -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(), phantom_node_pair.source_phantom.reverse_segment_id.id); @@ -104,14 +110,16 @@ class AlternativeRouting final if (phantom_node_pair.target_phantom.forward_segment_id.enabled) { - BOOST_ASSERT(phantom_node_pair.target_phantom.forward_segment_id.id != SPECIAL_SEGMENTID); + BOOST_ASSERT(phantom_node_pair.target_phantom.forward_segment_id.id != + SPECIAL_SEGMENTID); reverse_heap1.Insert(phantom_node_pair.target_phantom.forward_segment_id.id, phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(), phantom_node_pair.target_phantom.forward_segment_id.id); } if (phantom_node_pair.target_phantom.reverse_segment_id.enabled) { - BOOST_ASSERT(phantom_node_pair.target_phantom.reverse_segment_id.id != SPECIAL_SEGMENTID); + BOOST_ASSERT(phantom_node_pair.target_phantom.reverse_segment_id.id != + SPECIAL_SEGMENTID); reverse_heap1.Insert(phantom_node_pair.target_phantom.reverse_segment_id.id, phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(), phantom_node_pair.target_phantom.reverse_segment_id.id); @@ -308,9 +316,11 @@ class AlternativeRouting final BOOST_ASSERT(!packed_shortest_path.empty()); raw_route_data.unpacked_path_segments.resize(1); raw_route_data.source_traversed_in_reverse.push_back( - (packed_shortest_path.front() != phantom_node_pair.source_phantom.forward_segment_id.id)); + (packed_shortest_path.front() != + phantom_node_pair.source_phantom.forward_segment_id.id)); raw_route_data.target_traversed_in_reverse.push_back( - (packed_shortest_path.back() != phantom_node_pair.target_phantom.forward_segment_id.id)); + (packed_shortest_path.back() != + phantom_node_pair.target_phantom.forward_segment_id.id)); super::UnpackPath( // -- packed input @@ -329,10 +339,12 @@ class AlternativeRouting final RetrievePackedAlternatePath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, s_v_middle, v_t_middle, packed_alternate_path); - raw_route_data.alt_source_traversed_in_reverse.push_back(( - packed_alternate_path.front() != phantom_node_pair.source_phantom.forward_segment_id.id)); + raw_route_data.alt_source_traversed_in_reverse.push_back( + (packed_alternate_path.front() != + phantom_node_pair.source_phantom.forward_segment_id.id)); raw_route_data.alt_target_traversed_in_reverse.push_back( - (packed_alternate_path.back() != phantom_node_pair.target_phantom.forward_segment_id.id)); + (packed_alternate_path.back() != + phantom_node_pair.target_phantom.forward_segment_id.id)); // unpack the alternate path super::UnpackPath(packed_alternate_path.begin(), packed_alternate_path.end(), @@ -429,9 +441,9 @@ class AlternativeRouting final // partial unpacking, compute sharing // First partially unpack s-->v until paths deviate, note length of common path. - const int64_t s_v_min_path_size = - static_cast(std::min(packed_s_v_path.size(), packed_shortest_path.size())) - 1; - for (const int64_t current_node : util::irange(0, s_v_min_path_size)) + const auto s_v_min_path_size = + std::min(packed_s_v_path.size(), packed_shortest_path.size()) - 1; + for (const auto current_node : util::irange(0UL, s_v_min_path_size)) { if (packed_s_v_path[current_node] == packed_shortest_path[current_node] && packed_s_v_path[current_node + 1] == packed_shortest_path[current_node + 1]) diff --git a/include/engine/routing_algorithms/map_matching.hpp b/include/engine/routing_algorithms/map_matching.hpp index 7d8b04e99..0b1020a7a 100644 --- a/include/engine/routing_algorithms/map_matching.hpp +++ b/include/engine/routing_algorithms/map_matching.hpp @@ -244,14 +244,14 @@ class MapMatching final : public BasicRoutingInterface(0u, prev_viterbi.size())) + for (const auto s : util::irange(0UL, prev_viterbi.size())) { if (prev_pruned[s]) { continue; } - for (const auto s_prime : util::irange(0u, current_viterbi.size())) + for (const auto s_prime : util::irange(0UL, current_viterbi.size())) { const double emission_pr = emission_log_probabilities[t][s_prime]; double new_value = prev_viterbi[s] + emission_pr; diff --git a/include/engine/routing_algorithms/shortest_path.hpp b/include/engine/routing_algorithms/shortest_path.hpp index c4181a6d1..0d3d0be32 100644 --- a/include/engine/routing_algorithms/shortest_path.hpp +++ b/include/engine/routing_algorithms/shortest_path.hpp @@ -227,7 +227,7 @@ class ShortestPathRouting final raw_route_data.shortest_path_length = shortest_path_length; - for (const auto current_leg : util::irange(0, packed_leg_begin.size() - 1)) + for (const auto current_leg : util::irange(0UL, packed_leg_begin.size() - 1)) { auto leg_begin = total_packed_path.begin() + packed_leg_begin[current_leg]; auto leg_end = total_packed_path.begin() + packed_leg_begin[current_leg + 1]; diff --git a/src/contractor/contractor.cpp b/src/contractor/contractor.cpp index 39d6f4815..72b2d34d4 100644 --- a/src/contractor/contractor.cpp +++ b/src/contractor/contractor.cpp @@ -626,7 +626,7 @@ Contractor::WriteContractedGraph(unsigned max_node_id, int number_of_used_edges = 0; util::StaticGraph::EdgeArrayEntry current_edge; - for (const auto edge : util::irange(0, contracted_edge_list.size())) + for (const auto edge : util::irange(0UL, contracted_edge_list.size())) { // some self-loops are required for oneway handling. Need to assertthat we only keep these // (TODO) diff --git a/src/engine/plugins/match.cpp b/src/engine/plugins/match.cpp index 029a27eb3..bd3a970f7 100644 --- a/src/engine/plugins/match.cpp +++ b/src/engine/plugins/match.cpp @@ -168,7 +168,7 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters, } std::vector sub_routes(sub_matchings.size()); - for (auto index : util::irange(0UL, sub_matchings.size())) + for (auto index : util::irange(0UL, sub_matchings.size())) { BOOST_ASSERT(sub_matchings[index].nodes.size() > 1); diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index 368867d38..99f25aede 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -544,7 +544,7 @@ void Extractor::BuildRTree(std::vector node_based_edge_list, // Filter node based edges based on startpoint auto out_iter = node_based_edge_list.begin(); auto in_iter = node_based_edge_list.begin(); - for (auto index : util::irange(0, node_is_startpoint.size())) + for (auto index : util::irange(0UL, node_is_startpoint.size())) { BOOST_ASSERT(in_iter != node_based_edge_list.end()); if (node_is_startpoint[index])