Skip to content

Commit 1243579

Browse files
authored
Merge pull request #767 from awulkiew/feature/tuple
Modernize tuple-related code.
2 parents 9989780 + 3402c91 commit 1243579

25 files changed

+666
-1047
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ class linear_intersections
118118
bool is_p_last, bool is_q_last,
119119
EqPPStrategy const& strategy)
120120
{
121-
int arrival_a = result.template get<1>().arrival[0];
122-
int arrival_b = result.template get<1>().arrival[1];
123-
bool same_dirs = result.template get<1>().dir_a == 0
124-
&& result.template get<1>().dir_b == 0;
121+
int arrival_a = result.direction.arrival[0];
122+
int arrival_b = result.direction.arrival[1];
123+
bool same_dirs = result.direction.dir_a == 0
124+
&& result.direction.dir_b == 0;
125125

126126
if ( same_dirs )
127127
{
128-
if ( result.template get<0>().count == 2 )
128+
if ( result.intersection_points.count == 2 )
129129
{
130-
if ( ! result.template get<1>().opposite )
130+
if ( ! result.direction.opposite )
131131
{
132132
ips[0].p_operation = operation_intersection;
133133
ips[0].q_operation = operation_intersection;
@@ -136,10 +136,10 @@ class linear_intersections
136136

137137
ips[0].is_pi
138138
= equals::equals_point_point(
139-
pi, result.template get<0>().intersections[0], strategy);
139+
pi, result.intersection_points.intersections[0], strategy);
140140
ips[0].is_qi
141141
= equals::equals_point_point(
142-
qi, result.template get<0>().intersections[0], strategy);
142+
qi, result.intersection_points.intersections[0], strategy);
143143
ips[1].is_pj = arrival_a != -1;
144144
ips[1].is_qj = arrival_b != -1;
145145
}
@@ -158,7 +158,7 @@ class linear_intersections
158158
}
159159
else
160160
{
161-
BOOST_GEOMETRY_ASSERT(result.template get<0>().count == 1);
161+
BOOST_GEOMETRY_ASSERT(result.intersection_points.count == 1);
162162
ips[0].p_operation = union_or_blocked_same_dirs(arrival_a, is_p_last);
163163
ips[0].q_operation = union_or_blocked_same_dirs(arrival_b, is_q_last);
164164

@@ -542,19 +542,19 @@ struct get_turn_info_for_endpoint
542542

543543
//geometry::convert(ip, tp.point);
544544
//tp.method = method;
545-
base_turn_handler::assign_point(tp, method, result.template get<0>(), ip_index);
545+
base_turn_handler::assign_point(tp, method, result.intersection_points, ip_index);
546546

547547
tp.operations[0].operation = op0;
548548
tp.operations[1].operation = op1;
549549
tp.operations[0].position = pos0;
550550
tp.operations[1].position = pos1;
551551

552-
if ( result.template get<0>().count > 1 )
552+
if ( result.intersection_points.count > 1 )
553553
{
554554
// NOTE: is_collinear is NOT set for the first endpoint
555555
// for which there is no preceding segment
556556

557-
//BOOST_GEOMETRY_ASSERT( result.template get<1>().dir_a == 0 && result.template get<1>().dir_b == 0 );
557+
//BOOST_GEOMETRY_ASSERT( result.direction.dir_a == 0 && result.direction.dir_b == 0 );
558558
if ( ! is_p_first_ip )
559559
{
560560
tp.operations[0].is_collinear = op0 != operation_intersection
@@ -567,7 +567,7 @@ struct get_turn_info_for_endpoint
567567
|| is_q_spike;
568568
}
569569
}
570-
else //if ( result.template get<0>().count == 1 )
570+
else //if ( result.intersection_points.count == 1 )
571571
{
572572
if ( op0 == operation_blocked && op1 == operation_intersection )
573573
{

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

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
1919
#include <boost/geometry/algorithms/detail/recalculate.hpp>
2020
#include <boost/geometry/core/assert.hpp>
21-
#include <boost/geometry/policies/relate/direction.hpp>
22-
#include <boost/geometry/policies/relate/intersection_points.hpp>
23-
#include <boost/geometry/policies/relate/tupled.hpp>
21+
#include <boost/geometry/policies/relate/intersection_policy.hpp>
2422
#include <boost/geometry/policies/robustness/rescale_policy_tags.hpp>
2523
#include <boost/geometry/strategies/intersection_result.hpp>
2624

@@ -248,13 +246,9 @@ class intersection_info_base<UniqueSubRange1, UniqueSubRange2,
248246
TurnPoint,
249247
geometry::segment_ratio<boost::long_long_type>
250248
> intersection_point_type;
251-
typedef policies::relate::segments_tupled
249+
typedef policies::relate::segments_intersection_policy
252250
<
253-
policies::relate::segments_intersection_points
254-
<
255-
intersection_point_type
256-
>,
257-
policies::relate::segments_direction
251+
intersection_point_type
258252
> intersection_policy_type;
259253

260254
typedef typename intersection_policy_type::return_type result_type;
@@ -343,13 +337,9 @@ class intersection_info_base<UniqueSubRange1, UniqueSubRange2,
343337
public:
344338

345339
typedef segment_intersection_points<TurnPoint> intersection_point_type;
346-
typedef policies::relate::segments_tupled
340+
typedef policies::relate::segments_intersection_policy
347341
<
348-
policies::relate::segments_intersection_points
349-
<
350-
intersection_point_type
351-
>,
352-
policies::relate::segments_direction
342+
intersection_point_type
353343
> intersection_policy_type;
354344

355345
typedef typename intersection_policy_type::return_type result_type;
@@ -439,22 +429,21 @@ class intersection_info
439429
typedef typename base::side_calculator_type side_calculator_type;
440430
typedef typename base::result_type result_type;
441431

442-
typedef typename boost::tuples::element<0, result_type>::type i_info_type; // intersection_info
443-
typedef typename boost::tuples::element<1, result_type>::type d_info_type; // dir_info
432+
typedef typename result_type::intersection_points_type i_info_type;
433+
typedef typename result_type::direction_type d_info_type;
444434

445435
intersection_info(UniqueSubRange1 const& range_p,
446436
UniqueSubRange2 const& range_q,
447437
UmbrellaStrategy const& umbrella_strategy,
448438
RobustPolicy const& robust_policy)
449-
: base(range_p, range_q,
450-
umbrella_strategy, robust_policy)
439+
: base(range_p, range_q, umbrella_strategy, robust_policy)
451440
, m_intersection_strategy(umbrella_strategy)
452441
, m_robust_policy(robust_policy)
453442
{}
454443

455444
inline result_type const& result() const { return base::m_result; }
456-
inline i_info_type const& i_info() const { return base::m_result.template get<0>(); }
457-
inline d_info_type const& d_info() const { return base::m_result.template get<1>(); }
445+
inline i_info_type const& i_info() const { return base::m_result.intersection_points; }
446+
inline d_info_type const& d_info() const { return base::m_result.direction; }
458447

459448
inline side_strategy_type get_side_strategy() const
460449
{

include/boost/geometry/algorithms/detail/relate/de9im.hpp

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_DE9IM_HPP
1515
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_DE9IM_HPP
1616

17-
#include <boost/static_assert.hpp>
18-
#include <boost/tuple/tuple.hpp>
17+
#include <tuple>
1918

2019
#include <boost/geometry/algorithms/detail/relate/result.hpp>
2120
#include <boost/geometry/core/topological_dimension.hpp>
@@ -153,33 +152,20 @@ class static_mask
153152

154153

155154
inline
156-
boost::tuples::cons
157-
<
158-
mask,
159-
boost::tuples::cons<mask, boost::tuples::null_type>
160-
>
155+
std::tuple<mask, mask>
161156
operator||(mask const& m1, mask const& m2)
162157
{
163-
namespace bt = boost::tuples;
164-
165-
return bt::cons<mask, bt::cons<mask, bt::null_type> >
166-
( m1, bt::cons<mask, bt::null_type>(m2, bt::null_type()) );
158+
return std::tuple<mask, mask>(m1, m2);
167159
}
168160

169-
template <typename Tail>
161+
template <typename ...Masks>
170162
inline
171-
typename geometry::tuples::push_back
172-
<
173-
boost::tuples::cons<mask, Tail>,
174-
mask
175-
>::type
176-
operator||(boost::tuples::cons<mask, Tail> const& t, mask const& m)
163+
std::tuple<Masks..., mask>
164+
operator||(std::tuple<Masks...> const& t, mask const& m)
177165
{
178-
namespace bt = boost::tuples;
179-
180166
return geometry::tuples::push_back
181167
<
182-
bt::cons<mask, Tail>,
168+
std::tuple<Masks...>,
183169
mask
184170
>::apply(t, m);
185171
}

include/boost/geometry/algorithms/detail/relate/interface.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_INTERFACE_HPP
1616

1717

18-
#include <boost/tuple/tuple.hpp>
18+
#include <tuple>
19+
1920
#include <boost/variant/apply_visitor.hpp>
2021
#include <boost/variant/static_visitor.hpp>
2122
#include <boost/variant/variant_fwd.hpp>
@@ -104,12 +105,12 @@ struct result_handler_type<Geometry1, Geometry2, geometry::de9im::mask>
104105
> type;
105106
};
106107

107-
template <typename Geometry1, typename Geometry2, typename Head, typename Tail>
108-
struct result_handler_type<Geometry1, Geometry2, boost::tuples::cons<Head, Tail>>
108+
template <typename Geometry1, typename Geometry2, typename ...Masks>
109+
struct result_handler_type<Geometry1, Geometry2, std::tuple<Masks...>>
109110
{
110111
typedef mask_handler
111112
<
112-
boost::tuples::cons<Head, Tail>,
113+
std::tuple<Masks...>,
113114
interruption_enabled
114115
<
115116
Geometry1,

include/boost/geometry/algorithms/detail/relate/result.hpp

Lines changed: 23 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,14 @@ struct interrupt_dispatch<Mask, true>
308308
}
309309
};
310310

311-
template <typename Masks, int I = 0, int N = boost::tuples::length<Masks>::value>
311+
template <typename Masks, int I = 0, int N = std::tuple_size<Masks>::value>
312312
struct interrupt_dispatch_tuple
313313
{
314314
template <field F1, field F2, char V>
315315
static inline bool apply(Masks const& masks)
316316
{
317-
typedef typename boost::tuples::element<I, Masks>::type mask_type;
318-
mask_type const& mask = boost::get<I>(masks);
317+
typedef typename std::tuple_element<I, Masks>::type mask_type;
318+
mask_type const& mask = std::get<I>(masks);
319319
return interrupt_dispatch<mask_type, true>::template apply<F1, F2, V>(mask)
320320
&& interrupt_dispatch_tuple<Masks, I+1>::template apply<F1, F2, V>(masks);
321321
}
@@ -331,23 +331,10 @@ struct interrupt_dispatch_tuple<Masks, N, N>
331331
}
332332
};
333333

334-
//template <typename T0, typename T1, typename T2, typename T3, typename T4,
335-
// typename T5, typename T6, typename T7, typename T8, typename T9>
336-
//struct interrupt_dispatch<boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>, true>
337-
//{
338-
// typedef boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> mask_type;
339-
340-
// template <field F1, field F2, char V>
341-
// static inline bool apply(mask_type const& mask)
342-
// {
343-
// return interrupt_dispatch_tuple<mask_type>::template apply<F1, F2, V>(mask);
344-
// }
345-
//};
346-
347-
template <typename Head, typename Tail>
348-
struct interrupt_dispatch<boost::tuples::cons<Head, Tail>, true>
334+
template <typename ...Masks>
335+
struct interrupt_dispatch<std::tuple<Masks...>, true>
349336
{
350-
typedef boost::tuples::cons<Head, Tail> mask_type;
337+
typedef std::tuple<Masks...> mask_type;
351338

352339
template <field F1, field F2, char V>
353340
static inline bool apply(mask_type const& mask)
@@ -394,14 +381,14 @@ struct may_update_dispatch
394381
}
395382
};
396383

397-
template <typename Masks, int I = 0, int N = boost::tuples::length<Masks>::value>
384+
template <typename Masks, int I = 0, int N = std::tuple_size<Masks>::value>
398385
struct may_update_dispatch_tuple
399386
{
400387
template <field F1, field F2, char D, typename Matrix>
401388
static inline bool apply(Masks const& masks, Matrix const& matrix)
402389
{
403-
typedef typename boost::tuples::element<I, Masks>::type mask_type;
404-
mask_type const& mask = boost::get<I>(masks);
390+
typedef typename std::tuple_element<I, Masks>::type mask_type;
391+
mask_type const& mask = std::get<I>(masks);
405392
return may_update_dispatch<mask_type>::template apply<F1, F2, D>(mask, matrix)
406393
|| may_update_dispatch_tuple<Masks, I+1>::template apply<F1, F2, D>(masks, matrix);
407394
}
@@ -417,23 +404,10 @@ struct may_update_dispatch_tuple<Masks, N, N>
417404
}
418405
};
419406

420-
//template <typename T0, typename T1, typename T2, typename T3, typename T4,
421-
// typename T5, typename T6, typename T7, typename T8, typename T9>
422-
//struct may_update_dispatch< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
423-
//{
424-
// typedef boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> mask_type;
425-
426-
// template <field F1, field F2, char D, typename Matrix>
427-
// static inline bool apply(mask_type const& mask, Matrix const& matrix)
428-
// {
429-
// return may_update_dispatch_tuple<mask_type>::template apply<F1, F2, D>(mask, matrix);
430-
// }
431-
//};
432-
433-
template <typename Head, typename Tail>
434-
struct may_update_dispatch< boost::tuples::cons<Head, Tail> >
407+
template <typename ...Masks>
408+
struct may_update_dispatch<std::tuple<Masks...>>
435409
{
436-
typedef boost::tuples::cons<Head, Tail> mask_type;
410+
typedef std::tuple<Masks...> mask_type;
437411

438412
template <field F1, field F2, char D, typename Matrix>
439413
static inline bool apply(mask_type const& mask, Matrix const& matrix)
@@ -491,14 +465,14 @@ struct check_dispatch
491465
}
492466
};
493467

494-
template <typename Masks, int I = 0, int N = boost::tuples::length<Masks>::value>
468+
template <typename Masks, int I = 0, int N = std::tuple_size<Masks>::value>
495469
struct check_dispatch_tuple
496470
{
497471
template <typename Matrix>
498472
static inline bool apply(Masks const& masks, Matrix const& matrix)
499473
{
500-
typedef typename boost::tuples::element<I, Masks>::type mask_type;
501-
mask_type const& mask = boost::get<I>(masks);
474+
typedef typename std::tuple_element<I, Masks>::type mask_type;
475+
mask_type const& mask = std::get<I>(masks);
502476
return check_dispatch<mask_type>::apply(mask, matrix)
503477
|| check_dispatch_tuple<Masks, I+1>::apply(masks, matrix);
504478
}
@@ -514,23 +488,10 @@ struct check_dispatch_tuple<Masks, N, N>
514488
}
515489
};
516490

517-
//template <typename T0, typename T1, typename T2, typename T3, typename T4,
518-
// typename T5, typename T6, typename T7, typename T8, typename T9>
519-
//struct check_dispatch< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
520-
//{
521-
// typedef boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> mask_type;
522-
523-
// template <typename Matrix>
524-
// static inline bool apply(mask_type const& mask, Matrix const& matrix)
525-
// {
526-
// return check_dispatch_tuple<mask_type>::apply(mask, matrix);
527-
// }
528-
//};
529-
530-
template <typename Head, typename Tail>
531-
struct check_dispatch< boost::tuples::cons<Head, Tail> >
491+
template <typename ...Masks>
492+
struct check_dispatch<std::tuple<Masks...>>
532493
{
533-
typedef boost::tuples::cons<Head, Tail> mask_type;
494+
typedef std::tuple<Masks...> mask_type;
534495

535496
template <typename Matrix>
536497
static inline bool apply(mask_type const& mask, Matrix const& matrix)
@@ -555,11 +516,11 @@ struct matrix_width
555516

556517
template <typename Tuple,
557518
int I = 0,
558-
int N = boost::tuples::length<Tuple>::value>
519+
int N = std::tuple_size<Tuple>::value>
559520
struct matrix_width_tuple
560521
{
561522
static const std::size_t
562-
current = matrix_width<typename boost::tuples::element<I, Tuple>::type>::value;
523+
current = matrix_width<typename std::tuple_element<I, Tuple>::type>::value;
563524
static const std::size_t
564525
next = matrix_width_tuple<Tuple, I+1>::value;
565526

@@ -573,11 +534,11 @@ struct matrix_width_tuple<Tuple, N, N>
573534
static const std::size_t value = 0;
574535
};
575536

576-
template <typename Head, typename Tail>
577-
struct matrix_width< boost::tuples::cons<Head, Tail> >
537+
template <typename ...Masks>
538+
struct matrix_width<std::tuple<Masks...>>
578539
{
579540
static const std::size_t
580-
value = matrix_width_tuple< boost::tuples::cons<Head, Tail> >::value;
541+
value = matrix_width_tuple<std::tuple<Masks...>>::value;
581542
};
582543

583544
// mask_handler

0 commit comments

Comments
 (0)