From 83dab2d98cd985c97ad5dae0f88b85d9450ba827 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 12 Apr 2023 10:35:22 +0200 Subject: [PATCH] use auto instead of iterator types, and related --- include/boost/geometry/algorithms/append.hpp | 6 +- .../boost/geometry/algorithms/centroid.hpp | 16 +-- include/boost/geometry/algorithms/convert.hpp | 24 ++-- include/boost/geometry/algorithms/correct.hpp | 1 - .../geometry/algorithms/correct_closure.hpp | 1 - include/boost/geometry/algorithms/densify.hpp | 12 +- .../detail/buffer/buffer_inserter.hpp | 5 +- .../buffer/buffered_piece_collection.hpp | 129 ++++++------------ .../detail/buffer/get_piece_turns.hpp | 17 ++- .../buffer/turn_in_original_visitor.hpp | 13 +- .../detail/calculate_point_order.hpp | 30 ++-- .../algorithms/detail/calculate_sum.hpp | 3 +- .../detail/convex_hull/graham_andrew.hpp | 8 +- .../geometry/algorithms/detail/counting.hpp | 15 +- .../detail/disjoint/linear_areal.hpp | 7 +- .../detail/disjoint/multipoint_geometry.hpp | 3 +- .../distance/geometry_to_segment_or_box.hpp | 42 ++---- .../detail/envelope/range_of_boxes.hpp | 36 ++--- .../detail/equals/collect_vectors.hpp | 12 +- .../algorithms/detail/extreme_points.hpp | 18 +-- .../detail/has_self_intersections.hpp | 4 +- .../algorithms/detail/intersection/multi.hpp | 32 +---- .../is_simple/debug_print_boundary_points.hpp | 10 +- .../algorithms/detail/is_valid/has_spikes.hpp | 21 ++- .../detail/multi_modify_with_predicate.hpp | 5 +- .../geometry/algorithms/detail/multi_sum.hpp | 9 +- .../num_distinct_consecutive_points.hpp | 8 +- .../algorithms/detail/overlay/add_rings.hpp | 24 ++-- .../overlay/append_no_dups_or_spikes.hpp | 7 +- .../detail/overlay/assign_parents.hpp | 50 +++---- .../detail/overlay/backtrack_check_si.hpp | 16 +-- .../detail/overlay/check_enrich.hpp | 27 ++-- .../detail/overlay/clip_linestring.hpp | 5 +- .../detail/overlay/cluster_exits.hpp | 26 +--- .../detail/overlay/convert_ring.hpp | 1 + .../detail/overlay/copy_segments.hpp | 5 +- .../algorithms/detail/overlay/follow.hpp | 37 ++--- .../algorithms/detail/overlay/get_turns.hpp | 16 +-- .../detail/overlay/handle_colocations.hpp | 92 +++++-------- .../detail/overlay/handle_self_turns.hpp | 41 ++---- .../detail/overlay/intersection_insert.hpp | 28 ++-- .../detail/overlay/linear_linear.hpp | 4 +- .../algorithms/detail/overlay/overlay.hpp | 17 +-- .../detail/overlay/pointlike_linear.hpp | 5 +- .../detail/overlay/pointlike_pointlike.hpp | 16 +-- .../detail/overlay/select_rings.hpp | 34 ++--- .../detail/overlay/sort_by_side.hpp | 5 +- .../algorithms/detail/overlay/traversal.hpp | 29 ++-- .../algorithms/detail/overlay/traverse.hpp | 9 +- .../geometry/algorithms/detail/partition.hpp | 50 ++----- .../algorithms/detail/point_on_border.hpp | 7 +- .../algorithms/detail/recalculate.hpp | 7 +- .../detail/relate/follow_helpers.hpp | 7 +- .../algorithms/detail/relate/linear_areal.hpp | 9 +- .../detail/relate/multi_point_geometry.hpp | 11 +- .../algorithms/detail/relate/point_point.hpp | 34 +++-- .../detail/relate/topology_check.hpp | 19 +-- .../detail/sections/sectionalize.hpp | 6 +- .../detail/touches/implementation.hpp | 15 +- .../algorithms/detail/tupled_output.hpp | 3 +- .../algorithms/detail/within/multi_point.hpp | 12 +- .../detail/within/point_in_geometry.hpp | 55 ++++---- .../detail/within/within_no_turns.hpp | 88 ++++++------ .../boost/geometry/algorithms/for_each.hpp | 5 +- .../boost/geometry/algorithms/is_convex.hpp | 3 +- .../geometry/algorithms/line_interpolate.hpp | 7 +- .../geometry/algorithms/point_on_surface.hpp | 14 +- .../geometry/algorithms/remove_spikes.hpp | 22 +-- include/boost/geometry/algorithms/reverse.hpp | 1 - .../boost/geometry/algorithms/transform.hpp | 24 +--- include/boost/geometry/algorithms/unique.hpp | 14 +- include/boost/geometry/geometry.hpp | 2 + include/boost/geometry/io/dsv/write.hpp | 24 +--- include/boost/geometry/io/svg/svg_mapper.hpp | 17 +-- include/boost/geometry/io/svg/write.hpp | 29 +--- include/boost/geometry/io/wkt/read.hpp | 6 +- include/boost/geometry/io/wkt/write.hpp | 7 +- .../geometry/util/for_each_with_index.hpp | 19 ++- .../buffer/test_buffer_svg_per_turn.hpp | 10 +- .../overlay/multi_overlay_common.hpp | 3 +- test/algorithms/overlay/overlay_common.hpp | 3 +- .../difference/test_difference.hpp | 4 +- .../intersection/test_intersection.hpp | 5 +- .../set_operations/union/test_union.hpp | 5 +- 84 files changed, 549 insertions(+), 979 deletions(-) diff --git a/include/boost/geometry/algorithms/append.hpp b/include/boost/geometry/algorithms/append.hpp index b1bd57574..55dbc6ea1 100644 --- a/include/boost/geometry/algorithms/append.hpp +++ b/include/boost/geometry/algorithms/append.hpp @@ -91,17 +91,15 @@ struct to_polygon_point signed_size_type ring_index, signed_size_type = 0) { using ring_type = typename ring_type::type; - using exterior_ring_type = typename ring_return_type::type; - using interior_ring_range_type = typename interior_return_type::type; if (ring_index == -1) { - exterior_ring_type ext_ring = exterior_ring(polygon); + auto&& ext_ring = exterior_ring(polygon); to_range_point::apply(ext_ring, point); } else if (ring_index < signed_size_type(num_interior_rings(polygon))) { - interior_ring_range_type int_rings = interior_rings(polygon); + auto&& int_rings = interior_rings(polygon); to_range_point::apply(range::at(int_rings, ring_index), point); } } diff --git a/include/boost/geometry/algorithms/centroid.hpp b/include/boost/geometry/algorithms/centroid.hpp index 291560d34..c776015ae 100644 --- a/include/boost/geometry/algorithms/centroid.hpp +++ b/include/boost/geometry/algorithms/centroid.hpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -255,11 +254,9 @@ struct centroid_polygon_state { centroid_range_state::apply(exterior_ring(poly), transformer, strategy, state); - typename interior_return_type::type - rings = interior_rings(poly); - - for (typename detail::interior_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it) + auto const& rings = interior_rings(poly); + auto const end = boost::end(rings); + for (auto it = boost::begin(rings); it != end; ++it) { centroid_range_state::apply(*it, transformer, strategy, state); } @@ -352,15 +349,12 @@ struct centroid_multi Point >::type state; - for (typename boost::range_iterator::type - it = boost::begin(multi); - it != boost::end(multi); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { Policy::apply(*it, transformer, strategy, state); } - if ( strategy.result(state, centroid) ) + if (strategy.result(state, centroid)) { // translate the result back transformer.apply_reverse(centroid); diff --git a/include/boost/geometry/algorithms/convert.hpp b/include/boost/geometry/algorithms/convert.hpp index ac9cffa45..7869543b5 100644 --- a/include/boost/geometry/algorithms/convert.hpp +++ b/include/boost/geometry/algorithms/convert.hpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -128,7 +127,7 @@ struct segment_to_range { traits::resize::apply(range, 2); - typename boost::range_iterator::type it = boost::begin(range); + auto it = boost::begin(range); assign_point_from_index<0>(segment, *it); ++it; @@ -186,8 +185,7 @@ struct range_to_range // but ok, sice below it == end() size_type i = 0; - for (typename boost::range_iterator::type it - = boost::begin(view); + for (auto it = boost::begin(view); it != boost::end(view) && i < n; ++it, ++i) { @@ -227,15 +225,11 @@ struct polygon_to_polygon >::type >::apply(interior_rings(destination), num_interior_rings(source)); - typename interior_return_type::type - rings_source = interior_rings(source); - typename interior_return_type::type - rings_dest = interior_rings(destination); + auto const& rings_source = interior_rings(source); + auto&& rings_dest = interior_rings(destination); - typename detail::interior_iterator::type - it_source = boost::begin(rings_source); - typename detail::interior_iterator::type - it_dest = boost::begin(rings_dest); + auto it_source = boost::begin(rings_source); + auto it_dest = boost::begin(rings_dest); for ( ; it_source != boost::end(rings_source); ++it_source, ++it_dest) { @@ -263,10 +257,8 @@ struct multi_to_multi: private Policy { traits::resize::apply(multi2, boost::size(multi1)); - typename boost::range_iterator::type it1 - = boost::begin(multi1); - typename boost::range_iterator::type it2 - = boost::begin(multi2); + auto it1 = boost::begin(multi1); + auto it2 = boost::begin(multi2); for (; it1 != boost::end(multi1); ++it1, ++it2) { diff --git a/include/boost/geometry/algorithms/correct.hpp b/include/boost/geometry/algorithms/correct.hpp index 9d1f246a6..263af100a 100644 --- a/include/boost/geometry/algorithms/correct.hpp +++ b/include/boost/geometry/algorithms/correct.hpp @@ -30,7 +30,6 @@ #include #include -#include #include #include diff --git a/include/boost/geometry/algorithms/correct_closure.hpp b/include/boost/geometry/algorithms/correct_closure.hpp index 60b8beef5..baa41bc5b 100644 --- a/include/boost/geometry/algorithms/correct_closure.hpp +++ b/include/boost/geometry/algorithms/correct_closure.hpp @@ -15,7 +15,6 @@ #include -#include #include #include diff --git a/include/boost/geometry/algorithms/densify.hpp b/include/boost/geometry/algorithms/densify.hpp index 84e32bb2f..2390fef7f 100644 --- a/include/boost/geometry/algorithms/densify.hpp +++ b/include/boost/geometry/algorithms/densify.hpp @@ -78,11 +78,10 @@ struct densify_range static inline void apply(FwdRng const& rng, MutRng & rng_out, T const& len, Strategies const& strategies) { - typedef typename boost::range_iterator::type iterator_t; typedef typename boost::range_value::type point_t; - iterator_t it = boost::begin(rng); - iterator_t end = boost::end(rng); + auto it = boost::begin(rng); + auto const end = boost::end(rng); if (it == end) // empty(rng) { @@ -92,7 +91,7 @@ struct densify_range auto strategy = strategies.densify(rng); push_back_policy policy(rng_out); - iterator_t prev = it; + auto prev = it; for ( ++it ; it != end ; prev = it++) { point_t const& p0 = *prev; @@ -123,9 +122,8 @@ struct densify_ring if (boost::size(ring) <= 1) return; - typedef typename point_type::type point_t; - point_t const& p0 = range::back(ring); - point_t const& p1 = range::front(ring); + auto const& p0 = range::back(ring); + auto const& p1 = range::front(ring); auto strategy = strategies.densify(ring); push_back_policy policy(ring_out); diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp index 8d5ffe2b8..51ba1abfe 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp @@ -354,10 +354,7 @@ struct buffer_multi RobustPolicy const& robust_policy, Strategies const& strategies) { - for (typename boost::range_iterator::type - it = boost::begin(multi); - it != boost::end(multi); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { Policy::apply(*it, collection, distance_strategy, segment_strategy, diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp index d087e604b..df6849213 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -59,6 +59,7 @@ #include #include +#include #include @@ -295,12 +296,9 @@ struct buffered_piece_collection // and only applicable for linear features // (in a multi linestring with many short lines, the #endpoints can be // much higher) - for (typename boost::range_iterator const>::type it - = boost::begin(m_linear_end_points); - it != boost::end(m_linear_end_points); - ++it) + for (auto const& p : m_linear_end_points) { - if (detail::equals::equals_point_point(turn.point, *it, m_strategy)) + if (detail::equals::equals_point_point(turn.point, p, m_strategy)) { turn.is_linear_end_point = true; } @@ -324,12 +322,9 @@ struct buffered_piece_collection enriched_map_buffer_include_policy()); // Sort turns over offsetted ring(s) - for (typename mapped_vector_type::iterator mit - = mapped_vector.begin(); - mit != mapped_vector.end(); - ++mit) + for (auto& pair : mapped_vector) { - std::sort(mit->second.begin(), mit->second.end(), buffer_less()); + std::sort(pair.second.begin(), pair.second.end(), buffer_less()); } } @@ -342,17 +337,14 @@ struct buffered_piece_collection // Deflated rings may not travel to themselves, there should at least // be three turns (which cannot be checked here - TODO: add to traverse) - for (typename boost::range_iterator::type it = - boost::begin(m_turns); it != boost::end(m_turns); ++it) + for (auto& turn : m_turns) { - buffer_turn_info_type& turn = *it; if (! turn.is_turn_traversable) { continue; } - for (int i = 0; i < 2; i++) + for (auto& op : turn.operations) { - buffer_turn_operation_type& op = turn.operations[i]; if (op.enriched.get_next_turn_index() == static_cast(turn.turn_index) && m_pieces[op.seg_id.piece_index].is_deflated) { @@ -385,10 +377,8 @@ struct buffered_piece_collection bool const deflate = m_distance_strategy.negative(); - for (typename boost::range_iterator::type it = - boost::begin(m_turns); it != boost::end(m_turns); ++it) + for (auto& turn : m_turns) { - buffer_turn_info_type& turn = *it; if (turn.is_turn_traversable) { if (deflate && turn.count_in_original <= 0) @@ -408,13 +398,8 @@ struct buffered_piece_collection inline void update_turn_administration() { - std::size_t index = 0; - for (typename boost::range_iterator::type it = - boost::begin(m_turns); it != boost::end(m_turns); ++it, ++index) + for_each_with_index(m_turns, [this](std::size_t index, auto& turn) { - buffer_turn_info_type& turn = *it; - - // Update member used turn.turn_index = index; // Verify if a turn is a linear endpoint @@ -422,7 +407,7 @@ struct buffered_piece_collection { check_linear_endpoints(turn); } - } + }); } // Calculate properties of piece borders which are not influenced @@ -434,11 +419,8 @@ struct buffered_piece_collection // - (if pieces are reversed) inline void update_piece_administration() { - for (typename piece_vector_type::iterator it = boost::begin(m_pieces); - it != boost::end(m_pieces); - ++it) + for (auto& pc : m_pieces) { - piece& pc = *it; piece_border_type& border = pc.m_piece_border; buffered_ring const& ring = offsetted_rings[pc.first_seg_id.multi_index]; @@ -791,7 +773,7 @@ struct buffered_piece_collection { BOOST_GEOMETRY_ASSERT(boost::size(range) != 0u); - typename Range::const_iterator it = boost::begin(range); + auto it = boost::begin(range); // If it follows a non-join (so basically the same piece-type) point b1 should be added. // There should be two intersections later and it should be discarded. @@ -928,18 +910,17 @@ struct buffered_piece_collection // Those can never be traversed and should not be part of the output. inline void discard_rings() { - for (typename boost::range_iterator::type it = - boost::begin(m_turns); it != boost::end(m_turns); ++it) + for (auto const& turn : m_turns) { - if (it->is_turn_traversable) + if (turn.is_turn_traversable) { - offsetted_rings[it->operations[0].seg_id.multi_index].has_accepted_intersections = true; - offsetted_rings[it->operations[1].seg_id.multi_index].has_accepted_intersections = true; + offsetted_rings[turn.operations[0].seg_id.multi_index].has_accepted_intersections = true; + offsetted_rings[turn.operations[1].seg_id.multi_index].has_accepted_intersections = true; } else { - offsetted_rings[it->operations[0].seg_id.multi_index].has_discarded_intersections = true; - offsetted_rings[it->operations[1].seg_id.multi_index].has_discarded_intersections = true; + offsetted_rings[turn.operations[0].seg_id.multi_index].has_discarded_intersections = true; + offsetted_rings[turn.operations[1].seg_id.multi_index].has_discarded_intersections = true; } } } @@ -952,12 +933,8 @@ struct buffered_piece_collection // any of the robust original rings // This can go quadratic if the input has many rings, and there // are many untouched deflated rings around - for (typename std::vector::const_iterator it - = original_rings.begin(); - it != original_rings.end(); - ++it) + for (auto const& original : original_rings) { - original_ring const& original = *it; if (original.m_ring.empty()) { continue; @@ -999,12 +976,8 @@ struct buffered_piece_collection // be discarded inline void discard_nonintersecting_deflated_rings() { - for(typename buffered_ring_collection >::iterator it - = boost::begin(offsetted_rings); - it != boost::end(offsetted_rings); - ++it) + for (auto& ring : offsetted_rings) { - buffered_ring& ring = *it; if (! ring.has_intersections() && boost::size(ring) > 0u && geometry::area(ring, m_strategy) < 0) @@ -1019,10 +992,8 @@ struct buffered_piece_collection inline void block_turns() { - for (typename boost::range_iterator::type it = - boost::begin(m_turns); it != boost::end(m_turns); ++it) + for (auto& turn : m_turns) { - buffer_turn_info_type& turn = *it; if (! turn.is_turn_traversable) { // Discard this turn (don't set it to blocked to avoid colocated @@ -1055,21 +1026,16 @@ struct buffered_piece_collection inline void reverse() { - for(typename buffered_ring_collection >::iterator it = boost::begin(offsetted_rings); - it != boost::end(offsetted_rings); - ++it) + for (auto& ring : offsetted_rings) { - if (! it->has_intersections()) + if (! ring.has_intersections()) { - std::reverse(it->begin(), it->end()); + std::reverse(ring.begin(), ring.end()); } } - for (typename boost::range_iterator >::type - it = boost::begin(traversed_rings); - it != boost::end(traversed_rings); - ++it) + for (auto& ring : traversed_rings) { - std::reverse(it->begin(), it->end()); + std::reverse(ring.begin(), ring.end()); } } @@ -1091,37 +1057,30 @@ struct buffered_piece_collection // Inner rings, for deflate, which do not have intersections, and // which are outside originals, are skipped // (other ones should be traversed) - signed_size_type index = 0; - for(typename buffered_ring_collection >::const_iterator it = boost::begin(offsetted_rings); - it != boost::end(offsetted_rings); - ++it, ++index) - { - if (! it->has_intersections() - && ! it->is_untouched_outside_original) + for_each_with_index(offsetted_rings, [&](std::size_t index, auto const& ring) { - properties p = properties(*it, m_strategy); - if (p.valid) + if (! ring.has_intersections() + && ! ring.is_untouched_outside_original) { - ring_identifier id(0, index, -1); - selected[id] = p; + properties p = properties(ring, m_strategy); + if (p.valid) + { + ring_identifier id(0, index, -1); + selected[id] = p; + } } - } - } + }); // Select all created rings - index = 0; - for (typename boost::range_iterator const>::type - it = boost::begin(traversed_rings); - it != boost::end(traversed_rings); - ++it, ++index) - { - properties p = properties(*it, m_strategy); - if (p.valid) + for_each_with_index(traversed_rings, [&](std::size_t index, auto const& ring) { - ring_identifier id(2, index, -1); - selected[id] = p; - } - } + properties p = properties(ring, m_strategy); + if (p.valid) + { + ring_identifier id(2, index, -1); + selected[id] = p; + } + }); detail::overlay::assign_parents(offsetted_rings, traversed_rings, selected, m_strategy); diff --git a/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp b/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp index 09fef7518..c5b0aedc7 100644 --- a/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp @@ -194,7 +194,6 @@ class piece_turn_visitor { typedef typename boost::range_value::type ring_type; typedef typename boost::range_value::type turn_type; - typedef typename boost::range_iterator::type iterator; signed_size_type const piece1_first_index = piece1.first_seg_id.segment_index; signed_size_type const piece2_first_index = piece2.first_seg_id.segment_index; @@ -213,12 +212,12 @@ class piece_turn_visitor // get geometry and iterators over these sections ring_type const& ring1 = m_rings[piece1.first_seg_id.multi_index]; - iterator it1_first = boost::begin(ring1) + sec1_first_index; - iterator it1_beyond = boost::begin(ring1) + sec1_last_index + 1; + auto it1_first = boost::begin(ring1) + sec1_first_index; + auto it1_beyond = boost::begin(ring1) + sec1_last_index + 1; ring_type const& ring2 = m_rings[piece2.first_seg_id.multi_index]; - iterator it2_first = boost::begin(ring2) + sec2_first_index; - iterator it2_beyond = boost::begin(ring2) + sec2_last_index + 1; + auto it2_first = boost::begin(ring2) + sec2_first_index; + auto it2_beyond = boost::begin(ring2) + sec2_last_index + 1; // Set begin/end of monotonic ranges, in both x/y directions signed_size_type index1 = sec1_first_index; @@ -246,8 +245,8 @@ class piece_turn_visitor the_model.operations[0].seg_id = piece1.first_seg_id; the_model.operations[0].seg_id.segment_index = index1; // override - iterator it1 = it1_first; - for (iterator prev1 = it1++; + auto it1 = it1_first; + for (auto prev1 = it1++; it1 != it1_beyond; prev1 = it1++, the_model.operations[0].seg_id.segment_index++) { @@ -257,8 +256,8 @@ class piece_turn_visitor unique_sub_range_from_piece unique_sub_range1(ring1, prev1, it1); - iterator it2 = it2_first; - for (iterator prev2 = it2++; + auto it2 = it2_first; + for (auto prev2 = it2++; it2 != it2_beyond; prev2 = it2++, the_model.operations[1].seg_id.segment_index++) { diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp index b1930dc0c..ca598cc68 100644 --- a/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp @@ -190,20 +190,11 @@ inline int point_in_original(Point const& point, Original const& original, return strategy.result(state); } - typedef typename Original::sections_type sections_type; - typedef typename boost::range_iterator::type iterator_type; - typedef typename boost::range_value::type section_type; - typedef typename geometry::coordinate_type::type coordinate_type; - - coordinate_type const point_x = geometry::get<0>(point); + auto const point_x = geometry::get<0>(point); // Walk through all monotonic sections of this original - for (iterator_type it = boost::begin(original.m_sections); - it != boost::end(original.m_sections); - ++it) + for (auto const& section : original.m_sections) { - section_type const& section = *it; - if (! section.duplicate && section.begin_index < section.end_index && point_x >= geometry::get(section.bounding_box) diff --git a/include/boost/geometry/algorithms/detail/calculate_point_order.hpp b/include/boost/geometry/algorithms/detail/calculate_point_order.hpp index a9362b361..412ea56d7 100644 --- a/include/boost/geometry/algorithms/detail/calculate_point_order.hpp +++ b/include/boost/geometry/algorithms/detail/calculate_point_order.hpp @@ -36,7 +36,7 @@ struct clean_point , m_is_azi_valid(false), m_is_azi_diff_valid(false) {} - typename boost::iterators::iterator_reference::type ref() const + decltype(auto) ref() const { return *m_iter; } @@ -108,8 +108,6 @@ struct calculate_point_order_by_azimuth typedef typename boost::range_iterator::type iter_t; typedef typename Strategy::template result_type::type calc_t; typedef clean_point clean_point_t; - typedef std::vector cleaned_container_t; - typedef typename cleaned_container_t::iterator cleaned_iter_t; calc_t const zero = 0; calc_t const pi = math::pi(); @@ -121,7 +119,7 @@ struct calculate_point_order_by_azimuth } // non-duplicated, non-spike points - cleaned_container_t cleaned; + std::vector cleaned; cleaned.reserve(count); for (iter_t it = boost::begin(ring); it != boost::end(ring); ++it) @@ -131,9 +129,9 @@ struct calculate_point_order_by_azimuth while (cleaned.size() >= 3) { - cleaned_iter_t it0 = cleaned.end() - 3; - cleaned_iter_t it1 = cleaned.end() - 2; - cleaned_iter_t it2 = cleaned.end() - 1; + auto it0 = cleaned.end() - 3; + auto it1 = cleaned.end() - 2; + auto it2 = cleaned.end() - 1; calc_t diff; if (get_or_calculate_azimuths_difference(*it0, *it1, *it2, diff, strategy) @@ -156,8 +154,8 @@ struct calculate_point_order_by_azimuth } // filter-out duplicates and spikes at the front and back of cleaned - cleaned_iter_t cleaned_b = cleaned.begin(); - cleaned_iter_t cleaned_e = cleaned.end(); + auto cleaned_b = cleaned.begin(); + auto cleaned_e = cleaned.end(); std::size_t cleaned_count = cleaned.size(); bool found = false; do @@ -165,10 +163,10 @@ struct calculate_point_order_by_azimuth found = false; while(cleaned_count >= 3) { - cleaned_iter_t it0 = cleaned_e - 2; - cleaned_iter_t it1 = cleaned_e - 1; - cleaned_iter_t it2 = cleaned_b; - cleaned_iter_t it3 = cleaned_b + 1; + auto it0 = cleaned_e - 2; + auto it1 = cleaned_e - 1; + auto it2 = cleaned_b; + auto it3 = cleaned_b + 1; calc_t diff = 0; if (! get_or_calculate_azimuths_difference(*it0, *it1, *it2, diff, strategy) @@ -212,10 +210,10 @@ struct calculate_point_order_by_azimuth // calculate the sum of external angles calc_t angles_sum = zero; - for (cleaned_iter_t it = cleaned_b; it != cleaned_e; ++it) + for (auto it = cleaned_b; it != cleaned_e; ++it) { - cleaned_iter_t it0 = (it == cleaned_b ? cleaned_e - 1 : it - 1); - cleaned_iter_t it2 = (it == cleaned_e - 1 ? cleaned_b : it + 1); + auto it0 = (it == cleaned_b ? cleaned_e - 1 : it - 1); + auto it2 = (it == cleaned_e - 1 ? cleaned_b : it + 1); calc_t diff = 0; get_or_calculate_azimuths_difference(*it0, *it, *it2, diff, strategy); diff --git a/include/boost/geometry/algorithms/detail/calculate_sum.hpp b/include/boost/geometry/algorithms/detail/calculate_sum.hpp index 4af986fb6..4296d88e6 100644 --- a/include/boost/geometry/algorithms/detail/calculate_sum.hpp +++ b/include/boost/geometry/algorithms/detail/calculate_sum.hpp @@ -37,8 +37,7 @@ class calculate_polygon_sum static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy) { ReturnType sum = ReturnType(0); - for (typename boost::range_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it) + for (auto it = boost::begin(rings); it != boost::end(rings); ++it) { sum += Policy::apply(*it, strategy); } diff --git a/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp b/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp index 9e59927f5..2bc1fc435 100644 --- a/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp +++ b/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp @@ -148,8 +148,6 @@ class graham_andrew { typedef InputPoint point_type; typedef typename std::vector container_type; - typedef typename std::vector::const_iterator iterator; - typedef typename std::vector::const_reverse_iterator rev_iterator; class partitions { @@ -228,9 +226,9 @@ private: SideStrategy const& side) { output.push_back(left); - for(iterator it = input.begin(); it != input.end(); ++it) + for (auto const& i : input) { - add_to_hull(*it, output, side); + add_to_hull(i, output, side); } add_to_hull(right, output, side); } @@ -244,7 +242,7 @@ private: std::size_t output_size = output.size(); while (output_size >= 3) { - rev_iterator rit = output.rbegin(); + auto rit = output.rbegin(); point_type const last = *rit++; point_type const& last2 = *rit++; diff --git a/include/boost/geometry/algorithms/detail/counting.hpp b/include/boost/geometry/algorithms/detail/counting.hpp index 3580740b3..0199ec0b9 100644 --- a/include/boost/geometry/algorithms/detail/counting.hpp +++ b/include/boost/geometry/algorithms/detail/counting.hpp @@ -30,8 +30,6 @@ #include -#include - namespace boost { namespace geometry { @@ -67,10 +65,8 @@ struct polygon_count { std::size_t n = RangeCount::apply(exterior_ring(poly)); - typename interior_return_type::type - rings = interior_rings(poly); - for (typename detail::interior_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it) + auto const& rings = interior_rings(poly); + for (auto it = boost::begin(rings); it != boost::end(rings); ++it) { n += RangeCount::apply(*it); } @@ -84,13 +80,10 @@ template struct multi_count { template - static inline std::size_t apply(MultiGeometry const& geometry) + static inline std::size_t apply(MultiGeometry const& multi) { std::size_t n = 0; - for (typename boost::range_iterator::type - it = boost::begin(geometry); - it != boost::end(geometry); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { n += SingleCount::apply(*it); } diff --git a/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp b/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp index 47c1ae028..860585ab4 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp @@ -89,12 +89,11 @@ struct disjoint_no_intersections_policy static inline bool apply(Geometry1 const& g1, Geometry2 const& g2, Strategy const& strategy) { // TODO: use partition or rtree on g2 - typedef typename boost::range_iterator::type iterator; - for ( iterator it = boost::begin(g1) ; it != boost::end(g1) ; ++it ) + for (auto it = boost::begin(g1); it != boost::end(g1); ++it) { typedef typename boost::range_value::type value_type; - if ( ! disjoint_no_intersections_policy - ::apply(*it, g2, strategy) ) + if (! disjoint_no_intersections_policy + ::apply(*it, g2, strategy)) { return false; } diff --git a/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp b/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp index ac129a998..7e3b56cb0 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp @@ -291,8 +291,7 @@ public: geometry::envelope(single_geometry, box2, strategy); geometry::detail::expand_by_epsilon(box2); - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(multi_point) ; it != boost::end(multi_point) ; ++it ) + for (auto it = boost::begin(multi_point) ; it != boost::end(multi_point) ; ++it) { // The default strategy is enough for Point/Box if (! detail::disjoint::disjoint_point_box(*it, box2, strategy) diff --git a/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp index 6a852ec43..882fdc00b 100644 --- a/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp @@ -163,17 +163,11 @@ public: Strategies const& strategies, bool check_intersection = true) { - typedef geometry::point_iterator point_iterator_type; typedef geometry::segment_iterator < Geometry const > segment_iterator_type; - typedef typename boost::range_const_iterator - < - std::vector - >::type seg_or_box_const_iterator; - typedef assign_new_min_iterator assign_new_value; @@ -203,25 +197,20 @@ public: // consider all distances of the points in the geometry to the // segment or box comparable_return_type cd_min1(0); - point_iterator_type pit_min; - seg_or_box_const_iterator it_min1 = boost::const_begin(seg_or_box_points); - seg_or_box_const_iterator it_min2 = it_min1; - ++it_min2; + auto pit_min = points_begin(geometry); + auto it_min1 = boost::const_begin(seg_or_box_points); + auto it_min2 = it_min1 + 1; bool first = true; - for (point_iterator_type pit = points_begin(geometry); + for (auto pit = pit_min; pit != points_end(geometry); ++pit, first = false) { comparable_return_type cd; - std::pair - < - seg_or_box_const_iterator, seg_or_box_const_iterator - > it_pair - = point_to_point_range::apply(*pit, - boost::const_begin(seg_or_box_points), - boost::const_end(seg_or_box_points), - cstrategy, - cd); + auto it_pair = point_to_point_range::apply(*pit, + boost::const_begin(seg_or_box_points), + boost::const_end(seg_or_box_points), + cstrategy, + cd); if (first || cd < cd_min1) { @@ -236,10 +225,10 @@ public: // segments of the geometry comparable_return_type cd_min2(0); segment_iterator_type sit_min; - seg_or_box_const_iterator it_min; + auto it_min = boost::const_begin(seg_or_box_points); first = true; - for (seg_or_box_const_iterator it = boost::const_begin(seg_or_box_points); + for (auto it = boost::const_begin(seg_or_box_points); it != boost::const_end(seg_or_box_points); ++it, first = false) { comparable_return_type cd; @@ -299,14 +288,7 @@ class geometry_to_segment_or_box { private: typedef detail::closest_feature::geometry_to_range base_type; - - typedef typename boost::range_iterator - < - MultiPoint const - >::type iterator_type; - typedef detail::closest_feature::geometry_to_range geometry_to_range; - typedef distance::strategy_t strategy_type; public: @@ -318,7 +300,7 @@ public: { distance::creturn_t cd_min; - iterator_type it_min + auto const it_min = geometry_to_range::apply(segment_or_box, boost::begin(multipoint), boost::end(multipoint), diff --git a/include/boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp b/include/boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp index c55be0343..5da556d41 100644 --- a/include/boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp @@ -162,11 +162,6 @@ struct envelope_range_of_boxes_by_expansion { typedef typename boost::range_value::type box_type; - typedef typename boost::range_iterator - < - RangeOfBoxes const - >::type iterator_type; - // first initialize MBR detail::indexed_point_view mbr_min(mbr); detail::indexed_point_view mbr_max(mbr); @@ -194,7 +189,7 @@ struct envelope_range_of_boxes_by_expansion >::apply(first_box_max, mbr_max); // now expand using the remaining boxes - iterator_type it = boost::begin(range_of_boxes); + auto it = boost::begin(range_of_boxes); for (++it; it != boost::end(range_of_boxes); ++it) { detail::expand::indexed_loop @@ -237,10 +232,6 @@ struct envelope_range_of_boxes typedef typename boost::range_value::type box_type; typedef typename coordinate_type::type coordinate_type; typedef typename detail::cs_angular_units::type units_type; - typedef typename boost::range_iterator - < - RangeOfBoxes const - >::type iterator_type; static const bool is_equatorial = ! std::is_same < @@ -258,29 +249,30 @@ struct envelope_range_of_boxes BOOST_GEOMETRY_ASSERT(! boost::empty(range_of_boxes)); - iterator_type it_min = std::min_element(boost::begin(range_of_boxes), - boost::end(range_of_boxes), - latitude_less()); - iterator_type it_max = std::max_element(boost::begin(range_of_boxes), - boost::end(range_of_boxes), - latitude_less()); + auto const it_min = std::min_element(boost::begin(range_of_boxes), + boost::end(range_of_boxes), + latitude_less()); + auto const it_max = std::max_element(boost::begin(range_of_boxes), + boost::end(range_of_boxes), + latitude_less()); coordinate_type const min_longitude = constants::min_longitude(); coordinate_type const max_longitude = constants::max_longitude(); coordinate_type const period = constants::period(); interval_range_type intervals; - for (iterator_type it = boost::begin(range_of_boxes); + for (auto it = boost::begin(range_of_boxes); it != boost::end(range_of_boxes); ++it) { - if (is_inverse_spheroidal_coordinates(*it)) + auto const& box = *it; + if (is_inverse_spheroidal_coordinates(box)) { continue; } - coordinate_type lat_min = geometry::get(*it); - coordinate_type lat_max = geometry::get(*it); + coordinate_type lat_min = geometry::get(box); + coordinate_type lat_max = geometry::get(box); if (math::equals(lat_min, constants::max_latitude()) || math::equals(lat_max, constants::min_latitude())) { @@ -289,8 +281,8 @@ struct envelope_range_of_boxes continue; } - coordinate_type lon_left = geometry::get(*it); - coordinate_type lon_right = geometry::get(*it); + coordinate_type lon_left = geometry::get(box); + coordinate_type lon_right = geometry::get(box); if (math::larger(lon_right, max_longitude)) { diff --git a/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp b/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp index 3abd01cf5..b908c3e53 100644 --- a/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp +++ b/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp @@ -22,7 +22,6 @@ #include -#include #include #include @@ -400,10 +399,8 @@ struct polygon_collect_vectors typedef range_collect_vectors per_range; per_range::apply(collection, exterior_ring(polygon)); - typename interior_return_type::type - rings = interior_rings(polygon); - for (typename detail::interior_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it) + auto const& rings = interior_rings(polygon); + for (auto it = boost::begin(rings); it != boost::end(rings); ++it) { per_range::apply(collection, *it); } @@ -416,10 +413,7 @@ struct multi_collect_vectors { static inline void apply(Collection& collection, MultiGeometry const& multi) { - for (typename boost::range_iterator::type - it = boost::begin(multi); - it != boost::end(multi); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { SinglePolicy::apply(collection, *it); } diff --git a/include/boost/geometry/algorithms/detail/extreme_points.hpp b/include/boost/geometry/algorithms/detail/extreme_points.hpp index a6605fd45..2ac13fc1e 100644 --- a/include/boost/geometry/algorithms/detail/extreme_points.hpp +++ b/include/boost/geometry/algorithms/detail/extreme_points.hpp @@ -26,7 +26,6 @@ #include #include -#include #include @@ -124,7 +123,6 @@ struct extreme_points_on_ring { typedef typename geometry::coordinate_type::type coordinate_type; - typedef typename boost::range_iterator::type range_iterator; typedef typename geometry::point_type::type point_type; template @@ -288,8 +286,7 @@ struct extreme_points_on_ring template static inline bool right_turn(Ring const& ring, Iterator it, SideStrategy const& strategy) { - typename std::iterator_traits::difference_type const index - = std::distance(boost::begin(ring), it); + auto const index = std::distance(boost::begin(ring), it); geometry::ever_circling_range_iterator left(ring); geometry::ever_circling_range_iterator right(ring); left += index; @@ -326,9 +323,9 @@ struct extreme_points_on_ring // Get all maxima, usually one. In case of self-tangencies, or self-crossings, // the max might be is not valid. A valid max should make a right turn - range_iterator max_it = boost::begin(ring); + auto max_it = boost::begin(ring); compare smaller; - for (range_iterator it = max_it + 1; it != boost::end(ring); ++it) + for (auto it = max_it + 1; it != boost::end(ring); ++it) { if (smaller(*max_it, *it) && right_turn(ring, it, strategy)) { @@ -341,8 +338,7 @@ struct extreme_points_on_ring return false; } - typename std::iterator_traits::difference_type const - index = std::distance(boost::begin(ring), max_it); + auto const index = std::distance(boost::begin(ring), max_it); //std::cout << "Extreme point lies at " << index << " having " << geometry::wkt(*max_it) << std::endl; geometry::ever_circling_range_iterator left(ring); @@ -429,10 +425,8 @@ struct extreme_points } // For a polygon, its interior rings can contain intruders - typename interior_return_type::type - rings = interior_rings(polygon); - for (typename detail::interior_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it) + auto const& rings = interior_rings(polygon); + for (auto it = boost::begin(rings); it != boost::end(rings); ++it) { ring_implementation::get_intruders(*it, extremes, intruders, strategy); } diff --git a/include/boost/geometry/algorithms/detail/has_self_intersections.hpp b/include/boost/geometry/algorithms/detail/has_self_intersections.hpp index 805ab6754..0b13eb7bd 100644 --- a/include/boost/geometry/algorithms/detail/has_self_intersections.hpp +++ b/include/boost/geometry/algorithms/detail/has_self_intersections.hpp @@ -91,10 +91,8 @@ inline bool has_self_intersections(Geometry const& geometry, #ifdef BOOST_GEOMETRY_DEBUG_HAS_SELF_INTERSECTIONS bool first = true; #endif - for(typename std::deque::const_iterator it = boost::begin(turns); - it != boost::end(turns); ++it) + for (auto const& info : turns) { - turn_info const& info = *it; bool const both_union_turn = info.operations[0].operation == detail::overlay::operation_union && info.operations[1].operation == detail::overlay::operation_union; diff --git a/include/boost/geometry/algorithms/detail/intersection/multi.hpp b/include/boost/geometry/algorithms/detail/intersection/multi.hpp index 135d85170..7810abab5 100644 --- a/include/boost/geometry/algorithms/detail/intersection/multi.hpp +++ b/include/boost/geometry/algorithms/detail/intersection/multi.hpp @@ -64,19 +64,9 @@ struct intersection_multi_linestring_multi_linestring_point { // Note, this loop is quadratic w.r.t. number of linestrings per input. // Future Enhancement: first do the sections of each, then intersect. - for (typename boost::range_iterator - < - MultiLinestring1 const - >::type it1 = boost::begin(ml1); - it1 != boost::end(ml1); - ++it1) + for (auto it1 = boost::begin(ml1); it1 != boost::end(ml1); ++it1) { - for (typename boost::range_iterator - < - MultiLinestring2 const - >::type it2 = boost::begin(ml2); - it2 != boost::end(ml2); - ++it2) + for (auto it2 = boost::begin(ml2); it2 != boost::end(ml2); ++it2) { out = intersection_linestring_linestring_point ::apply(*it1, *it2, robust_policy, out, strategy); @@ -103,12 +93,7 @@ struct intersection_linestring_multi_linestring_point OutputIterator out, Strategy const& strategy) { - for (typename boost::range_iterator - < - MultiLinestring const - >::type it = boost::begin(ml); - it != boost::end(ml); - ++it) + for (auto it = boost::begin(ml); it != boost::end(ml); ++it) { out = intersection_linestring_linestring_point ::apply(linestring, *it, robust_policy, out, strategy); @@ -141,12 +126,7 @@ struct intersection_of_multi_linestring_with_areal OutputIterator out, Strategy const& strategy) { - for (typename boost::range_iterator - < - MultiLinestring const - >::type it = boost::begin(ml); - it != boost::end(ml); - ++it) + for (auto it = boost::begin(ml); it != boost::end(ml); ++it) { out = intersection_of_linestring_with_areal < @@ -205,9 +185,7 @@ struct clip_multi_linestring { typedef typename point_type::type point_type; strategy::intersection::liang_barsky lb_strategy; - for (typename boost::range_iterator::type it - = boost::begin(multi_linestring); - it != boost::end(multi_linestring); ++it) + for (auto it = boost::begin(multi_linestring); it != boost::end(multi_linestring); ++it) { out = detail::intersection::clip_range_with_box (box, *it, robust_policy, out, lb_strategy); diff --git a/include/boost/geometry/algorithms/detail/is_simple/debug_print_boundary_points.hpp b/include/boost/geometry/algorithms/detail/is_simple/debug_print_boundary_points.hpp index b336d44f6..7136e5167 100644 --- a/include/boost/geometry/algorithms/detail/is_simple/debug_print_boundary_points.hpp +++ b/include/boost/geometry/algorithms/detail/is_simple/debug_print_boundary_points.hpp @@ -69,9 +69,7 @@ struct debug_boundary_points_printer typedef std::vector point_vector; point_vector boundary_points; - for (typename boost::range_iterator::type it - = boost::begin(multilinestring); - it != boost::end(multilinestring); ++it) + for (auto it = boost::begin(multilinestring); it != boost::end(multilinestring); ++it) { if ( boost::size(*it) > 1 && !geometry::equals(range::front(*it), range::back(*it)) ) @@ -85,11 +83,9 @@ struct debug_boundary_points_printer geometry::less()); std::cout << "boundary points: "; - for (typename point_vector::const_iterator - pit = boundary_points.begin(); - pit != boundary_points.end(); ++pit) + for (auto const& p : boundary_points) { - std::cout << " " << geometry::dsv(*pit); + std::cout << " " << geometry::dsv(p); } std::cout << std::endl << std::endl; } diff --git a/include/boost/geometry/algorithms/detail/is_valid/has_spikes.hpp b/include/boost/geometry/algorithms/detail/is_valid/has_spikes.hpp index 6dbaa49bc..08e9ab43d 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/has_spikes.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/has_spikes.hpp @@ -56,7 +56,9 @@ struct has_spikes Strategy const& strategy) { if (first == last) + { return last; + } auto const& front = *first; ++first; return std::find_if(first, last, [&](auto const& pt) { @@ -71,18 +73,12 @@ struct has_spikes { boost::ignore_unused(visitor); - typedef typename boost::range_iterator::type iterator; + auto cur = boost::begin(view); + auto prev = find_different_from_first(boost::rbegin(view), + boost::rend(view), + strategy); - iterator cur = boost::begin(view); - typename boost::range_reverse_iterator - < - View const - >::type prev = find_different_from_first(boost::rbegin(view), - boost::rend(view), - strategy); - - iterator next = find_different_from_first(cur, boost::end(view), - strategy); + auto next = find_different_from_first(cur, boost::end(view), strategy); if (detail::is_spike_or_equal(*next, *cur, *prev, strategy.side())) { return ! visitor.template apply(is_linear, *cur); @@ -131,8 +127,7 @@ struct has_spikes // also in geographic cases going over the pole if (detail::is_spike_or_equal(*next, *cur, *prev, strategy.side())) { - return - ! visitor.template apply(is_linestring, *cur); + return ! visitor.template apply(is_linestring, *cur); } prev = cur; cur = next; diff --git a/include/boost/geometry/algorithms/detail/multi_modify_with_predicate.hpp b/include/boost/geometry/algorithms/detail/multi_modify_with_predicate.hpp index 4dcc919e9..8d0ec2cb5 100644 --- a/include/boost/geometry/algorithms/detail/multi_modify_with_predicate.hpp +++ b/include/boost/geometry/algorithms/detail/multi_modify_with_predicate.hpp @@ -36,10 +36,7 @@ struct multi_modify_with_predicate { static inline void apply(MultiGeometry& multi, Predicate const& predicate) { - typedef typename boost::range_iterator::type iterator_type; - for (iterator_type it = boost::begin(multi); - it != boost::end(multi); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { Policy::apply(*it, predicate); } diff --git a/include/boost/geometry/algorithms/detail/multi_sum.hpp b/include/boost/geometry/algorithms/detail/multi_sum.hpp index d41a3689f..1c5ad6bf5 100644 --- a/include/boost/geometry/algorithms/detail/multi_sum.hpp +++ b/include/boost/geometry/algorithms/detail/multi_sum.hpp @@ -31,15 +31,10 @@ namespace detail struct multi_sum { template - static inline ReturnType apply(MultiGeometry const& geometry, Strategy const& strategy) + static inline ReturnType apply(MultiGeometry const& multi, Strategy const& strategy) { ReturnType sum = ReturnType(); - for (typename boost::range_iterator - < - MultiGeometry const - >::type it = boost::begin(geometry); - it != boost::end(geometry); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { sum += Policy::apply(*it, strategy); } diff --git a/include/boost/geometry/algorithms/detail/num_distinct_consecutive_points.hpp b/include/boost/geometry/algorithms/detail/num_distinct_consecutive_points.hpp index 5acc531d3..508e9b604 100644 --- a/include/boost/geometry/algorithms/detail/num_distinct_consecutive_points.hpp +++ b/include/boost/geometry/algorithms/detail/num_distinct_consecutive_points.hpp @@ -48,8 +48,6 @@ struct num_distinct_consecutive_points template static inline std::size_t apply(Range const& range, Strategy const& strategy) { - typedef typename boost::range_iterator::type iterator; - std::size_t const size = boost::size(range); if ( size < 2u ) @@ -57,13 +55,13 @@ struct num_distinct_consecutive_points return (size < MaximumNumber) ? size : MaximumNumber; } - iterator current = boost::begin(range); - iterator const end = boost::end(range); + auto current = boost::begin(range); + auto const end = boost::end(range); std::size_t counter(0); do { ++counter; - iterator next = std::find_if(current, end, [&](auto const& pt) { + auto next = std::find_if(current, end, [&](auto const& pt) { return ! equals::equals_point_point(pt, *current, strategy); }); current = next; diff --git a/include/boost/geometry/algorithms/detail/overlay/add_rings.hpp b/include/boost/geometry/algorithms/detail/overlay/add_rings.hpp index 45f2e7f12..026906b49 100644 --- a/include/boost/geometry/algorithms/detail/overlay/add_rings.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/add_rings.hpp @@ -96,8 +96,6 @@ inline OutputIterator add_rings(SelectionMap const& map, Strategy const& strategy, add_rings_error_handling error_handling = add_rings_ignore_unordered) { - typedef typename SelectionMap::const_iterator iterator; - std::size_t const min_num_points = core_detail::closure::minimum_ring_size < geometry::closure @@ -110,29 +108,23 @@ inline OutputIterator add_rings(SelectionMap const& map, >::value; - for (iterator it = boost::begin(map); - it != boost::end(map); - ++it) + for (auto const& pair : map) { - if (! it->second.discarded - && it->second.parent.source_index == -1) + if (! pair.second.discarded + && pair.second.parent.source_index == -1) { GeometryOut result; convert_and_add(result, geometry1, geometry2, collection, - it->first, it->second.reversed, false); + pair.first, pair.second.reversed, false); // Add children - for (typename std::vector::const_iterator child_it - = it->second.children.begin(); - child_it != it->second.children.end(); - ++child_it) + for (auto const& child : pair.second.children) { - iterator mit = map.find(*child_it); - if (mit != map.end() - && ! mit->second.discarded) + auto mit = map.find(child); + if (mit != map.end() && ! mit->second.discarded) { convert_and_add(result, geometry1, geometry2, collection, - *child_it, mit->second.reversed, true); + child, mit->second.reversed, true); } } diff --git a/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp b/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp index f304600c0..acc0f93ac 100644 --- a/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp @@ -174,7 +174,6 @@ inline void clean_closing_dups_and_spikes(Range& range, return; } - typedef typename boost::range_iterator::type iterator_type; static bool const closed = geometry::closure::value == geometry::closed; // TODO: the following algorithm could be rewritten to first look for spikes @@ -184,9 +183,9 @@ inline void clean_closing_dups_and_spikes(Range& range, do { found = false; - iterator_type first = boost::begin(range); - iterator_type second = first + 1; - iterator_type ultimate = boost::end(range) - 1; + auto first = boost::begin(range); + auto second = first + 1; + auto ultimate = boost::end(range) - 1; if (BOOST_GEOMETRY_CONDITION(closed)) { ultimate--; diff --git a/include/boost/geometry/algorithms/detail/overlay/assign_parents.hpp b/include/boost/geometry/algorithms/detail/overlay/assign_parents.hpp index 6b95fb227..70617cfbc 100644 --- a/include/boost/geometry/algorithms/detail/overlay/assign_parents.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/assign_parents.hpp @@ -26,6 +26,7 @@ #include #include +#include namespace boost { namespace geometry { @@ -260,38 +261,31 @@ inline void assign_parents(Geometry1 const& geometry1, point_type, Strategy // TODO: point_type is technically incorrect >::type area_result_type; - typedef typename RingMap::iterator map_iterator_type; - { - typedef ring_info_helper helper; - typedef std::vector vector_type; - typedef typename boost::range_iterator::type vector_iterator_type; - std::size_t count_total = ring_map.size(); std::size_t count_positive = 0; std::size_t index_positive = 0; // only used if count_positive>0 - std::size_t index = 0; - // Copy to vector (with new approach this might be obsolete as well, using the map directly) - vector_type vector(count_total); + // Copy to vector (this might be obsolete, using the map directly) + using helper = ring_info_helper; + std::vector vector(count_total); - for (map_iterator_type it = boost::begin(ring_map); - it != boost::end(ring_map); ++it, ++index) + for_each_with_index(ring_map, [&](std::size_t index, auto const& pair) { - vector[index] = helper(it->first, it->second.get_area()); + vector[index] = helper(pair.first, pair.second.get_area()); helper& item = vector[index]; - switch(it->first.source_index) + switch(pair.first.source_index) { case 0 : - geometry::envelope(get_ring::apply(it->first, geometry1), + geometry::envelope(get_ring::apply(pair.first, geometry1), item.envelope, strategy); break; case 1 : - geometry::envelope(get_ring::apply(it->first, geometry2), + geometry::envelope(get_ring::apply(pair.first, geometry2), item.envelope, strategy); break; case 2 : - geometry::envelope(get_ring::apply(it->first, collection), + geometry::envelope(get_ring::apply(pair.first, collection), item.envelope, strategy); break; } @@ -304,7 +298,7 @@ inline void assign_parents(Geometry1 const& geometry1, count_positive++; index_positive = index; } - } + }); if (! check_for_orientation) { @@ -325,17 +319,15 @@ inline void assign_parents(Geometry1 const& geometry1, // located outside the outer ring, this cannot be done ring_identifier id_of_positive = vector[index_positive].id; ring_info_type& outer = ring_map[id_of_positive]; - index = 0; - for (vector_iterator_type it = boost::begin(vector); - it != boost::end(vector); ++it, ++index) + for_each_with_index(vector, [&](std::size_t index, auto const& item) { if (index != index_positive) { - ring_info_type& inner = ring_map[it->id]; + ring_info_type& inner = ring_map[item.id]; inner.parent = id_of_positive; - outer.children.push_back(it->id); + outer.children.push_back(item.id); } - } + }); return; } } @@ -357,10 +349,9 @@ inline void assign_parents(Geometry1 const& geometry1, if (check_for_orientation) { - for (map_iterator_type it = boost::begin(ring_map); - it != boost::end(ring_map); ++it) + for (auto& pair : ring_map) { - ring_info_type& info = it->second; + ring_info_type& info = pair.second; if (geometry::math::equals(info.get_area(), 0)) { info.discarded = true; @@ -397,12 +388,11 @@ inline void assign_parents(Geometry1 const& geometry1, } // Assign childlist - for (map_iterator_type it = boost::begin(ring_map); - it != boost::end(ring_map); ++it) + for (auto& pair : ring_map) { - if (it->second.parent.source_index >= 0) + if (pair.second.parent.source_index >= 0) { - ring_map[it->second.parent].children.push_back(it->first); + ring_map[pair.second.parent].children.push_back(pair.first); } } } diff --git a/include/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp b/include/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp index 14be63a55..49d190bd0 100644 --- a/include/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp @@ -38,21 +38,11 @@ namespace detail { namespace overlay template inline void clear_visit_info(Turns& turns) { - typedef typename boost::range_value::type tp_type; - - for (typename boost::range_iterator::type - it = boost::begin(turns); - it != boost::end(turns); - ++it) + for (auto& turn : turns) { - for (typename boost::range_iterator - < - typename tp_type::container_type - >::type op_it = boost::begin(it->operations); - op_it != boost::end(it->operations); - ++op_it) + for (auto& op : turn.operations) { - op_it->visited.clear(); + op.visited.clear(); } } } diff --git a/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp b/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp index 843e120a1..ad3bd6bda 100644 --- a/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp @@ -127,37 +127,30 @@ inline bool check_graph(TurnPoints& turn_points, operation_type for_operation) typedef typename boost::range_value::type turn_point_type; bool error = false; - int index = 0; std::vector > meta_turns; - for (typename boost::range_iterator::type - it = boost::begin(turn_points); - it != boost::end(turn_points); - ++it, ++index) + for_each_with_index(turn_points, [&](std::size_t index, auto const& point) { - meta_turns.push_back(meta_turn(index, *it)); - } + meta_turns.push_back(meta_turn(index, point)); + }); int cycle = 0; - for (typename boost::range_iterator > > ::type - it = boost::begin(meta_turns); - it != boost::end(meta_turns); - ++it) + for (auto& meta_turn : meta_turns) { - if (! (it->turn->blocked() || it->turn->discarded)) + if (! (meta_turn.turn->blocked() || meta_turn.turn->discarded)) { for (int i = 0 ; i < 2; i++) { - if (! it->handled[i] - && it->turn->operations[i].operation == for_operation) + if (! meta_turn.handled[i] + && meta_turn.turn->operations[i].operation == for_operation) { #ifdef BOOST_GEOMETRY_DEBUG_ENRICH std::cout << "CYCLE " << cycle << std::endl; #endif - it->handled[i] = true; - check_detailed(meta_turns, *it, i, cycle++, it->index, for_operation, error); + meta_turn.handled[i] = true; + check_detailed(meta_turns, meta_turn, i, cycle++, meta_turn.index, for_operation, error); #ifdef BOOST_GEOMETRY_DEBUG_ENRICH - std::cout <<" END CYCLE " << it->index << std::endl; + std::cout <<" END CYCLE " << meta_turn.index << std::endl; #endif } } diff --git a/include/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp b/include/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp index f99140dcd..2eb70aa7d 100644 --- a/include/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp @@ -197,9 +197,8 @@ OutputIterator clip_range_with_box(Box const& b, Range const& range, OutputLinestring line_out; - typedef typename boost::range_iterator::type iterator_type; - iterator_type vertex = boost::begin(range); - for(iterator_type previous = vertex++; + auto vertex = boost::begin(range); + for (auto previous = vertex++; vertex != boost::end(range); ++previous, ++vertex) { diff --git a/include/boost/geometry/algorithms/detail/overlay/cluster_exits.hpp b/include/boost/geometry/algorithms/detail/overlay/cluster_exits.hpp index c4d01b1c1..6875493cf 100644 --- a/include/boost/geometry/algorithms/detail/overlay/cluster_exits.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/cluster_exits.hpp @@ -67,16 +67,11 @@ private : signed_size_type rank_index; }; - typedef typename std::vector::const_iterator const_it_type; - typedef typename std::vector::iterator it_type; - typedef typename std::set::const_iterator sit_type; - inline signed_size_type get_rank(Sbs const& sbs, linked_turn_op_info const& info) const { - for (std::size_t i = 0; i < sbs.m_ranked_points.size(); i++) + for (auto const& rp : sbs.m_ranked_points) { - typename Sbs::rp const& rp = sbs.m_ranked_points[i]; if (rp.turn_index == info.turn_index && rp.operation_index == info.op_index && rp.direction == sort_by_side::dir_to) @@ -95,9 +90,8 @@ private : bool collect(Turns const& turns) { - for (sit_type it = m_ids.begin(); it != m_ids.end(); ++it) + for (auto cluster_turn_index : m_ids) { - signed_size_type cluster_turn_index = *it; turn_type const& cluster_turn = turns[cluster_turn_index]; if (cluster_turn.discarded) { @@ -148,23 +142,19 @@ private : return true; } - for (it_type it = possibilities.begin(); it != possibilities.end(); ++it) + for (auto& info : possibilities) { - linked_turn_op_info& info = *it; info.rank_index = get_rank(sbs, info); } - for (it_type it = blocked.begin(); it != blocked.end(); ++it) + for (auto& info : blocked) { - linked_turn_op_info& info = *it; info.rank_index = get_rank(sbs, info); } - for (const_it_type it = possibilities.begin(); it != possibilities.end(); ++it) + for (auto const& lti : possibilities) { - linked_turn_op_info const& lti = *it; - for (const_it_type bit = blocked.begin(); bit != blocked.end(); ++bit) + for (auto const& blti : blocked) { - linked_turn_op_info const& blti = *bit; if (blti.next_turn_index == lti.next_turn_index && blti.rank_index == lti.rank_index) { @@ -198,10 +188,8 @@ public : // If there is one (and only one) possibility pointing outside // the cluster, take that one. linked_turn_op_info target; - for (const_it_type it = possibilities.begin(); - it != possibilities.end(); ++it) + for (auto const& lti : possibilities) { - linked_turn_op_info const& lti = *it; if (m_ids.count(lti.next_turn_index) == 0) { if (target.turn_index >= 0 diff --git a/include/boost/geometry/algorithms/detail/overlay/convert_ring.hpp b/include/boost/geometry/algorithms/detail/overlay/convert_ring.hpp index becaaafc3..c7c1cf703 100644 --- a/include/boost/geometry/algorithms/detail/overlay/convert_ring.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/convert_ring.hpp @@ -86,6 +86,7 @@ struct convert_ring if (geometry::num_points(source) >= min_num_points) { + // TODO: resize and .size() and .back() should not be called here interior_rings(destination).resize( interior_rings(destination).size() + 1); geometry::convert(source, interior_rings(destination).back()); diff --git a/include/boost/geometry/algorithms/detail/overlay/copy_segments.hpp b/include/boost/geometry/algorithms/detail/overlay/copy_segments.hpp index 8af9ea4c1..6be8f2163 100644 --- a/include/boost/geometry/algorithms/detail/overlay/copy_segments.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/copy_segments.hpp @@ -167,10 +167,7 @@ public: } signed_size_type const count = to_index - from_index + 1; - - typename boost::range_iterator::type - it = boost::begin(ls) + from_index; - + auto it = boost::begin(ls) + from_index; for (signed_size_type i = 0; i < count; ++i, ++it) { append_to_output(current_output, *it, strategy, robust_policy, diff --git a/include/boost/geometry/algorithms/detail/overlay/follow.hpp b/include/boost/geometry/algorithms/detail/overlay/follow.hpp index be4271c3d..d94560541 100644 --- a/include/boost/geometry/algorithms/detail/overlay/follow.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/follow.hpp @@ -422,13 +422,6 @@ public : OutputIterator out, Strategy const& strategy) { - typedef typename boost::range_iterator::type turn_iterator; - typedef typename boost::range_value::type turn_type; - typedef typename boost::range_iterator - < - typename turn_type::container_type - >::type turn_operation_iterator_type; - typedef following::action_selector action; // Sort intersection points on segments-along-linestring, and distance @@ -448,51 +441,51 @@ public : // Iterate through all intersection points (they are ordered along the line) bool entered = false; bool first = true; - for (turn_iterator it = boost::begin(turns); it != boost::end(turns); ++it) + for (auto const& turn : turns) { - turn_operation_iterator_type iit = boost::begin(it->operations); + auto const& op = turn.operations[0]; - if (following::was_entered(*it, *iit, first, linestring, polygon, strategy)) + if (following::was_entered(turn, op, first, linestring, polygon, strategy)) { - debug_traverse(*it, *iit, "-> Was entered"); + debug_traverse(turn, op, "-> Was entered"); entered = true; } - if (following::is_staying_inside(*it, *iit, entered, first, linestring, polygon, strategy)) + if (following::is_staying_inside(turn, op, entered, first, linestring, polygon, strategy)) { - debug_traverse(*it, *iit, "-> Staying inside"); + debug_traverse(turn, op, "-> Staying inside"); entered = true; } - else if (following::is_entering(*it, *iit)) + else if (following::is_entering(turn, op)) { - debug_traverse(*it, *iit, "-> Entering"); + debug_traverse(turn, op, "-> Entering"); entered = true; action::enter(current_piece, linestring, current_segment_id, - iit->seg_id.segment_index, it->point, *iit, + op.seg_id.segment_index, turn.point, op, strategy, robust_policy, linear::get(out)); } - else if (following::is_leaving(*it, *iit, entered, first, linestring, polygon, strategy)) + else if (following::is_leaving(turn, op, entered, first, linestring, polygon, strategy)) { - debug_traverse(*it, *iit, "-> Leaving"); + debug_traverse(turn, op, "-> Leaving"); entered = false; action::leave(current_piece, linestring, current_segment_id, - iit->seg_id.segment_index, it->point, *iit, + op.seg_id.segment_index, turn.point, op, strategy, robust_policy, linear::get(out)); } else if (BOOST_GEOMETRY_CONDITION(FollowIsolatedPoints) - && following::is_touching(*it, *iit, entered)) + && following::is_touching(turn, op, entered)) { - debug_traverse(*it, *iit, "-> Isolated point"); + debug_traverse(turn, op, "-> Isolated point"); action::template isolated_point < typename pointlike::type - >(it->point, pointlike::get(out)); + >(turn.point, pointlike::get(out)); } first = false; diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp index cade8bbef..7b0d1c9ab 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -842,10 +841,8 @@ struct get_turns_polygon_cs signed_size_type i = 0; - typename interior_return_type::type - rings = interior_rings(polygon); - for (typename detail::interior_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it, ++i) + auto const& rings = interior_rings(polygon); + for (auto it = boost::begin(rings); it != boost::end(rings); ++it, ++i) { intersector_type::apply( source_id1, *it, @@ -877,15 +874,8 @@ struct get_turns_multi_polygon_cs Turns& turns, InterruptPolicy& interrupt_policy) { - typedef typename boost::range_iterator - < - Multi const - >::type iterator_type; - signed_size_type i = 0; - for (iterator_type it = boost::begin(multi); - it != boost::end(multi); - ++it, ++i) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it, ++i) { // Call its single version get_turns_polygon_cs diff --git a/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp b/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp index ac64c22cf..aaabb4a4d 100644 --- a/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp @@ -82,8 +82,8 @@ inline void cleanup_clusters(Turns& turns, Clusters& clusters) for (auto& pair : clusters) { auto& cinfo = pair.second; - auto& ids = cinfo.turn_indices; - for (auto sit = ids.begin(); sit != ids.end(); /* no increment */) + auto& indices = cinfo.turn_indices; + for (auto sit = indices.begin(); sit != indices.end(); /* no increment */) { auto current_it = sit; ++sit; @@ -91,7 +91,7 @@ inline void cleanup_clusters(Turns& turns, Clusters& clusters) auto const turn_index = *current_it; if (turns[turn_index].discarded) { - ids.erase(current_it); + indices.erase(current_it); } } } @@ -100,14 +100,14 @@ inline void cleanup_clusters(Turns& turns, Clusters& clusters) colocate_clusters(clusters, turns); } -template -inline void discard_colocated_turn(Turn& turn, IdSet& ids, signed_size_type id) +template +inline void discard_colocated_turn(Turn& turn, IndexSet& indices, signed_size_type index) { turn.discarded = true; // Set cluster id to -1, but don't clear colocated flags turn.cluster_id = -1; // To remove it later from clusters - ids.insert(id); + indices.insert(index); } template @@ -167,22 +167,17 @@ template > inline void discard_interior_exterior_turns(Turns& turns, Clusters& clusters) { - typedef std::set::const_iterator set_iterator; - typedef typename boost::range_value::type turn_type; + std::set indices_to_remove; - std::set ids_to_remove; - - for (typename Clusters::iterator cit = clusters.begin(); - cit != clusters.end(); ++cit) + for (auto& pair : clusters) { - cluster_info& cinfo = cit->second; - std::set& ids = cinfo.turn_indices; + cluster_info& cinfo = pair.second; - ids_to_remove.clear(); + indices_to_remove.clear(); - for (set_iterator it = ids.begin(); it != ids.end(); ++it) + for (auto index : cinfo.turn_indices) { - turn_type& turn = turns[*it]; + auto& turn = turns[index]; segment_identifier const& seg_0 = turn.operations[0].seg_id; segment_identifier const& seg_1 = turn.operations[1].seg_id; @@ -193,34 +188,33 @@ inline void discard_interior_exterior_turns(Turns& turns, Clusters& clusters) continue; } - for (set_iterator int_it = ids.begin(); int_it != ids.end(); ++int_it) + for (auto interior_index : cinfo.turn_indices) { - if (*it == *int_it) + if (index == interior_index) { continue; } // Turn with, possibly, an interior ring involved - turn_type& int_turn = turns[*int_it]; - segment_identifier const& int_seg_0 = int_turn.operations[0].seg_id; - segment_identifier const& int_seg_1 = int_turn.operations[1].seg_id; + auto& interior_turn = turns[interior_index]; + segment_identifier const& int_seg_0 = interior_turn.operations[0].seg_id; + segment_identifier const& int_seg_1 = interior_turn.operations[1].seg_id; if (is_ie_turn(seg_0, seg_1, int_seg_0, int_seg_1)) { - discard_colocated_turn(int_turn, ids_to_remove, *int_it); + discard_colocated_turn(interior_turn, indices_to_remove, interior_index); } if (is_ie_turn(seg_1, seg_0, int_seg_1, int_seg_0)) { - discard_colocated_turn(int_turn, ids_to_remove, *int_it); + discard_colocated_turn(interior_turn, indices_to_remove, interior_index); } } } - // Erase from the ids (which cannot be done above) - for (set_iterator sit = ids_to_remove.begin(); - sit != ids_to_remove.end(); ++sit) + // Erase from the indices (which cannot be done above) + for (auto index : indices_to_remove) { - ids.erase(*sit); + cinfo.turn_indices.erase(index); } } } @@ -233,19 +227,14 @@ template > inline void set_colocation(Turns& turns, Clusters const& clusters) { - typedef std::set::const_iterator set_iterator; - typedef typename boost::range_value::type turn_type; - - for (typename Clusters::const_iterator cit = clusters.begin(); - cit != clusters.end(); ++cit) + for (auto const& pair : clusters) { - cluster_info const& cinfo = cit->second; - std::set const& ids = cinfo.turn_indices; + cluster_info const& cinfo = pair.second; bool both_target = false; - for (set_iterator it = ids.begin(); it != ids.end(); ++it) + for (auto index : cinfo.turn_indices) { - turn_type const& turn = turns[*it]; + auto const& turn = turns[index]; if (turn.both(operation_from_overlay::value)) { both_target = true; @@ -255,9 +244,9 @@ inline void set_colocation(Turns& turns, Clusters const& clusters) if (both_target) { - for (set_iterator it = ids.begin(); it != ids.end(); ++it) + for (auto index : cinfo.turn_indices) { - turn_type& turn = turns[*it]; + auto& turn = turns[index]; turn.has_colocated_both = true; } } @@ -276,7 +265,7 @@ inline void check_colocation(bool& has_blocked, has_blocked = false; - typename Clusters::const_iterator mit = clusters.find(cluster_id); + auto mit = clusters.find(cluster_id); if (mit == clusters.end()) { return; @@ -284,11 +273,9 @@ inline void check_colocation(bool& has_blocked, cluster_info const& cinfo = mit->second; - for (std::set::const_iterator it - = cinfo.turn_indices.begin(); - it != cinfo.turn_indices.end(); ++it) + for (auto index : cinfo.turn_indices) { - turn_type const& turn = turns[*it]; + turn_type const& turn = turns[index]; if (turn.any_blocked()) { has_blocked = true; @@ -410,21 +397,15 @@ inline bool fill_sbs(Sbs& sbs, Point& turn_point, Turns const& turns, Geometry1 const& geometry1, Geometry2 const& geometry2) { - typedef typename boost::range_value::type turn_type; - - std::set const& ids = cinfo.turn_indices; - - if (ids.empty()) + if (cinfo.turn_indices.empty()) { return false; } bool first = true; - for (std::set::const_iterator sit = ids.begin(); - sit != ids.end(); ++sit) + for (auto turn_index : cinfo.turn_indices) { - signed_size_type turn_index = *sit; - turn_type const& turn = turns[turn_index]; + auto const& turn = turns[turn_index]; if (first) { turn_point = turn.point; @@ -464,10 +445,9 @@ inline void gather_cluster_properties(Clusters& clusters, Turns& turns, Reverse1, Reverse2, OverlayType, point_type, SideStrategy, std::less > sbs_type; - for (typename Clusters::iterator mit = clusters.begin(); - mit != clusters.end(); ++mit) + for (auto& pair : clusters) { - cluster_info& cinfo = mit->second; + cluster_info& cinfo = pair.second; sbs_type sbs(strategy); point_type turn_point; // should be all the same for all turns in cluster diff --git a/include/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp b/include/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp index 729f052bb..3ee49dec8 100644 --- a/include/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp @@ -106,15 +106,8 @@ struct discard_closed_turns Geometry0 const& geometry0, Geometry1 const& geometry1, Strategy const& strategy) { - typedef typename boost::range_value::type turn_type; - - for (typename boost::range_iterator::type - it = boost::begin(turns); - it != boost::end(turns); - ++it) + for (auto& turn : turns) { - turn_type& turn = *it; - if (! turn.discarded && is_self_turn(turn) && check_within::apply(turn, geometry0, @@ -137,18 +130,16 @@ private : bool is_self_cluster(signed_size_type cluster_id, const Turns& turns, Clusters const& clusters) { - typename Clusters::const_iterator cit = clusters.find(cluster_id); + auto cit = clusters.find(cluster_id); if (cit == clusters.end()) { return false; } cluster_info const& cinfo = cit->second; - for (std::set::const_iterator it - = cinfo.turn_indices.begin(); - it != cinfo.turn_indices.end(); ++it) + for (auto index : cinfo.turn_indices) { - if (! is_self_turn(turns[*it])) + if (! is_self_turn(turns[index])) { return false; } @@ -164,28 +155,25 @@ private : Geometry0 const& geometry0, Geometry1 const& geometry1, Strategy const& strategy) { - for (typename Clusters::const_iterator cit = clusters.begin(); - cit != clusters.end(); ++cit) + for (auto const& pair : clusters) { - signed_size_type const cluster_id = cit->first; + signed_size_type const cluster_id = pair.first; + cluster_info const& cinfo = pair.second; // If there are only self-turns in the cluster, the cluster should // be located within the other geometry, for intersection - if (! cit->second.turn_indices.empty() + if (! cinfo.turn_indices.empty() && is_self_cluster(cluster_id, turns, clusters)) { - cluster_info const& cinfo = cit->second; signed_size_type const index = *cinfo.turn_indices.begin(); if (! check_within::apply(turns[index], geometry0, geometry1, strategy)) { // Discard all turns in cluster - for (std::set::const_iterator sit - = cinfo.turn_indices.begin(); - sit != cinfo.turn_indices.end(); ++sit) + for (auto index : cinfo.turn_indices) { - turns[*sit].discarded = true; + turns[index].discarded = true; } } } @@ -203,15 +191,8 @@ public : { discard_clusters(turns, clusters, geometry0, geometry1, strategy); - typedef typename boost::range_value::type turn_type; - - for (typename boost::range_iterator::type - it = boost::begin(turns); - it != boost::end(turns); - ++it) + for (auto& turn : turns) { - turn_type& turn = *it; - // It is a ii self-turn // Check if it is within the other geometry if (! turn.discarded diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp index 635b4a538..1ddeca478 100644 --- a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp @@ -59,6 +59,7 @@ #if defined(BOOST_GEOMETRY_DEBUG_FOLLOW) #include #include +#include #endif namespace boost { namespace geometry @@ -145,11 +146,10 @@ struct intersection_linestring_linestring_point geometry::get_intersection_points(linestring1, linestring2, robust_policy, turns, strategy); - for (typename boost::range_iterator const>::type - it = boost::begin(turns); it != boost::end(turns); ++it) + for (auto const& turn : turns) { PointOut p; - geometry::convert(it->point, p); + geometry::convert(turn.point, p); *out++ = p; } return out; @@ -212,11 +212,10 @@ struct intersection_of_linestring_with_areal bool found_union = false; bool found_front = false; - for (typename Turns::const_iterator it = turns.begin(); - it != turns.end(); ++it) + for (auto const& turn : turns) { - method_type const method = it->method; - operation_type const op = it->operations[0].operation; + method_type const method = turn.method; + operation_type const op = turn.operations[0].operation; if (method == method_crosses) { @@ -240,7 +239,7 @@ struct intersection_of_linestring_with_areal return false; } - if (it->operations[0].position == position_front) + if (turn.operations[0].position == position_front) { found_front = true; } @@ -380,12 +379,10 @@ struct intersection_of_linestring_with_areal } #if defined(BOOST_GEOMETRY_DEBUG_FOLLOW) - int index = 0; - for(typename std::deque::const_iterator - it = turns.begin(); it != turns.end(); ++it) + for_each_with_index(turns, [](auto index, auto const& turn) { - debug_follow(*it, it->operations[0], index++); - } + debug_follow(turn, turn.operations[0], index); + }); #endif return follower::apply @@ -402,10 +399,9 @@ template inline OutputIterator intersection_output_turn_points(Turns const& turns, OutputIterator out) { - for (typename Turns::const_iterator - it = turns.begin(); it != turns.end(); ++it) + for (auto const& turn : turns) { - *out++ = it->point; + *out++ = turn.point; } return out; diff --git a/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp index 10aa72dbb..f67a06b0b 100644 --- a/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp @@ -82,9 +82,7 @@ struct linear_linear_no_intersections static inline OutputIterator apply(MultiLineString const& multilinestring, OutputIterator oit) { - for (typename boost::range_iterator::type - it = boost::begin(multilinestring); - it != boost::end(multilinestring); ++it) + for (auto it = boost::begin(multilinestring); it != boost::end(multilinestring); ++it) { LineStringOut ls_out; geometry::convert(*it, ls_out); diff --git a/include/boost/geometry/algorithms/detail/overlay/overlay.hpp b/include/boost/geometry/algorithms/detail/overlay/overlay.hpp index 3d27087a7..e0451f9dd 100644 --- a/include/boost/geometry/algorithms/detail/overlay/overlay.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/overlay.hpp @@ -103,10 +103,6 @@ template > inline void get_ring_turn_info(TurnInfoMap& turn_info_map, Turns const& turns, Clusters const& clusters) { - typedef typename boost::range_value::type turn_type; - typedef typename turn_type::turn_operation_type turn_operation_type; - typedef typename turn_type::container_type container_type; - static const operation_type target_operation = operation_from_overlay::value; static const operation_type opposite_operation @@ -114,13 +110,8 @@ inline void get_ring_turn_info(TurnInfoMap& turn_info_map, Turns const& turns, C ? operation_intersection : operation_union; - for (typename boost::range_iterator::type - it = boost::begin(turns); - it != boost::end(turns); - ++it) + for (auto const& turn : turns) { - turn_type const& turn = *it; - bool cluster_checked = false; bool has_blocked = false; @@ -130,12 +121,8 @@ inline void get_ring_turn_info(TurnInfoMap& turn_info_map, Turns const& turns, C continue; } - for (typename boost::range_iterator::type - op_it = boost::begin(turn.operations); - op_it != boost::end(turn.operations); - ++op_it) + for (auto const& op : turn.operations) { - turn_operation_type const& op = *op_it; ring_identifier const ring_id = ring_id_by_seg_id(op.seg_id); if (! is_self_turn(turn) diff --git a/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp index bbf62b363..19045b250 100644 --- a/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp @@ -98,10 +98,7 @@ struct multipoint_single_point OutputIterator oit, Strategy const& strategy) { - for (typename boost::range_iterator::type - it = boost::begin(multipoint); - it != boost::end(multipoint); - ++it) + for (auto it = boost::begin(multipoint); it != boost::end(multipoint); ++it) { action_selector_pl < diff --git a/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp b/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp index a46fc8b5f..e59f8011e 100644 --- a/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp @@ -75,9 +75,7 @@ struct copy_points static inline void apply(MultiPointIn const& multi_point_in, OutputIterator& oit) { - for (typename boost::range_iterator::type - it = boost::begin(multi_point_in); - it != boost::end(multi_point_in); ++it) + for (auto it = boost::begin(multi_point_in); it != boost::end(multi_point_in); ++it) { PointOut point_out; geometry::convert(*it, point_out); @@ -189,9 +187,7 @@ struct multipoint_point_point { BOOST_GEOMETRY_ASSERT( OverlayType == overlay_difference ); - for (typename boost::range_iterator::type - it = boost::begin(multipoint); - it != boost::end(multipoint); ++it) + for (auto it = boost::begin(multipoint); it != boost::end(multipoint); ++it) { action_selector_pl < @@ -225,9 +221,7 @@ struct point_multipoint_point { typedef action_selector_pl action; - for (typename boost::range_iterator::type - it = boost::begin(multipoint); - it != boost::end(multipoint); ++it) + for (auto it = boost::begin(multipoint); it != boost::end(multipoint); ++it) { if ( detail::equals::equals_point_point(*it, point, strategy) ) { @@ -279,9 +273,7 @@ struct multipoint_multipoint_point less_type const less = less_type(); std::sort(points2.begin(), points2.end(), less); - for (typename boost::range_iterator::type - it1 = boost::begin(multipoint1); - it1 != boost::end(multipoint1); ++it1) + for (auto it1 = boost::begin(multipoint1); it1 != boost::end(multipoint1); ++it1) { bool found = std::binary_search(points2.begin(), points2.end(), *it1, less); diff --git a/include/boost/geometry/algorithms/detail/overlay/select_rings.hpp b/include/boost/geometry/algorithms/detail/overlay/select_rings.hpp index 709c4f8ed..9250038dc 100644 --- a/include/boost/geometry/algorithms/detail/overlay/select_rings.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/select_rings.hpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -119,10 +118,8 @@ namespace dispatch per_ring::apply(exterior_ring(polygon), geometry, id, ring_properties, strategy); - typename interior_return_type::type - rings = interior_rings(polygon); - for (typename detail::interior_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it) + auto const& rings = interior_rings(polygon); + for (auto it = boost::begin(rings); it != boost::end(rings); ++it) { id.ring_index++; per_ring::apply(*it, geometry, id, ring_properties, strategy); @@ -139,10 +136,8 @@ namespace dispatch per_ring::apply(exterior_ring(polygon), id, ring_properties, strategy); - typename interior_return_type::type - rings = interior_rings(polygon); - for (typename detail::interior_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it) + auto const& rings = interior_rings(polygon); + for (auto it = boost::begin(rings); it != boost::end(rings); ++it) { id.ring_index++; per_ring::apply(*it, id, ring_properties, strategy); @@ -158,15 +153,10 @@ namespace dispatch ring_identifier id, RingPropertyMap& ring_properties, Strategy const& strategy) { - typedef typename boost::range_iterator - < - Multi const - >::type iterator_type; - typedef select_rings::type> per_polygon; id.multi_index = 0; - for (iterator_type it = boost::begin(multi); it != boost::end(multi); ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { id.ring_index = -1; per_polygon::apply(*it, geometry, id, ring_properties, strategy); @@ -254,15 +244,13 @@ inline void update_ring_selection(Geometry1 const& geometry1, { selected_ring_properties.clear(); - for (typename RingPropertyMap::const_iterator it = boost::begin(all_ring_properties); - it != boost::end(all_ring_properties); - ++it) + for (auto const& pair : all_ring_properties) { - ring_identifier const& id = it->first; + ring_identifier const& id = pair.first; ring_turn_info info; - typename TurnInfoMap::const_iterator tcit = turn_info_map.find(id); + auto tcit = turn_info_map.find(id); if (tcit != turn_info_map.end()) { info = tcit->second; // Copy by value @@ -281,12 +269,12 @@ inline void update_ring_selection(Geometry1 const& geometry1, { // within case 0 : - info.within_other = range_in_geometry(it->second.point, + info.within_other = range_in_geometry(pair.second.point, geometry1, geometry2, strategy) > 0; break; case 1 : - info.within_other = range_in_geometry(it->second.point, + info.within_other = range_in_geometry(pair.second.point, geometry2, geometry1, strategy) > 0; break; @@ -294,7 +282,7 @@ inline void update_ring_selection(Geometry1 const& geometry1, if (decide::include(id, info)) { - typename RingPropertyMap::mapped_type properties = it->second; // Copy by value + auto properties = pair.second; // Copy by value properties.reversed = decide::reversed(id, info); selected_ring_properties[id] = properties; } diff --git a/include/boost/geometry/algorithms/detail/overlay/sort_by_side.hpp b/include/boost/geometry/algorithms/detail/overlay/sort_by_side.hpp index 9656285ab..789783207 100644 --- a/include/boost/geometry/algorithms/detail/overlay/sort_by_side.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/sort_by_side.hpp @@ -475,7 +475,7 @@ public : // Move iterator after rank==0 bool has_first = false; - typename container_type::iterator it = m_ranked_points.begin() + 1; + auto it = m_ranked_points.begin() + 1; for (; it != m_ranked_points.end() && it->rank == 0; ++it) { has_first = true; @@ -486,8 +486,7 @@ public : // Reverse first part (having rank == 0), if any, // but skip the very first row std::reverse(m_ranked_points.begin() + 1, it); - for (typename container_type::iterator fit = m_ranked_points.begin(); - fit != it; ++fit) + for (auto fit = m_ranked_points.begin(); fit != it; ++fit) { BOOST_ASSERT(fit->rank == 0); } diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp index 1e1dd6739..22ae1a2de 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp @@ -123,12 +123,8 @@ public : template inline void finalize_visit_info(TurnInfoMap& turn_info_map) { - for (typename boost::range_iterator::type - it = boost::begin(m_turns); - it != boost::end(m_turns); - ++it) + for (auto& turn : m_turns) { - turn_type& turn = *it; for (int i = 0; i < 2; i++) { turn_operation_type& op = turn.operations[i]; @@ -158,23 +154,18 @@ public : inline void set_visited_in_cluster(signed_size_type cluster_id, signed_size_type rank) { - typename Clusters::const_iterator mit = m_clusters.find(cluster_id); + auto mit = m_clusters.find(cluster_id); BOOST_ASSERT(mit != m_clusters.end()); cluster_info const& cinfo = mit->second; - std::set const& ids = cinfo.turn_indices; - for (typename std::set::const_iterator it = ids.begin(); - it != ids.end(); ++it) + for (auto turn_index : cinfo.turn_indices) { - signed_size_type const turn_index = *it; turn_type& turn = m_turns[turn_index]; - for (int i = 0; i < 2; i++) + for (auto& op : turn.operations) { - turn_operation_type& op = turn.operations[i]; - if (op.visited.none() - && op.enriched.rank == rank) + if (op.visited.none() && op.enriched.rank == rank) { op.visited.set_visited(); } @@ -789,21 +780,19 @@ public : turn_type const& turn = m_turns[turn_index]; BOOST_ASSERT(turn.is_clustered()); - typename Clusters::const_iterator mit = m_clusters.find(turn.cluster_id); + auto mit = m_clusters.find(turn.cluster_id); BOOST_ASSERT(mit != m_clusters.end()); cluster_info const& cinfo = mit->second; - std::set const& cluster_indices = cinfo.turn_indices; sbs_type sbs(m_strategy); - - if (! fill_sbs(sbs, turn_index, cluster_indices, previous_seg_id)) + if (! fill_sbs(sbs, turn_index, cinfo.turn_indices, previous_seg_id)) { return false; } - cluster_exits exits(m_turns, cluster_indices, sbs); + cluster_exits exits(m_turns, cinfo.turn_indices, sbs); if (exits.apply(turn_index, op_index)) { @@ -814,7 +803,7 @@ public : if (is_union) { - result = select_from_cluster_union(turn_index, cluster_indices, + result = select_from_cluster_union(turn_index, cinfo.turn_indices, op_index, sbs, start_turn_index, start_op_index); if (! result) diff --git a/include/boost/geometry/algorithms/detail/overlay/traverse.hpp b/include/boost/geometry/algorithms/detail/overlay/traverse.hpp index b9cbea312..710cea09e 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traverse.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traverse.hpp @@ -42,14 +42,11 @@ class traverse template static void reset_visits(Turns& turns) { - for (typename boost::range_iterator::type - it = boost::begin(turns); - it != boost::end(turns); - ++it) + for (auto& turn : turns) { - for (int i = 0; i < 2; i++) + for (auto& op : turn.operations) { - it->operations[i].visited.reset(); + op.visited.reset(); } } } diff --git a/include/boost/geometry/algorithms/detail/partition.hpp b/include/boost/geometry/algorithms/detail/partition.hpp index 2a47eb2b6..664925517 100644 --- a/include/boost/geometry/algorithms/detail/partition.hpp +++ b/include/boost/geometry/algorithms/detail/partition.hpp @@ -85,12 +85,7 @@ inline void divide_into_subsets(Box const& lower_box, IteratorVector& exceeding, OverlapsPolicy const& overlaps_policy) { - typedef typename boost::range_iterator - < - IteratorVector const - >::type it_type; - - for(it_type it = boost::begin(input); it != boost::end(input); ++it) + for (auto it = boost::begin(input); it != boost::end(input); ++it) { bool const lower_overlapping = overlaps_policy.apply(lower_box, **it); bool const upper_overlapping = overlaps_policy.apply(upper_box, **it); @@ -124,10 +119,9 @@ template inline void expand_with_elements(Box& total, IteratorVector const& input, ExpandPolicy const& expand_policy) { - typedef typename boost::range_iterator::type it_type; - for(it_type it = boost::begin(input); it != boost::end(input); ++it) + for (auto const& it : input) { - expand_policy.apply(total, **it); + expand_policy.apply(total, *it); } } @@ -141,12 +135,10 @@ inline bool handle_one(IteratorVector const& input, VisitPolicy& visitor) return true; } - typedef typename boost::range_iterator::type it_type; - // Quadratic behaviour at lowest level (lowest quad, or all exceeding) - for (it_type it1 = boost::begin(input); it1 != boost::end(input); ++it1) + for (auto it1 = boost::begin(input); it1 != boost::end(input); ++it1) { - it_type it2 = it1; + auto it2 = it1; for (++it2; it2 != boost::end(input); ++it2) { if (! visitor.apply(**it1, **it2)) @@ -170,30 +162,17 @@ inline bool handle_two(IteratorVector1 const& input1, IteratorVector2 const& input2, VisitPolicy& visitor) { - typedef typename boost::range_iterator - < - IteratorVector1 const - >::type iterator_type1; - - typedef typename boost::range_iterator - < - IteratorVector2 const - >::type iterator_type2; if (boost::empty(input1) || boost::empty(input2)) { return true; } - for(iterator_type1 it1 = boost::begin(input1); - it1 != boost::end(input1); - ++it1) + for (auto const& it1 : input1) { - for(iterator_type2 it2 = boost::begin(input2); - it2 != boost::end(input2); - ++it2) + for (auto const& it2 : input2) { - if (! visitor.apply(**it1, **it2)) + if (! visitor.apply(*it1, *it2)) { return false; // interrupt } @@ -629,10 +608,7 @@ class partition IteratorVector& iterator_vector, ExpandPolicy const& expand_policy) { - for(typename boost::range_iterator::type - it = boost::begin(forward_range); - it != boost::end(forward_range); - ++it) + for (auto it = boost::begin(forward_range); it != boost::end(forward_range); ++it) { if (IncludePolicy::apply(*it)) { @@ -712,11 +688,11 @@ public: } else { - for(iterator_type it1 = boost::begin(forward_range); + for(auto it1 = boost::begin(forward_range); it1 != boost::end(forward_range); ++it1) { - iterator_type it2 = it1; + auto it2 = it1; for(++it2; it2 != boost::end(forward_range); ++it2) { if (! visitor.apply(*it1, *it2)) @@ -849,11 +825,11 @@ public: } else { - for(iterator_type1 it1 = boost::begin(forward_range1); + for (auto it1 = boost::begin(forward_range1); it1 != boost::end(forward_range1); ++it1) { - for(iterator_type2 it2 = boost::begin(forward_range2); + for (auto it2 = boost::begin(forward_range2); it2 != boost::end(forward_range2); ++it2) { diff --git a/include/boost/geometry/algorithms/detail/point_on_border.hpp b/include/boost/geometry/algorithms/detail/point_on_border.hpp index aa77a0a65..8b3a20a16 100644 --- a/include/boost/geometry/algorithms/detail/point_on_border.hpp +++ b/include/boost/geometry/algorithms/detail/point_on_border.hpp @@ -110,12 +110,7 @@ struct point_on_multi { // Take a point on the first multi-geometry // (i.e. the first that is not empty) - for (typename boost::range_iterator - < - MultiGeometry const - >::type it = boost::begin(multi); - it != boost::end(multi); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { if (Policy::apply(point, *it)) { diff --git a/include/boost/geometry/algorithms/detail/recalculate.hpp b/include/boost/geometry/algorithms/detail/recalculate.hpp index 688d49237..eb633c9c2 100644 --- a/include/boost/geometry/algorithms/detail/recalculate.hpp +++ b/include/boost/geometry/algorithms/detail/recalculate.hpp @@ -106,13 +106,10 @@ struct range_to_range typedef recalculate_point::value> per_point; geometry::clear(destination); - for (typename boost::range_iterator::type it - = boost::begin(source); - it != boost::end(source); - ++it) + for (auto const& source_point : source) { point_type p; - per_point::apply(p, *it, strategy); + per_point::apply(p, source_point, strategy); geometry::append(destination, p); } } diff --git a/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp b/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp index 9a811d9b6..cb1f0f40c 100644 --- a/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp +++ b/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp @@ -256,11 +256,10 @@ public: segment_identifier const& other_id = turn.operations[other_op_id].seg_id; overlay::operation_type exit_op = turn.operations[op_id].operation; - typedef typename std::vector::iterator point_iterator; // search for the entry point in the same range of other geometry - point_iterator entry_it = std::find_if(m_other_entry_points.begin(), - m_other_entry_points.end(), - same_single(other_id)); + auto entry_it = std::find_if(m_other_entry_points.begin(), + m_other_entry_points.end(), + same_single(other_id)); // this end point has corresponding entry point if ( entry_it != m_other_entry_points.end() ) diff --git a/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp b/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp index f4b41e085..4cf014f31 100644 --- a/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp +++ b/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp @@ -277,7 +277,6 @@ inline bool calculate_from_inside(Geometry1 const& geometry1, auto const& range1 = sub_range(geometry1, turn.operations[op_id].seg_id); using range2_view = detail::closed_clockwise_view::type const>; - using range2_iterator = typename boost::range_iterator::type; range2_view const range2(sub_range(geometry2, turn.operations[other_op_id].seg_id)); BOOST_GEOMETRY_ASSERT(boost::size(range1)); @@ -305,10 +304,10 @@ inline bool calculate_from_inside(Geometry1 const& geometry1, std::size_t const q_seg_jk = (q_seg_ij + 1) % seg_count2; // TODO: the following function should return immediately, however the worst case complexity is O(N) // It would be good to replace it with some O(1) mechanism - range2_iterator qk_it = find_next_non_duplicated(boost::begin(range2), - range::pos(range2, q_seg_jk), - boost::end(range2), - strategy); + auto qk_it = find_next_non_duplicated(boost::begin(range2), + range::pos(range2, q_seg_jk), + boost::end(range2), + strategy); // Calculate sides in a different point order for P and Q // Will this sequence of points be always correct? diff --git a/include/boost/geometry/algorithms/detail/relate/multi_point_geometry.hpp b/include/boost/geometry/algorithms/detail/relate/multi_point_geometry.hpp index 281ad2384..b4ded12fc 100644 --- a/include/boost/geometry/algorithms/detail/relate/multi_point_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/relate/multi_point_geometry.hpp @@ -188,8 +188,7 @@ struct multi_point_single_geometry geometry::envelope(single_geometry, box2, strategy); geometry::detail::expand_by_epsilon(box2); - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(multi_point) ; it != boost::end(multi_point) ; ++it ) + for (auto it = boost::begin(multi_point); it != boost::end(multi_point); ++it) { if (! (relate::may_update(result) || relate::may_update(result) @@ -445,7 +444,6 @@ struct multi_point_multi_geometry_ii_ib_ie typedef model::box box2_type; typedef std::pair box_pair_type; typedef std::vector boxes_type; - typedef typename boxes_type::const_iterator boxes_iterator; template static inline void apply(MultiPoint const& multi_point, @@ -466,8 +464,7 @@ struct multi_point_multi_geometry_ii_ib_ie rtree(boxes.begin(), boxes.end(), index_parameters_type(index::rstar<4>(), strategy)); - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(multi_point) ; it != boost::end(multi_point) ; ++it ) + for (auto it = boost::begin(multi_point); it != boost::end(multi_point); ++it) { if (! (relate::may_update(result) || relate::may_update(result) @@ -482,10 +479,10 @@ struct multi_point_multi_geometry_ii_ib_ie rtree.query(index::intersects(point), std::back_inserter(boxes_found)); bool found_ii_or_ib = false; - for (boxes_iterator bi = boxes_found.begin() ; bi != boxes_found.end() ; ++bi) + for (auto const& box_found : boxes_found) { typename boost::range_value::type const& - single = range::at(multi_geometry, bi->second); + single = range::at(multi_geometry, box_found.second); int in_val = detail::within::point_in_geometry(point, single, strategy); diff --git a/include/boost/geometry/algorithms/detail/relate/point_point.hpp b/include/boost/geometry/algorithms/detail/relate/point_point.hpp index f7d35ed09..e0efc1653 100644 --- a/include/boost/geometry/algorithms/detail/relate/point_point.hpp +++ b/include/boost/geometry/algorithms/detail/relate/point_point.hpp @@ -67,20 +67,25 @@ std::pair point_multipoint_check(Point const& point, // point_in_geometry could be used here but why iterate over MultiPoint twice? // we must search for a point in the exterior because all points in MultiPoint can be equal - typedef typename boost::range_iterator::type iterator; - iterator it = boost::begin(multi_point); - iterator last = boost::end(multi_point); - for ( ; it != last ; ++it ) + + auto const end = boost::end(multi_point); + for (auto it = boost::begin(multi_point); it != end; ++it) { bool ii = detail::equals::equals_point_point(point, *it, strategy); - if ( ii ) + if (ii) + { found_inside = true; + } else + { found_outside = true; + } - if ( found_inside && found_outside ) + if (found_inside && found_outside) + { break; + } } return std::make_pair(found_inside, found_outside); @@ -229,19 +234,22 @@ struct multipoint_multipoint bool found_outside = false; // for each point in the second MPt - typedef typename boost::range_iterator::type iterator; - for ( iterator it = boost::begin(iterated_mpt) ; - it != boost::end(iterated_mpt) ; ++it ) + for (auto it = boost::begin(iterated_mpt); it != boost::end(iterated_mpt); ++it) { - bool ii = - std::binary_search(points.begin(), points.end(), *it, less); - if ( ii ) + bool ii = std::binary_search(points.begin(), points.end(), *it, less); + if (ii) + { found_inside = true; + } else + { found_outside = true; + } - if ( found_inside && found_outside ) + if (found_inside && found_outside) + { break; + } } if ( found_inside ) // some point of MP2 is equal to some of MP1 diff --git a/include/boost/geometry/algorithms/detail/relate/topology_check.hpp b/include/boost/geometry/algorithms/detail/relate/topology_check.hpp index 459c81614..fb90c1544 100644 --- a/include/boost/geometry/algorithms/detail/relate/topology_check.hpp +++ b/include/boost/geometry/algorithms/detail/relate/topology_check.hpp @@ -175,17 +175,17 @@ private: void init() const { if (m_is_initialized) + { return; + } m_endpoints.reserve(boost::size(m_mls) * 2); m_has_interior = false; - typedef typename boost::range_iterator::type ls_iterator; - for ( ls_iterator it = boost::begin(m_mls) ; it != boost::end(m_mls) ; ++it ) + for (auto it = boost::begin(m_mls); it != boost::end(m_mls); ++it) { - typename boost::range_reference::type - ls = *it; + auto const& ls = *it; std::size_t count = boost::size(ls); @@ -196,13 +196,8 @@ private: if (count > 1) { - typedef typename boost::range_reference - < - typename boost::range_value::type const - >::type point_reference; - - point_reference front_pt = range::front(ls); - point_reference back_pt = range::back(ls); + auto const& front_pt = range::front(ls); + auto const& back_pt = range::back(ls); // don't store boundaries of linear rings, this doesn't change anything if (! equals::equals_point_point(front_pt, back_pt, m_strategy)) @@ -226,7 +221,7 @@ private: m_has_boundary = false; - if (! m_endpoints.empty() ) + if (! m_endpoints.empty()) { std::sort(m_endpoints.begin(), m_endpoints.end(), less_type()); m_has_boundary = find_odd_count(m_endpoints.begin(), m_endpoints.end()); diff --git a/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp b/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp index 97478be67..0da246d22 100644 --- a/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp +++ b/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -710,10 +709,7 @@ struct sectionalize_multi std::size_t max_count) { ring_id.multi_index = 0; - for (typename boost::range_iterator::type - it = boost::begin(multi); - it != boost::end(multi); - ++it, ++ring_id.multi_index) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it, ++ring_id.multi_index) { Policy::apply(*it, robust_policy, sections, strategy, diff --git a/include/boost/geometry/algorithms/detail/touches/implementation.hpp b/include/boost/geometry/algorithms/detail/touches/implementation.hpp index 1648af63e..753225e83 100644 --- a/include/boost/geometry/algorithms/detail/touches/implementation.hpp +++ b/include/boost/geometry/algorithms/detail/touches/implementation.hpp @@ -157,19 +157,20 @@ struct areal_interrupt_policy inline bool apply(Range const& range) { // if already rejected (temp workaround?) - if ( found_not_touch ) - return true; - - typedef typename boost::range_iterator::type iterator; - for ( iterator it = boost::begin(range) ; it != boost::end(range) ; ++it ) + if (found_not_touch) { - if ( it->has(overlay::operation_intersection) ) + return true; + } + + for (auto it = boost::begin(range); it != boost::end(range); ++it) + { + if (it->has(overlay::operation_intersection)) { found_not_touch = true; return true; } - switch(it->method) + switch (it->method) { case overlay::method_crosses: found_not_touch = true; diff --git a/include/boost/geometry/algorithms/detail/tupled_output.hpp b/include/boost/geometry/algorithms/detail/tupled_output.hpp index e0f889745..6298e7e76 100644 --- a/include/boost/geometry/algorithms/detail/tupled_output.hpp +++ b/include/boost/geometry/algorithms/detail/tupled_output.hpp @@ -593,8 +593,7 @@ struct convert_to_output static OutputIterator apply(Geometry const& geometry, OutputIterator oit) { - typedef typename boost::range_iterator::type iterator; - for (iterator it = boost::begin(geometry); it != boost::end(geometry); ++it) + for (auto it = boost::begin(geometry); it != boost::end(geometry); ++it) { SingleOut single_out; geometry::convert(*it, single_out); diff --git a/include/boost/geometry/algorithms/detail/within/multi_point.hpp b/include/boost/geometry/algorithms/detail/within/multi_point.hpp index 349ef0302..3f3e280f9 100644 --- a/include/boost/geometry/algorithms/detail/within/multi_point.hpp +++ b/include/boost/geometry/algorithms/detail/within/multi_point.hpp @@ -55,8 +55,7 @@ struct multi_point_point { auto const s = strategy.relate(multi_point, point); - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(multi_point) ; it != boost::end(multi_point) ; ++it ) + for (auto it = boost::begin(multi_point); it != boost::end(multi_point); ++it) { if (! s.apply(*it, point)) { @@ -88,8 +87,7 @@ struct multi_point_multi_point bool result = false; - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(multi_point1) ; it != boost::end(multi_point1) ; ++it ) + for (auto it = boost::begin(multi_point1); it != boost::end(multi_point1); ++it) { if (! std::binary_search(points2.begin(), points2.end(), *it, less)) { @@ -134,8 +132,7 @@ struct multi_point_single_geometry // If in the exterior, break bool result = false; - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(multi_point) ; it != boost::end(multi_point) ; ++it ) + for (auto it = boost::begin(multi_point); it != boost::end(multi_point); ++it ) { typedef decltype(strategy.covered_by(*it, box)) point_in_box_type; @@ -198,8 +195,7 @@ struct multi_point_multi_geometry // If a point is in the exterior break bool result = false; - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(multi_point) ; it != boost::end(multi_point) ; ++it ) + for (auto it = boost::begin(multi_point); it != boost::end(multi_point); ++it) { // TODO: investigate the possibility of using satisfies // TODO: investigate the possibility of using iterative queries (optimization below) diff --git a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp index c9b9cbfd8..459e54ec8 100644 --- a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -49,13 +48,12 @@ int point_in_range(Point const& point, Range const& range, Strategy const& strat { typename Strategy::state_type state; - typedef typename boost::range_iterator::type iterator_type; - iterator_type it = boost::begin(range); - iterator_type end = boost::end(range); + auto it = boost::begin(range); + auto const end = boost::end(range); - for ( iterator_type previous = it++ ; it != end ; ++previous, ++it ) + for (auto previous = it++; it != end; ++previous, ++it) { - if ( ! strategy.apply(point, *previous, *it, state) ) + if (! strategy.apply(point, *previous, *it, state)) { break; } @@ -202,13 +200,8 @@ struct point_in_geometry if (code == 1) { - typename interior_return_type::type - rings = interior_rings(polygon); - - for (typename detail::interior_iterator::type - it = boost::begin(rings); - it != boost::end(rings); - ++it) + auto const& rings = interior_rings(polygon); + for (auto it = boost::begin(rings); it != boost::end(rings); ++it) { int const interior_code = point_in_geometry < @@ -235,14 +228,16 @@ struct point_in_geometry int apply(Point const& point, Geometry const& geometry, Strategy const& strategy) { typedef typename boost::range_value::type point_type; - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(geometry) ; it != boost::end(geometry) ; ++it ) + for (auto it = boost::begin(geometry); it != boost::end(geometry); ++it) { int pip = point_in_geometry::apply(point, *it, strategy); //BOOST_GEOMETRY_ASSERT(pip != 0); - if ( pip > 0 ) // inside + if (pip > 0) + { + // inside return 1; + } } return -1; // outside @@ -259,14 +254,13 @@ struct point_in_geometry typedef typename boost::range_value::type linestring_type; typedef typename boost::range_value::type point_type; - typedef typename boost::range_iterator::type iterator; - iterator it = boost::begin(geometry); - for ( ; it != boost::end(geometry) ; ++it ) + auto it = boost::begin(geometry); + for ( ; it != boost::end(geometry); ++it) { pip = point_in_geometry::apply(point, *it, strategy); // inside or on the boundary - if ( pip >= 0 ) + if (pip >= 0) { ++it; break; @@ -274,24 +268,30 @@ struct point_in_geometry } // outside - if ( pip < 0 ) + if (pip < 0) + { return -1; + } // TODO: the following isn't needed for covered_by() unsigned boundaries = pip == 0 ? 1 : 0; - for ( ; it != boost::end(geometry) ; ++it ) + for (; it != boost::end(geometry); ++it) { - if ( boost::size(*it) < 2 ) + if (boost::size(*it) < 2) + { continue; + } point_type const& front = range::front(*it); point_type const& back = range::back(*it); // is closed_ring - no boundary - if ( detail::equals::equals_point_point(front, back, strategy) ) + if (detail::equals::equals_point_point(front, back, strategy)) + { continue; + } // is point on boundary if ( detail::equals::equals_point_point(point, front, strategy) @@ -316,14 +316,15 @@ struct point_in_geometry //int res = -1; // outside typedef typename boost::range_value::type polygon_type; - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(geometry) ; it != boost::end(geometry) ; ++it ) + for (auto it = boost::begin(geometry); it != boost::end(geometry); ++it) { int pip = point_in_geometry::apply(point, *it, strategy); // inside or on the boundary - if ( pip >= 0 ) + if (pip >= 0) + { return pip; + } // For invalid multi-polygons //if ( 1 == pip ) // inside polygon diff --git a/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp b/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp index 8da05e58f..c34425151 100644 --- a/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp +++ b/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp @@ -41,8 +41,10 @@ struct within_no_turns { typedef typename geometry::point_type::type point1_type; point1_type p; - if ( !geometry::point_on_border(p, geometry1) ) + if (! geometry::point_on_border(p, geometry1)) + { return false; + } return detail::within::point_in_geometry(p, geometry2, strategy) >= 0; } @@ -57,25 +59,28 @@ struct within_no_turns typedef typename geometry::point_type::type point1_type; typedef typename geometry::point_type::type point2_type; point1_type p; - if ( !geometry::point_on_border(p, geometry1) ) + if (! geometry::point_on_border(p, geometry1)) + { return false; + } // check if one of ring points is outside the polygon - if ( detail::within::point_in_geometry(p, geometry2, strategy) < 0 ) + if (detail::within::point_in_geometry(p, geometry2, strategy) < 0) + { return false; + } // Now check if holes of G2 aren't inside G1 - typedef typename boost::range_const_iterator - < - typename geometry::interior_type::type - >::type iterator; - for ( iterator it = boost::begin(geometry::interior_rings(geometry2)) ; - it != boost::end(geometry::interior_rings(geometry2)) ; - ++it ) + auto const& rings2 = geometry::interior_rings(geometry2); + for (auto it = boost::begin(rings2); it != boost::end(rings2); ++it) { point2_type p; - if ( !geometry::point_on_border(p, *it) ) + if (! geometry::point_on_border(p, *it)) + { return false; - if ( detail::within::point_in_geometry(p, geometry1, strategy) > 0 ) + } + if (detail::within::point_in_geometry(p, geometry1, strategy) > 0) + { return false; + } } return true; } @@ -90,44 +95,42 @@ struct within_no_turns typedef typename geometry::point_type::type point1_type; typedef typename geometry::point_type::type point2_type; point1_type p; - if ( !geometry::point_on_border(p, geometry1) ) + if (! geometry::point_on_border(p, geometry1)) + { return false; + } // check if one of ring points is outside the polygon - if ( detail::within::point_in_geometry(p, geometry2, strategy) < 0 ) + if (detail::within::point_in_geometry(p, geometry2, strategy) < 0) + { return false; + } // Now check if holes of G2 aren't inside G1 - typedef typename boost::range_const_iterator - < - typename geometry::interior_type::type - >::type iterator2; - for ( iterator2 it = boost::begin(geometry::interior_rings(geometry2)) ; - it != boost::end(geometry::interior_rings(geometry2)) ; - ++it ) + auto const& rings2 = geometry::interior_rings(geometry2); + for (auto it2 = boost::begin(rings2); it != boost::end(rings2); ++it) { point2_type p2; - if ( !geometry::point_on_border(p2, *it) ) + if (! geometry::point_on_border(p2, *it2)) + { return false; + } // if the hole of G2 is inside G1 - if ( detail::within::point_in_geometry(p2, geometry1, strategy) > 0 ) + if (detail::within::point_in_geometry(p2, geometry1, strategy) > 0) { // if it's also inside one of the G1 holes, it's ok bool ok = false; - typedef typename boost::range_const_iterator - < - typename geometry::interior_type::type - >::type iterator1; - for ( iterator1 it1 = boost::begin(geometry::interior_rings(geometry1)) ; - it1 != boost::end(geometry::interior_rings(geometry1)) ; - ++it1 ) + auto const& rings1 = geometry::interior_rings(geometry1); + for (auto it1 = boost::begin(rings1); it1 != boost::end(rings1); ++it1) { - if ( detail::within::point_in_geometry(p2, *it1, strategy) < 0 ) + if (detail::within::point_in_geometry(p2, *it1, strategy) < 0) { ok = true; break; } } - if ( !ok ) + if (! ok) + { return false; + } } } return true; @@ -157,11 +160,12 @@ struct within_no_turns_multi { // All values of G1 must be inside G2 typedef typename boost::range_value::type subgeometry1; - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it ) + for (auto it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it ) { - if ( !within_no_turns::apply(*it, geometry2, strategy) ) + if (! within_no_turns::apply(*it, geometry2, strategy)) + { return false; + } } return true; } @@ -175,11 +179,12 @@ struct within_no_turns_multi { // G1 must be within at least one value of G2 typedef typename boost::range_value::type subgeometry2; - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(geometry2) ; it != boost::end(geometry2) ; ++it ) + for (auto it = boost::begin(geometry2); it != boost::end(geometry2); ++it) { - if ( within_no_turns::apply(geometry1, *it, strategy) ) + if (within_no_turns::apply(geometry1, *it, strategy)) + { return true; + } } return false; } @@ -193,11 +198,12 @@ struct within_no_turns_multi { // each value of G1 must be inside at least one value of G2 typedef typename boost::range_value::type subgeometry1; - typedef typename boost::range_const_iterator::type iterator; - for ( iterator it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it ) + for (auto it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it) { - if ( !within_no_turns_multi::apply(*it, geometry2, strategy) ) + if (! within_no_turns_multi::apply(*it, geometry2, strategy)) + { return false; + } } return true; } diff --git a/include/boost/geometry/algorithms/for_each.hpp b/include/boost/geometry/algorithms/for_each.hpp index e39c1b571..65a9b13a9 100644 --- a/include/boost/geometry/algorithms/for_each.hpp +++ b/include/boost/geometry/algorithms/for_each.hpp @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -326,9 +325,7 @@ struct for_each_polygon return false; } - typename interior_return_type::type - rings = interior_rings(poly); - + auto&& rings = interior_rings(poly); auto const end = boost::end(rings); for (auto it = boost::begin(rings); it != end; ++it) { diff --git a/include/boost/geometry/algorithms/is_convex.hpp b/include/boost/geometry/algorithms/is_convex.hpp index 0d54111c9..691b56533 100644 --- a/include/boost/geometry/algorithms/is_convex.hpp +++ b/include/boost/geometry/algorithms/is_convex.hpp @@ -139,6 +139,7 @@ struct multi_polygon_is_convex static inline bool apply(MultiPolygon const& multi_polygon, Strategies const& strategies) { auto const size = boost::size(multi_polygon); + // TODO: this looks wrong, it should only return convex if all its rings are convex return size == 0 // For consistency with ring_is_convex || (size == 1 && polygon_is_convex::apply(range::front(multi_polygon), strategies)); } @@ -272,7 +273,7 @@ struct is_convex template static bool apply(Geometry const& geometry, Strategy const& strategy) { - concepts::check(); + concepts::check(); return resolve_strategy::is_convex::apply(geometry, strategy); } }; diff --git a/include/boost/geometry/algorithms/line_interpolate.hpp b/include/boost/geometry/algorithms/line_interpolate.hpp index 47c89c582..239dd5946 100644 --- a/include/boost/geometry/algorithms/line_interpolate.hpp +++ b/include/boost/geometry/algorithms/line_interpolate.hpp @@ -89,11 +89,10 @@ struct interpolate_range PointLike & pointlike, Strategies const& strategies) { - typedef typename boost::range_iterator::type iterator_t; typedef typename boost::range_value::type point_t; - iterator_t it = boost::begin(range); - iterator_t end = boost::end(range); + auto it = boost::begin(range); + auto const end = boost::end(range); if (it == end) // empty(range) { @@ -112,7 +111,7 @@ struct interpolate_range typedef decltype(pp_strategy.apply( std::declval(), std::declval())) distance_type; - iterator_t prev = it++; + auto prev = it++; distance_type repeated_distance = max_distance; distance_type prev_distance = 0; distance_type current_distance = 0; diff --git a/include/boost/geometry/algorithms/point_on_surface.hpp b/include/boost/geometry/algorithms/point_on_surface.hpp index 803f71a91..966cd8535 100644 --- a/include/boost/geometry/algorithms/point_on_surface.hpp +++ b/include/boost/geometry/algorithms/point_on_surface.hpp @@ -82,11 +82,11 @@ template empty()) + if (! item.empty()) { - Value the_value = geometry::get(*std::max_element(it->begin(), it->end(), predicate)); + Value the_value = geometry::get(*std::max_element(item.begin(), item.end(), predicate)); if (first || the_value > the_max) { the_max = the_value; @@ -153,16 +153,14 @@ template inline void calculate_average(Point& point, std::vector

const& points) { typedef typename geometry::coordinate_type::type coordinate_type; - typedef typename std::vector

::const_iterator iterator_type; coordinate_type x = 0; coordinate_type y = 0; - iterator_type end = points.end(); - for ( iterator_type it = points.begin() ; it != end ; ++it) + for (auto const& p : points) { - x += geometry::get<0>(*it); - y += geometry::get<1>(*it); + x += geometry::get<0>(p); + y += geometry::get<1>(p); } signed_size_type const count = points.size(); diff --git a/include/boost/geometry/algorithms/remove_spikes.hpp b/include/boost/geometry/algorithms/remove_spikes.hpp index ad631183d..533d43330 100644 --- a/include/boost/geometry/algorithms/remove_spikes.hpp +++ b/include/boost/geometry/algorithms/remove_spikes.hpp @@ -37,7 +37,6 @@ #include #include -#include #include #include @@ -88,11 +87,10 @@ struct range_remove_spikes std::vector cleaned; cleaned.reserve(n); - for (typename boost::range_iterator::type it = boost::begin(range); - it != boost::end(range); ++it) + for (auto const& p : range) { // Add point - cleaned.push_back(*it); + cleaned.push_back(p); while(cleaned.size() >= 3 && detail::is_spike_or_equal(range::at(cleaned, cleaned.size() - 3), @@ -105,9 +103,8 @@ struct range_remove_spikes } } - typedef typename std::vector::iterator cleaned_iterator; - cleaned_iterator cleaned_b = cleaned.begin(); - cleaned_iterator cleaned_e = cleaned.end(); + auto cleaned_b = cleaned.begin(); + auto cleaned_e = cleaned.end(); std::size_t cleaned_count = cleaned.size(); // For a closed-polygon, remove closing point, this makes checking first point(s) easier and consistent @@ -178,11 +175,9 @@ struct polygon_remove_spikes typedef range_remove_spikes per_range; per_range::apply(exterior_ring(polygon), strategy); - typename interior_return_type::type - rings = interior_rings(polygon); + auto&& rings = interior_rings(polygon); - for (typename detail::interior_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it) + for (auto it = boost::begin(rings); it != boost::end(rings); ++it) { per_range::apply(*it, strategy); } @@ -196,10 +191,7 @@ struct multi_remove_spikes template static inline void apply(MultiGeometry& multi, SideStrategy const& strategy) { - for (typename boost::range_iterator::type - it = boost::begin(multi); - it != boost::end(multi); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { SingleVersion::apply(*it, strategy); } diff --git a/include/boost/geometry/algorithms/reverse.hpp b/include/boost/geometry/algorithms/reverse.hpp index 2fc4b1ccb..45b16b2bf 100644 --- a/include/boost/geometry/algorithms/reverse.hpp +++ b/include/boost/geometry/algorithms/reverse.hpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/transform.hpp b/include/boost/geometry/algorithms/transform.hpp index 9b63a8507..12120eb28 100644 --- a/include/boost/geometry/algorithms/transform.hpp +++ b/include/boost/geometry/algorithms/transform.hpp @@ -34,7 +34,6 @@ #include #include -#include #include #include @@ -143,10 +142,7 @@ inline bool transform_range_out(Range const& range, OutputIterator out, Strategy const& strategy) { PointOut point_out; - for(typename boost::range_iterator::type - it = boost::begin(range); - it != boost::end(range); - ++it) + for (auto it = boost::begin(range); it != boost::end(range); ++it) { if (! transform_point::apply(*it, point_out, strategy)) { @@ -184,15 +180,11 @@ struct transform_polygon >::apply(geometry::interior_rings(poly2), geometry::num_interior_rings(poly1)); - typename geometry::interior_return_type::type - rings1 = geometry::interior_rings(poly1); - typename geometry::interior_return_type::type - rings2 = geometry::interior_rings(poly2); + auto const& rings1 = geometry::interior_rings(poly1); + auto&& rings2 = geometry::interior_rings(poly2); - typename detail::interior_iterator::type - it1 = boost::begin(rings1); - typename detail::interior_iterator::type - it2 = boost::begin(rings2); + auto it1 = boost::begin(rings1); + auto it2 = boost::begin(rings2); for ( ; it1 != boost::end(rings1); ++it1, ++it2) { if ( ! transform_range_out(*it1, @@ -251,10 +243,8 @@ struct transform_multi { traits::resize::apply(multi2, boost::size(multi1)); - typename boost::range_iterator::type it1 - = boost::begin(multi1); - typename boost::range_iterator::type it2 - = boost::begin(multi2); + auto it1 = boost::begin(multi1); + auto it2 = boost::begin(multi2); for (; it1 != boost::end(multi1); ++it1, ++it2) { diff --git a/include/boost/geometry/algorithms/unique.hpp b/include/boost/geometry/algorithms/unique.hpp index c953311bb..618087e14 100644 --- a/include/boost/geometry/algorithms/unique.hpp +++ b/include/boost/geometry/algorithms/unique.hpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -46,7 +45,7 @@ struct range_unique template static inline void apply(Range& range, ComparePolicy const& policy) { - typename boost::range_iterator::type it + auto it = std::unique ( boost::begin(range), @@ -66,11 +65,9 @@ struct polygon_unique { range_unique::apply(exterior_ring(polygon), policy); - typename interior_return_type::type - rings = interior_rings(polygon); + auto&& rings = interior_rings(polygon); - for (typename detail::interior_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it) + for (auto it = boost::begin(rings); it != boost::end(rings); ++it) { range_unique::apply(*it, policy); } @@ -84,10 +81,7 @@ struct multi_unique template static inline void apply(MultiGeometry& multi, ComparePolicy const& compare) { - for (typename boost::range_iterator::type - it = boost::begin(multi); - it != boost::end(multi); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { Policy::apply(*it, compare); } diff --git a/include/boost/geometry/geometry.hpp b/include/boost/geometry/geometry.hpp index c232c831c..cd9957671 100644 --- a/include/boost/geometry/geometry.hpp +++ b/include/boost/geometry/geometry.hpp @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include @@ -94,6 +95,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/geometry/io/dsv/write.hpp b/include/boost/geometry/io/dsv/write.hpp index d24255d4a..5870d21c5 100644 --- a/include/boost/geometry/io/dsv/write.hpp +++ b/include/boost/geometry/io/dsv/write.hpp @@ -28,8 +28,6 @@ #include #include -#include - #include #include #include @@ -170,15 +168,11 @@ struct dsv_range Range const& range, dsv_settings const& settings) { - typedef typename boost::range_iterator::type iterator_type; - bool first = true; os << settings.list_open; - for (iterator_type it = boost::begin(range); - it != boost::end(range); - ++it) + for (auto it = boost::begin(range); it != boost::end(range); ++it) { os << (first ? "" : settings.point_separator) << settings.point_open; @@ -218,10 +212,8 @@ struct dsv_poly dsv_range::apply(os, exterior_ring(poly), settings); - typename interior_return_type::type - rings = interior_rings(poly); - for (typename detail::interior_iterator::type - it = boost::begin(rings); it != boost::end(rings); ++it) + auto const& rings = interior_rings(poly); + for (auto it = boost::begin(rings); it != boost::end(rings); ++it) { os << settings.list_separator; dsv_range::apply(os, *it, settings); @@ -362,12 +354,6 @@ struct dsv_multi typename boost::range_value::type > dispatch_one; - typedef typename boost::range_iterator - < - MultiGeometry const - >::type iterator; - - template static inline void apply(std::basic_ostream& os, MultiGeometry const& multi, @@ -376,9 +362,7 @@ struct dsv_multi os << settings.list_open; bool first = true; - for(iterator it = boost::begin(multi); - it != boost::end(multi); - ++it, first = false) + for(auto it = boost::begin(multi); it != boost::end(multi); ++it, first = false) { os << (first ? "" : settings.list_separator); dispatch_one::apply(os, *it, settings); diff --git a/include/boost/geometry/io/svg/svg_mapper.hpp b/include/boost/geometry/io/svg/svg_mapper.hpp index aaac85044..1785ac1cf 100644 --- a/include/boost/geometry/io/svg/svg_mapper.hpp +++ b/include/boost/geometry/io/svg/svg_mapper.hpp @@ -160,10 +160,7 @@ struct svg_map std::string const& style, double size, Multi const& multi, TransformStrategy const& strategy) { - for (typename boost::range_iterator::type it - = boost::begin(multi); - it != boost::end(multi); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { svg_map < @@ -466,19 +463,17 @@ public : { // Multi-line modus - std::vector splitted; - boost::split(splitted, s, boost::is_any_of("\n")); - for (std::vector::const_iterator it - = splitted.begin(); - it != splitted.end(); - ++it, offset_y += lineheight) + std::vector split; + boost::split(split, s, boost::is_any_of("\n")); + for (auto const& item : split) { m_stream << "(map_point) + offset_x << "\"" << " y=\"" << get<1>(map_point) + offset_y << "\"" - << ">" << *it << ""; + << ">" << item << ""; + offset_y += lineheight; } } m_stream << "" << std::endl; diff --git a/include/boost/geometry/io/svg/write.hpp b/include/boost/geometry/io/svg/write.hpp index f372b7adf..84803fa06 100644 --- a/include/boost/geometry/io/svg/write.hpp +++ b/include/boost/geometry/io/svg/write.hpp @@ -29,8 +29,6 @@ #include #include -#include - #include #include #include @@ -117,15 +115,11 @@ struct svg_range static inline void apply(std::basic_ostream& os, Range const& range, std::string const& style, double) { - typedef typename boost::range_iterator::type iterator; - bool first = true; os << "<" << Policy::prefix() << " points=\""; - for (iterator it = boost::begin(range); - it != boost::end(range); - ++it, first = false) + for (auto it = boost::begin(range); it != boost::end(range); ++it, first = false) { os << (first ? "" : " " ) << geometry::get<0>(*it) @@ -146,15 +140,12 @@ struct svg_poly Polygon const& polygon, std::string const& style, double) { typedef typename geometry::ring_type::type ring_type; - typedef typename boost::range_iterator::type iterator_type; bool first = true; os << "(*it) @@ -164,15 +155,11 @@ struct svg_poly // Inner rings: { - typename interior_return_type::type - rings = interior_rings(polygon); - for (typename detail::interior_iterator::type - rit = boost::begin(rings); rit != boost::end(rings); ++rit) + auto const& rings = interior_rings(polygon); + for (auto rit = boost::begin(rings); rit != boost::end(rings); ++rit) { first = true; - for (typename detail::interior_ring_iterator::type - it = boost::begin(*rit); it != boost::end(*rit); - ++it, first = false) + for (auto it = boost::begin(*rit); it != boost::end(*rit); ++it, first = false) { os << (first ? "M" : " L") << " " << geometry::get<0>(*it) @@ -209,14 +196,10 @@ struct svg_multi static inline void apply(std::basic_ostream& os, MultiGeometry const& multi, std::string const& style, double size) { - for (typename boost::range_iterator::type - it = boost::begin(multi); - it != boost::end(multi); - ++it) + for (auto it = boost::begin(multi); it != boost::end(multi); ++it) { Policy::apply(os, *it, style, size); } - } }; diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index eae3a1d89..fdb46c633 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -754,7 +754,7 @@ struct box_parser { auto const tokens{make_tokenizer(wkt)}; auto it = tokens.begin(); - auto end = tokens.end(); + auto const end = tokens.end(); apply(it, end, wkt, box); @@ -835,7 +835,7 @@ struct segment_parser { auto const tokens{make_tokenizer(wkt)}; auto it = tokens.begin(); - auto end = tokens.end(); + auto const end = tokens.end(); apply(it, end, wkt, segment); @@ -1122,7 +1122,7 @@ struct read_wkt { auto tokens{detail::wkt::make_tokenizer(wkt)}; auto it = tokens.begin(); - auto end = tokens.end(); + auto const end = tokens.end(); if (it == end) { BOOST_THROW_EXCEPTION(read_wkt_exception( diff --git a/include/boost/geometry/io/wkt/write.hpp b/include/boost/geometry/io/wkt/write.hpp index f57fb7b35..801f09693 100644 --- a/include/boost/geometry/io/wkt/write.hpp +++ b/include/boost/geometry/io/wkt/write.hpp @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -136,7 +135,7 @@ struct wkt_range os << "("; } auto begin = boost::begin(range); - auto end = boost::end(range); + auto const end = boost::end(range); for (auto it = begin; it != end; ++it) { os << (first ? "" : ","); @@ -201,8 +200,8 @@ struct wkt_poly { using ring = typename ring_type::type; - auto const exterior = exterior_ring(poly); - auto const rings = interior_rings(poly); + auto const& exterior = exterior_ring(poly); + auto const& rings = interior_rings(poly); std::size_t point_count = boost::size(exterior); for (auto it = boost::begin(rings); it != boost::end(rings); ++it) diff --git a/include/boost/geometry/util/for_each_with_index.hpp b/include/boost/geometry/util/for_each_with_index.hpp index 99c1100b7..425f2a497 100644 --- a/include/boost/geometry/util/for_each_with_index.hpp +++ b/include/boost/geometry/util/for_each_with_index.hpp @@ -9,8 +9,9 @@ #ifndef BOOST_GEOMETRY_UTIL_FOR_EACH_WITH_INDEX_HPP #define BOOST_GEOMETRY_UTIL_FOR_EACH_WITH_INDEX_HPP -#include -#include +#include +#include +#include namespace boost { namespace geometry { @@ -23,8 +24,18 @@ namespace detail template inline void for_each_with_index(Container const& container, Function func) { - std::size_t index = 0; - for (auto it = std::begin(container); it != std::end(container); ++it, ++index) + typename boost::range_size::type index = 0; + for (auto it = boost::begin(container); it != boost::end(container); ++it, ++index) + { + func(index, *it); + } +} + +template +inline void for_each_with_index(Container& container, Function func) +{ + typename boost::range_size::type index = 0; + for (auto it = boost::begin(container); it != boost::end(container); ++it, ++index) { func(index, *it); } diff --git a/test/algorithms/buffer/test_buffer_svg_per_turn.hpp b/test/algorithms/buffer/test_buffer_svg_per_turn.hpp index be01f4b95..1a32323a6 100644 --- a/test/algorithms/buffer/test_buffer_svg_per_turn.hpp +++ b/test/algorithms/buffer/test_buffer_svg_per_turn.hpp @@ -146,10 +146,9 @@ public : template inline void apply(PieceCollection const& collection, int phase) { - for(typename container_type::iterator it = mappers.begin(); - it != mappers.end(); ++it) + for (auto& item : mappers) { - it->apply(collection, phase); + item.apply(collection, phase); } } @@ -157,10 +156,9 @@ public : void map_input_output(Geometry const& geometry, GeometryBuffer const& buffered, bool negative) { - for(typename container_type::iterator it = mappers.begin(); - it != mappers.end(); ++it) + for (auto& item : mappers) { - it->map_input_output(geometry, buffered, negative); + item.map_input_output(geometry, buffered, negative); } } }; diff --git a/test/algorithms/overlay/multi_overlay_common.hpp b/test/algorithms/overlay/multi_overlay_common.hpp index 5d6aa20ec..91f15fa9f 100644 --- a/test/algorithms/overlay/multi_overlay_common.hpp +++ b/test/algorithms/overlay/multi_overlay_common.hpp @@ -23,8 +23,7 @@ template void test_all(std::vector const& expected, double precision = 0.01) { - typename boost::range_const_iterator >::type iterator - = boost::begin(expected); + auto iterator = boost::begin(expected); typedef bg::model::multi_polygon > mp; typedef bg::model::box

box; diff --git a/test/algorithms/overlay/overlay_common.hpp b/test/algorithms/overlay/overlay_common.hpp index 01fd109e5..451d1aaee 100644 --- a/test/algorithms/overlay/overlay_common.hpp +++ b/test/algorithms/overlay/overlay_common.hpp @@ -95,8 +95,7 @@ void test_all(std::vector const& expected) // compilation test only, will not output //test_overlay("", "", "", ""); - typename boost::range_const_iterator >::type iterator - = boost::begin(expected); + auto iterator = boost::begin(expected); #ifndef ONLY_CASE_BRANDON diff --git a/test/algorithms/set_operations/difference/test_difference.hpp b/test/algorithms/set_operations/difference/test_difference.hpp index 3ec8dfa24..8717235cc 100644 --- a/test/algorithms/set_operations/difference/test_difference.hpp +++ b/test/algorithms/set_operations/difference/test_difference.hpp @@ -147,9 +147,9 @@ void difference_output(std::string const& caseid, G1 const& g1, G2 const& g2, Ou mapper.map(g2, "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:3"); - for (typename Output::const_iterator it = output.begin(); it != output.end(); ++it) + for (auto const& item : output) { - mapper.map(*it, + mapper.map(item, //sym ? "fill-opacity:0.2;stroke-opacity:0.4;fill:rgb(255,255,0);stroke:rgb(255,0,255);stroke-width:8" : "fill-opacity:0.2;stroke-opacity:0.4;fill:rgb(255,0,0);stroke:rgb(255,0,255);stroke-width:8"); } diff --git a/test/algorithms/set_operations/intersection/test_intersection.hpp b/test/algorithms/set_operations/intersection/test_intersection.hpp index b2de92027..5951325b6 100644 --- a/test/algorithms/set_operations/intersection/test_intersection.hpp +++ b/test/algorithms/set_operations/intersection/test_intersection.hpp @@ -256,10 +256,9 @@ typename bg::default_area_result::type test_intersection(std::string const& mapper.map(g2, "fill-opacity:0.3;fill:rgb(51,51,153);" "stroke:rgb(51,51,153);stroke-width:3"); - for (typename result_type::const_iterator it = intersection_output.begin(); - it != intersection_output.end(); ++it) + for (auto const& item : intersection_output) { - mapper.map(*it, "fill-opacity:0.2;stroke-opacity:0.4;fill:rgb(255,0,0);" + mapper.map(item, "fill-opacity:0.2;stroke-opacity:0.4;fill:rgb(255,0,0);" "stroke:rgb(255,0,255);stroke-width:8"); } } diff --git a/test/algorithms/set_operations/union/test_union.hpp b/test/algorithms/set_operations/union/test_union.hpp index 3ea139d59..1946e3df7 100644 --- a/test/algorithms/set_operations/union/test_union.hpp +++ b/test/algorithms/set_operations/union/test_union.hpp @@ -227,10 +227,9 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2, //mapper.map(g1, "opacity:0.6;fill:rgb(0,0,255);stroke:rgb(0,0,0);stroke-width:1"); //mapper.map(g2, "opacity:0.6;fill:rgb(0,255,0);stroke:rgb(0,0,0);stroke-width:1"); - for (typename result_type::const_iterator it = clip.begin(); - it != clip.end(); ++it) + for (auto const& item : clip) { - mapper.map(*it, "fill-opacity:0.2;stroke-opacity:0.4;fill:rgb(255,0,0);" + mapper.map(item, "fill-opacity:0.2;stroke-opacity:0.4;fill:rgb(255,0,0);" "stroke:rgb(255,0,255);stroke-width:8"); //mapper.map(*it, "opacity:0.6;fill:none;stroke:rgb(255,0,0);stroke-width:5"); }