Skip to content

Commit 51a919d

Browse files
authored
Merge pull request #1379 from barendgehrels/fix/issue_629
fix: avoid warnings for coordinate conversions and unused parameters
2 parents 763683e + ab495c3 commit 51a919d

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <cstddef>
2222
#include <vector>
2323

24+
#include <boost/core/ignore_unused.hpp>
2425
#include <boost/range/begin.hpp>
2526
#include <boost/range/end.hpp>
2627
#include <boost/range/value_type.hpp>
@@ -66,6 +67,8 @@ inline void display(MetaTurn const& meta_turn, const char* reason = "")
6667
//<< " -> " << op_index
6768
<< " " << reason
6869
<< std::endl;
70+
#else
71+
boost::ignore_unused(meta_turn, reason);
6972
#endif
7073
}
7174

include/boost/geometry/strategies/geographic/distance_cross_track_box_box.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ struct result_from_distance
189189

190190
public:
191191
template <typename T>
192-
static inline return_type apply(this_strategy const& strategy,
193-
T const& distance)
192+
static inline return_type apply(this_strategy const& , T const& distance)
194193
{
195194
return static_cast<return_type>(distance);
196195
}

include/boost/geometry/strategy/cartesian/side_by_triangle.hpp

+15-8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <boost/geometry/strategies/compare.hpp>
3434
#include <boost/geometry/strategies/side.hpp>
3535

36+
#include <boost/geometry/util/promote_integral.hpp>
3637
#include <boost/geometry/util/select_calculation_type.hpp>
3738
#include <boost/geometry/util/select_most_precise.hpp>
3839

@@ -205,23 +206,29 @@ public :
205206
template <typename P1, typename P2, typename P>
206207
static inline int apply(P1 const& p1, P2 const& p2, P const& p)
207208
{
208-
using coor_t = typename select_calculation_type_alt<CalculationType, P1, P2, P>::type;
209-
210-
// Promote float->double, small int->int
211-
using promoted_t = typename select_most_precise<coor_t, double>::type;
212-
213-
bool const are_all_integral_coordinates =
209+
constexpr bool are_all_integral_coordinates =
214210
std::is_integral<coordinate_type_t<P1>>::value
215211
&& std::is_integral<coordinate_type_t<P2>>::value
216212
&& std::is_integral<coordinate_type_t<P>>::value;
217213

214+
// Promote float to double
215+
// For integer: short -> int -> long
216+
// For larger integers: long, long long, std::int64_t all stay as they are (on a Mac)
217+
using coor_t = typename select_calculation_type_alt<CalculationType, P1, P2, P>::type;
218+
using promoted_t = std::conditional_t
219+
<
220+
are_all_integral_coordinates,
221+
typename promote_integral<coor_t>::type,
222+
typename select_most_precise<coor_t, double>::type
223+
>;
224+
218225
eps_policy< math::detail::equals_factor_policy<promoted_t> > epsp;
219-
promoted_t s = compute_side_value
226+
promoted_t const s = compute_side_value
220227
<
221228
coor_t, promoted_t, are_all_integral_coordinates
222229
>::apply(p1, p2, p, epsp);
223230

224-
promoted_t const zero = promoted_t();
231+
static promoted_t const zero = promoted_t();
225232
return math::detail::equals_by_policy(s, zero, epsp.policy) ? 0
226233
: s > zero ? 1
227234
: -1;

include/boost/geometry/util/promote_integral.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
#ifndef BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP
1212
#define BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP
1313

14-
// For now deactivate the use of multiprecision integers
15-
// TODO: activate it later
14+
// Uncommenting this macro will use Boost.Multiprecision's cpp_int<> as a last resort
15+
// TODO (#1380): change this to BOOST_GEOMETRY_PROMOTE_INTEGER_TO_BOOST_MULTI_PRECISION
16+
// to be able to let users actively choose to use Boost.Multiprecision, but not enable it by default
1617
#define BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER
1718

18-
1919
#include <climits>
2020
#include <cstddef>
2121
#include <type_traits>

0 commit comments

Comments
 (0)