diff --git a/Point_set_processing_3/include/CGAL/remove_outliers.h b/Point_set_processing_3/include/CGAL/remove_outliers.h index a7c584e5466..aac07b43296 100644 --- a/Point_set_processing_3/include/CGAL/remove_outliers.h +++ b/Point_set_processing_3/include/CGAL/remove_outliers.h @@ -247,33 +247,37 @@ remove_outliers( if (threshold_distance != FT(0)) f2r = std::partition (sorted_points.begin(), sorted_points.end(), - [&threshold_distance](const std::pair& p) -> bool + [sq_threshold_distance = CGAL::square(threshold_distance)](const std::pair& p) -> bool { - return p.first < threshold_distance * threshold_distance; + return p.first < sq_threshold_distance; }); - if (static_cast(std::distance (sorted_points.begin(), f2r)) < first_index_to_remove) - { - std::nth_element (f2r, - sorted_points.begin() + first_index_to_remove, - sorted_points.end(), - [](const std::pair& v1, const std::pair& v2) - { - return v1.firstsecond; - if (sit == f2r) - out = pit; - ++ pit; + if (static_cast(std::distance (sorted_points.begin(), f2r)) < first_index_to_remove) + { + std::nth_element (f2r, + sorted_points.begin() + first_index_to_remove, + sorted_points.end(), + [](const std::pair& v1, const std::pair& v2) + { + return v1.firstsecond; + if (sit == f2r) + out = pit; + ++ pit; + } } callback_wrapper.join();