Skip to content

Commit

Permalink
[fix] replace decltype by typename for some compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
barendgehrels committed Mar 24, 2024
1 parent 425263e commit 0dd7879
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions include/boost/geometry/algorithms/detail/sections/sectionalize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,24 +721,31 @@ struct sectionalize_multi
template <typename Sections, typename Strategy>
inline void enlarge_sections(Sections& sections, Strategy const&)
{
// Expand the box to avoid missing any intersection. The amount is
// should be larger than epsilon. About the value itself: the smaller
// it is, the higher the risk to miss intersections. The larger it is,
// the more comparisons are made, which is not harmful for the result
// (but it might be for the performance).
// So it should be on the high side.

// Use a compilable and workable epsilon for all types, for example:
// Expand the box to avoid missing any intersection.
// About the value itself: the smaller it is,
// the higher the risk to miss intersections.
// The larger it is, the more comparisons are made,
// which is not harmful for the result,
// but it might be for the performance.
// So it should be on the higher side.
//
// The current value:
// - for double :~ 2.22e-13
// - for float :~ 1e-4
// - for Boost.Multiprecision (50) :~ 5.35e-48
// - for Boost.Rational : 0/1

// WARNING: don't use decltype here.
// Earlier code used decltype(section.bonding_box) below,
// but that somehow is not accepted by the NVCC (CUDA 12.4) compiler.
using section_t = typename boost::range_value<Sections>::type;
using box_t = typename section_t::box_type;
using coor_t = typename geometry::coordinate_type<box_t>::type;

static auto const eps = math::scaled_epsilon<coor_t>(1000);

for (auto& section : sections)
{
using gt = decltype(section.bounding_box);
using ct = typename geometry::coordinate_type<gt>::type;
static ct const eps = math::scaled_epsilon<ct>(1000);
expand_by_epsilon(section.bounding_box, eps);
}
}
Expand Down

0 comments on commit 0dd7879

Please sign in to comment.