@@ -28,6 +28,10 @@ namespace boost { namespace geometry
2828namespace detail { namespace generic_robust_predicates
2929{
3030
31+ // The templates in this file are meant to be used for the evaluation of
32+ // expressions with floating-point precision and floating-point rounding.
33+ // The most important template in this file is approximate_interim.
34+
3135template
3236<
3337 typename Node,
@@ -37,7 +41,7 @@ template
3741>
3842struct get_nth_real_impl
3943{
40- static inline Real apply (const InputArr& input)
44+ static inline Real apply (InputArr const & input)
4145 {
4246 return input[N - 1 ];
4347 }
@@ -51,7 +55,7 @@ template
5155>
5256struct get_nth_real_impl <Node, 0 , Real, InputArr>
5357{
54- static inline Real apply (const InputArr&)
58+ static inline Real apply (InputArr const &)
5559 {
5660 return Node::value;
5761 }
@@ -64,7 +68,7 @@ template
6468 typename Real,
6569 typename InputArr
6670>
67- inline Real get_nth_real (const InputArr& input)
71+ inline Real get_nth_real (InputArr const & input)
6872{
6973 return get_nth_real_impl<Node, Node::argn, Real, InputArr>::apply (input);
7074}
@@ -80,7 +84,7 @@ template
8084>
8185struct get_approx_impl
8286{
83- static inline Real apply (Arr& interim_results, const InputArr& input )
87+ static inline Real apply (Arr& interim_results, InputArr const & )
8488 {
8589 return interim_results[boost::mp11::mp_find<All, Node>::value];
8690 }
@@ -96,7 +100,7 @@ template
96100>
97101struct get_approx_impl <All, Node, Real, Arr, true , InputArr>
98102{
99- static inline Real apply (Arr& interim_results, const InputArr& input)
103+ static inline Real apply (Arr&, InputArr const & input)
100104 {
101105 return get_nth_real<Node, Node::argn, Real, InputArr>(input);
102106 }
@@ -110,7 +114,7 @@ template
110114 typename Arr,
111115 typename InputArr
112116>
113- inline Real get_approx (Arr& interim_results, const InputArr& input)
117+ inline Real get_approx (Arr& interim_results, InputArr const & input)
114118{
115119 return get_approx_impl
116120 <
@@ -145,7 +149,7 @@ template
145149>
146150struct approximate_remainder_impl
147151{
148- static inline void apply (Arr& interim_results, const InputArr& input)
152+ static inline void apply (Arr& interim_results, InputArr const & input)
149153 {
150154 using node = boost::mp11::mp_front<Remaining>;
151155 approximate_interim_impl
@@ -178,7 +182,7 @@ struct approximate_remainder_impl
178182 InputArr
179183 >
180184{
181- static inline void apply (Arr& interim_results, const InputArr& input ) {}
185+ static inline void apply (Arr&, InputArr const & ) {}
182186};
183187
184188template
@@ -189,7 +193,7 @@ template
189193 typename Arr,
190194 typename InputArr
191195>
192- inline void approximate_remainder (Arr& interim_results, const InputArr& input)
196+ inline void approximate_remainder (Arr& interim_results, InputArr const & input)
193197{
194198 approximate_remainder_impl
195199 <
@@ -220,7 +224,7 @@ struct approximate_interim_impl
220224 InputArr
221225 >
222226{
223- static inline void apply (Arr& interim_results, const InputArr& input)
227+ static inline void apply (Arr& interim_results, InputArr const & input)
224228 {
225229 using node = boost::mp11::mp_front<Remaining>;
226230 interim_results[boost::mp11::mp_find<All, node>::value] =
@@ -255,7 +259,7 @@ struct approximate_interim_impl
255259 InputArr
256260 >
257261{
258- static inline void apply (Arr& interim_results, const InputArr& input)
262+ static inline void apply (Arr& interim_results, InputArr const & input)
259263 {
260264 using node = boost::mp11::mp_front<Remaining>;
261265 interim_results[boost::mp11::mp_find<All, node>::value] = std::max (
@@ -290,7 +294,7 @@ struct approximate_interim_impl
290294 InputArr
291295 >
292296{
293- static inline void apply (Arr& interim_results, const InputArr& input)
297+ static inline void apply (Arr& interim_results, InputArr const & input)
294298 {
295299 using node = boost::mp11::mp_front<Remaining>;
296300 interim_results[boost::mp11::mp_find<All, node>::value] = std::min (
@@ -325,7 +329,7 @@ struct approximate_interim_impl
325329 InputArr
326330 >
327331{
328- static inline void apply (Arr& interim_results, const InputArr& input)
332+ static inline void apply (Arr& interim_results, InputArr const & input)
329333 {
330334 using node = boost::mp11::mp_front<Remaining>;
331335 interim_results[boost::mp11::mp_find<All, node>::value] =
@@ -360,7 +364,7 @@ struct approximate_interim_impl
360364 InputArr
361365 >
362366{
363- static inline void apply (Arr& interim_results, const InputArr& input)
367+ static inline void apply (Arr& interim_results, InputArr const & input)
364368 {
365369 using node = boost::mp11::mp_front<Remaining>;
366370 interim_results[boost::mp11::mp_find<All, node>::value] =
@@ -395,7 +399,7 @@ struct approximate_interim_impl
395399 InputArr
396400 >
397401{
398- static inline void apply (Arr& interim_results, const InputArr& input)
402+ static inline void apply (Arr& interim_results, InputArr const & input)
399403 {
400404 using node = boost::mp11::mp_front<Remaining>;
401405 interim_results[boost::mp11::mp_find<All, node>::value] =
@@ -432,7 +436,7 @@ struct approximate_interim_impl
432436 InputArr
433437 >
434438{
435- static inline void apply (Arr& interim_results, const InputArr& input)
439+ static inline void apply (Arr& interim_results, InputArr const & input)
436440 {
437441 approximate_remainder
438442 <
@@ -443,6 +447,13 @@ struct approximate_interim_impl
443447 }
444448};
445449
450+ // All expects an boost::mp11::mp_list of all expressions that need to be
451+ // evaluated. Remaining expects an boost::mp11::mp_list of the expressions
452+ // that are left to be evaluated. In the first call it is expected to be
453+ // equal to All and it serves as an anchor for template recursion. Real is a
454+ // floating-point type. The remaining template arguments are deduced from
455+ // parameters.
456+
446457template
447458<
448459 typename All,
@@ -451,7 +462,7 @@ template
451462 typename Arr,
452463 typename InputArr
453464>
454- inline void approximate_interim (Arr& interim_results, const InputArr& input)
465+ inline void approximate_interim (Arr& interim_results, InputArr const & input)
455466{
456467 approximate_remainder
457468 <
@@ -462,7 +473,7 @@ inline void approximate_interim(Arr& interim_results, const InputArr& input)
462473}
463474
464475template <typename Expression, typename Real, typename InputArr>
465- inline Real approximate_value (const InputArr& input)
476+ inline Real approximate_value (InputArr const & input)
466477{
467478 using stack = typename boost::mp11::mp_unique<post_order<Expression>>;
468479 using evals = typename boost::mp11::mp_remove_if<stack, is_leaf>;
0 commit comments