When using a reference for the functor we must generate a new functor in the for loop

This commit is contained in:
Andreas Fabri 2021-01-28 17:12:26 +00:00
parent b796e6d786
commit 51086d5678
1 changed files with 2 additions and 1 deletions

View File

@ -42,7 +42,6 @@ ch_bykat(InputIterator first, InputIterator last,
typedef typename Traits::Equal_2 Equal_2;
Left_turn_2 left_turn = ch_traits.left_turn_2_object();
Less_dist less_dist = ch_traits.less_signed_distance_to_line_2_object();
Equal_2 equal_points = ch_traits.equal_2_object();
if (first == last) return result;
@ -81,6 +80,8 @@ ch_bykat(InputIterator first, InputIterator last,
for (;;)
{
// This functor must be in the for loop so that the Convex_hull_constructive traits_2 works correctly
Less_dist less_dist = ch_traits.less_signed_distance_to_line_2_object();
if ( l != r)
{
Point_2 c = *std::min_element( l, r, [&less_dist,&a,&b](const Point_2&p1, const Point_2& p2)