From 459e2a322be1d7fec9514a4ec7c558a8c3fd601e Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 26 Nov 2014 12:05:55 +0100 Subject: [PATCH] cast computed way in a proper way, add a static assertion to check for file types via traits --- DataStructures/StaticRTree.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/DataStructures/StaticRTree.h b/DataStructures/StaticRTree.h index aa5bce540..be16ef148 100644 --- a/DataStructures/StaticRTree.h +++ b/DataStructures/StaticRTree.h @@ -1121,13 +1121,20 @@ class StaticRTree m_coordinate_list->at(nearest_edge.u), m_coordinate_list->at(nearest_edge.v)); const float ratio = std::min(1.f, distance_1 / distance_2); + using TreeWeightType = decltype(result_phantom_node.forward_weight); + static_assert(std::is_same::value, + "forward and reverse weight type in tree must be the same"); + if (SPECIAL_NODEID != result_phantom_node.forward_node_id) { - result_phantom_node.forward_weight *= ratio; + const auto new_weight = static_cast(result_phantom_node.forward_weight * ratio); + result_phantom_node.forward_weight = new_weight; } if (SPECIAL_NODEID != result_phantom_node.reverse_node_id) { - result_phantom_node.reverse_weight *= (1.f - ratio); + const auto new_weight = static_cast(result_phantom_node.reverse_weight * (1.f-ratio)); + result_phantom_node.reverse_weight = new_weight; } }