From ab495c3c0a2b2d7099af08a196835f74874caa65 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 15 Mar 2025 20:05:47 +0100 Subject: [PATCH] fix: avoid warnings for coordinate conversions and unused parameters Fixes: #629 --- .../detail/overlay/check_enrich.hpp | 3 +++ .../distance_cross_track_box_box.hpp | 3 +-- .../strategy/cartesian/side_by_triangle.hpp | 23 ++++++++++++------- .../boost/geometry/util/promote_integral.hpp | 6 ++--- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp b/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp index 2195494184..af5136593a 100644 --- a/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -66,6 +67,8 @@ inline void display(MetaTurn const& meta_turn, const char* reason = "") //<< " -> " << op_index << " " << reason << std::endl; +#else +boost::ignore_unused(meta_turn, reason); #endif } diff --git a/include/boost/geometry/strategies/geographic/distance_cross_track_box_box.hpp b/include/boost/geometry/strategies/geographic/distance_cross_track_box_box.hpp index 4c9b2a2ee4..6a9d73cb33 100644 --- a/include/boost/geometry/strategies/geographic/distance_cross_track_box_box.hpp +++ b/include/boost/geometry/strategies/geographic/distance_cross_track_box_box.hpp @@ -189,8 +189,7 @@ struct result_from_distance public: template - static inline return_type apply(this_strategy const& strategy, - T const& distance) + static inline return_type apply(this_strategy const& , T const& distance) { return static_cast(distance); } diff --git a/include/boost/geometry/strategy/cartesian/side_by_triangle.hpp b/include/boost/geometry/strategy/cartesian/side_by_triangle.hpp index 3fdbd80199..bf8c0d64c6 100644 --- a/include/boost/geometry/strategy/cartesian/side_by_triangle.hpp +++ b/include/boost/geometry/strategy/cartesian/side_by_triangle.hpp @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -205,23 +206,29 @@ public : template static inline int apply(P1 const& p1, P2 const& p2, P const& p) { - using coor_t = typename select_calculation_type_alt::type; - - // Promote float->double, small int->int - using promoted_t = typename select_most_precise::type; - - bool const are_all_integral_coordinates = + constexpr bool are_all_integral_coordinates = std::is_integral>::value && std::is_integral>::value && std::is_integral>::value; + // Promote float to double + // For integer: short -> int -> long + // For larger integers: long, long long, std::int64_t all stay as they are (on a Mac) + using coor_t = typename select_calculation_type_alt::type; + using promoted_t = std::conditional_t + < + are_all_integral_coordinates, + typename promote_integral::type, + typename select_most_precise::type + >; + eps_policy< math::detail::equals_factor_policy > epsp; - promoted_t s = compute_side_value + promoted_t const s = compute_side_value < coor_t, promoted_t, are_all_integral_coordinates >::apply(p1, p2, p, epsp); - promoted_t const zero = promoted_t(); + static promoted_t const zero = promoted_t(); return math::detail::equals_by_policy(s, zero, epsp.policy) ? 0 : s > zero ? 1 : -1; diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp index 0566f42140..764ab05149 100644 --- a/include/boost/geometry/util/promote_integral.hpp +++ b/include/boost/geometry/util/promote_integral.hpp @@ -11,11 +11,11 @@ #ifndef BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP #define BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP -// For now deactivate the use of multiprecision integers -// TODO: activate it later +// Uncommenting this macro will use Boost.Multiprecision's cpp_int<> as a last resort +// TODO (#1380): change this to BOOST_GEOMETRY_PROMOTE_INTEGER_TO_BOOST_MULTI_PRECISION +// to be able to let users actively choose to use Boost.Multiprecision, but not enable it by default #define BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER - #include #include #include