diff --git a/include/boost/geometry/algorithms/detail/check_iterator_range.hpp b/include/boost/geometry/algorithms/detail/check_iterator_range.hpp deleted file mode 100644 index 9bd1d7ae2..000000000 --- a/include/boost/geometry/algorithms/detail/check_iterator_range.hpp +++ /dev/null @@ -1,71 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) - -// Copyright (c) 2014, Oracle and/or its affiliates. - -// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle - -// Licensed under the Boost Software License version 1.0. -// http://www.boost.org/users/license.html - -#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CHECK_ITERATOR_RANGE_HPP -#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CHECK_ITERATOR_RANGE_HPP - -#include - - -namespace boost { namespace geometry -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -// Check whether (each element of) an iterator range satisfies a given -// predicate. -// The predicate must be implemented as having a static apply unary -// method that returns a bool. -// By default an empty range is accepted -template -struct check_iterator_range -{ - template - static inline bool apply(InputIterator first, InputIterator beyond) - { - for (InputIterator it = first; it != beyond; ++it) - { - if (! Predicate::apply(*it)) - { - return false; - } - } - return AllowEmptyRange || first != beyond; - } - - - // version where we can pass a predicate object - template - static inline bool apply(InputIterator first, - InputIterator beyond, - Predicate const& predicate) - { - // in case predicate's apply method is static, MSVC will - // complain that predicate is not used - boost::ignore_unused(predicate); - - for (InputIterator it = first; it != beyond; ++it) - { - if (! predicate.apply(*it)) - { - return false; - } - } - return AllowEmptyRange || first != beyond; - } -}; - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - -}} // namespace boost::geometry - -#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CHECK_ITERATOR_RANGE_HPP diff --git a/include/boost/geometry/algorithms/detail/closest_points/multipoint_to_geometry.hpp b/include/boost/geometry/algorithms/detail/closest_points/multipoint_to_geometry.hpp index 981281014..3b9b1d9f6 100644 --- a/include/boost/geometry/algorithms/detail/closest_points/multipoint_to_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/closest_points/multipoint_to_geometry.hpp @@ -13,7 +13,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp b/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp index 0a1513fbe..53eec91a7 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp @@ -8,8 +8,9 @@ // This file was modified by Oracle on 2013-2021. // Modifications copyright (c) 2013-2021, Oracle and/or its affiliates. -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -40,7 +41,6 @@ #include #include -#include #include #include @@ -141,28 +141,25 @@ struct disjoint_segment_areal template class disjoint_segment_areal { -private: + template static inline bool check_interior_rings(InteriorRings const& interior_rings, Segment const& segment, Strategy const& strategy) { - typedef typename boost::range_value::type ring_type; + using ring_type = typename boost::range_value::type; - typedef unary_disjoint_geometry_to_query_geometry + using unary_predicate_type = unary_disjoint_geometry_to_query_geometry < Segment, Strategy, disjoint_range_segment_or_box - > unary_predicate_type; - - return check_iterator_range - < - unary_predicate_type - >::apply(boost::begin(interior_rings), - boost::end(interior_rings), - unary_predicate_type(segment, strategy)); + >; + + return std::all_of(boost::begin(interior_rings), + boost::end(interior_rings), + unary_predicate_type(segment, strategy)); } diff --git a/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp b/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp index 9e3a57a29..ac129a998 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp @@ -2,7 +2,9 @@ // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. + +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -31,7 +33,6 @@ #include #include -#include #include #include #include @@ -63,24 +64,24 @@ class multipoint_multipoint { private: template - class unary_disjoint_predicate + class unary_not_disjoint_predicate : geometry::less { private: typedef geometry::less base_type; public: - unary_disjoint_predicate(Iterator first, Iterator last) + unary_not_disjoint_predicate(Iterator first, Iterator last) : base_type(), m_first(first), m_last(last) {} template - inline bool apply(Point const& point) const + inline bool operator()(Point const& point) const { - return !std::binary_search(m_first, - m_last, - point, - static_cast(*this)); + return std::binary_search(m_first, + m_last, + point, + static_cast(*this)); } private: @@ -93,30 +94,26 @@ public: MultiPoint2 const& multipoint2, Strategy const&) { - typedef typename Strategy::cs_tag cs_tag; - typedef geometry::less less_type; - BOOST_GEOMETRY_ASSERT( boost::size(multipoint1) <= boost::size(multipoint2) ); - typedef typename boost::range_value::type point1_type; + using cs_tag = typename Strategy::cs_tag; + using less_type = geometry::less; + using point1_type = typename boost::range_value::type; std::vector points1(boost::begin(multipoint1), boost::end(multipoint1)); std::sort(points1.begin(), points1.end(), less_type()); - typedef unary_disjoint_predicate + using predicate_type = unary_not_disjoint_predicate < typename std::vector::const_iterator, cs_tag - > predicate_type; + >; - return check_iterator_range - < - predicate_type - >::apply(boost::begin(multipoint2), - boost::end(multipoint2), - predicate_type(points1.begin(), points1.end())); + return none_of(boost::begin(multipoint2), + boost::end(multipoint2), + predicate_type(points1.begin(), points1.end())); } }; diff --git a/include/boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp b/include/boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp index 51945551b..42750af34 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp @@ -1,7 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -16,7 +17,6 @@ #include #include -#include #include @@ -34,13 +34,13 @@ class unary_disjoint_geometry_to_query_geometry { public: unary_disjoint_geometry_to_query_geometry(Geometry const& geometry, - Strategy const& strategy) + Strategy const& strategy) : m_geometry(geometry) , m_strategy(strategy) {} template - inline bool apply(QueryGeometry const& query_geometry) const + inline bool operator()(QueryGeometry const& query_geometry) const { return BinaryPredicate::apply(query_geometry, m_geometry, m_strategy); } @@ -59,7 +59,7 @@ struct multirange_constant_size_geometry ConstantSizeGeometry const& constant_size_geometry, Strategy const& strategy) { - typedef unary_disjoint_geometry_to_query_geometry + using disjoint = unary_disjoint_geometry_to_query_geometry < ConstantSizeGeometry, Strategy, @@ -68,13 +68,11 @@ struct multirange_constant_size_geometry typename boost::range_value::type, ConstantSizeGeometry > - > unary_predicate_type; + >; - return detail::check_iterator_range - < - unary_predicate_type - >::apply(boost::begin(multirange), boost::end(multirange), - unary_predicate_type(constant_size_geometry, strategy)); + return std::all_of(boost::begin(multirange), + boost::end(multirange), + disjoint(constant_size_geometry, strategy)); } template diff --git a/include/boost/geometry/algorithms/detail/distance/multipoint_to_geometry.hpp b/include/boost/geometry/algorithms/detail/distance/multipoint_to_geometry.hpp index eabc9528d..e410e53d8 100644 --- a/include/boost/geometry/algorithms/detail/distance/multipoint_to_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/distance/multipoint_to_geometry.hpp @@ -1,7 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2021 Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -16,7 +17,6 @@ #include #include -#include #include #include #include @@ -46,7 +46,6 @@ struct multipoint_to_multipoint Strategies const& strategies) { if (boost::size(multipoint2) < boost::size(multipoint1)) - { return point_or_segment_range_to_geometry_rtree < @@ -103,16 +102,16 @@ template class multipoint_to_areal { private: - struct not_covered_by_areal + struct covered_by_areal { - not_covered_by_areal(Areal const& areal, Strategies const& strategy) + covered_by_areal(Areal const& areal, Strategies const& strategy) : m_areal(areal), m_strategy(strategy) {} template - inline bool apply(Point const& point) const + inline bool operator()(Point const& point) const { - return !geometry::covered_by(point, m_areal, m_strategy); + return geometry::covered_by(point, m_areal, m_strategy); } Areal const& m_areal; @@ -126,14 +125,10 @@ public: Areal const& areal, Strategies const& strategies) { - not_covered_by_areal predicate(areal, strategies); + covered_by_areal predicate(areal, strategies); - if (check_iterator_range - < - not_covered_by_areal, false - >::apply(boost::begin(multipoint), - boost::end(multipoint), - predicate)) + if (! boost::empty(multipoint) && + std::none_of(boost::begin(multipoint), boost::end(multipoint), predicate)) { return detail::distance::point_or_segment_range_to_geometry_rtree < diff --git a/include/boost/geometry/algorithms/detail/is_simple/areal.hpp b/include/boost/geometry/algorithms/detail/is_simple/areal.hpp index 4fc3fa26e..952aa4e54 100644 --- a/include/boost/geometry/algorithms/detail/is_simple/areal.hpp +++ b/include/boost/geometry/algorithms/detail/is_simple/areal.hpp @@ -49,12 +49,12 @@ template inline bool are_simple_interior_rings(InteriorRings const& interior_rings, Strategy const& strategy) { - auto const end = boost::end(interior_rings); - return std::find_if(boost::begin(interior_rings), end, - [&](auto const& r) - { - return ! is_simple_ring(r, strategy); - }) == end; // non-simple ring not found + return std::all_of(boost::begin(interior_rings), + boost::end(interior_rings), + [&](auto const& r) + { + return is_simple_ring(r, strategy); + }); // non-simple ring not found // allow empty ring } @@ -116,12 +116,11 @@ struct is_simple template static inline bool apply(MultiPolygon const& multipolygon, Strategy const& strategy) { - auto const end = boost::end(multipolygon); - return std::find_if(boost::begin(multipolygon), end, - [&](auto const& po) { - return ! detail::is_simple::is_simple_polygon(po, strategy); - }) == end; // non-simple polygon not found - // allow empty multi-polygon + return std::none_of(boost::begin(multipolygon), boost::end(multipolygon), + [&](auto const& po) { + return ! detail::is_simple::is_simple_polygon(po, strategy); + }); // non-simple polygon not found + // allow empty multi-polygon } }; diff --git a/include/boost/geometry/algorithms/detail/is_simple/linear.hpp b/include/boost/geometry/algorithms/detail/is_simple/linear.hpp index 090824c25..d8cdc66b9 100644 --- a/include/boost/geometry/algorithms/detail/is_simple/linear.hpp +++ b/include/boost/geometry/algorithms/detail/is_simple/linear.hpp @@ -2,6 +2,7 @@ // Copyright (c) 2014-2021, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -36,7 +37,6 @@ #include #include -#include #include #include @@ -261,16 +261,16 @@ struct is_simple_multilinestring { private: template - struct per_linestring + struct not_simple { - per_linestring(Strategy const& strategy) + not_simple(Strategy const& strategy) : m_strategy(strategy) {} template - inline bool apply(Linestring const& linestring) const + inline bool operator()(Linestring const& linestring) const { - return detail::is_simple::is_simple_linestring + return ! detail::is_simple::is_simple_linestring < Linestring, false // do not compute self-intersections @@ -285,19 +285,16 @@ public: static inline bool apply(MultiLinestring const& multilinestring, Strategy const& strategy) { - typedef per_linestring per_ls; - // check each of the linestrings for simplicity // but do not compute self-intersections yet; these will be // computed for the entire multilinestring - if ( ! detail::check_iterator_range - < - per_ls, // do not compute self-intersections - true // allow empty multilinestring - >::apply(boost::begin(multilinestring), - boost::end(multilinestring), - per_ls(strategy)) - ) + // return true for empty multilinestring + + using not_simple = not_simple; // do not compute self-intersections + + if (std::any_of(boost::begin(multilinestring), + boost::end(multilinestring), + not_simple(strategy))) { return false; } diff --git a/include/boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp b/include/boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp index ce0853d20..72649d0b8 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp @@ -1,7 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -14,7 +15,6 @@ #include #include -#include #include #include @@ -80,26 +80,19 @@ struct indexed_has_invalid_coordinate struct range_has_invalid_coordinate { - struct point_has_valid_coordinates - { - template - static inline bool apply(Point const& point) - { - return ! point_has_invalid_coordinate::apply(point); - } - }; - template static inline bool apply(Geometry const& geometry, VisitPolicy& visitor) { boost::ignore_unused(visitor); - bool const has_valid_coordinates = detail::check_iterator_range - < - point_has_valid_coordinates, - true // do not consider an empty range as problematic - >::apply(geometry::points_begin(geometry), - geometry::points_end(geometry)); + auto const points_end = geometry::points_end(geometry); + bool const has_valid_coordinates = std::none_of + ( + geometry::points_begin(geometry), points_end, + []( auto const& point ){ + return point_has_invalid_coordinate::apply(point); + } + ); return has_valid_coordinates ? diff --git a/include/boost/geometry/algorithms/detail/is_valid/linear.hpp b/include/boost/geometry/algorithms/detail/is_valid/linear.hpp index 69cb76e5d..c407c72dc 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/linear.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/linear.hpp @@ -2,6 +2,7 @@ // Copyright (c) 2014-2021, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -20,7 +21,6 @@ #include #include -#include #include #include #include @@ -131,7 +131,6 @@ class is_valid MultiLinestring, multi_linestring_tag, AllowEmptyMultiGeometries > { -private: template struct per_linestring { @@ -141,7 +140,7 @@ private: {} template - inline bool apply(Linestring const& linestring) const + inline bool operator()(Linestring const& linestring) const { return detail::is_valid::is_valid_linestring < @@ -165,15 +164,11 @@ public: return visitor.template apply(); } - typedef per_linestring per_ls; + using per_ls = per_linestring; - return detail::check_iterator_range - < - per_ls, - false // do not check for empty multilinestring (done above) - >::apply(boost::begin(multilinestring), - boost::end(multilinestring), - per_ls(visitor, strategy)); + return std::all_of(boost::begin(multilinestring), + boost::end(multilinestring), + per_ls(visitor, strategy)); } }; diff --git a/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp b/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp index 0b3b4c4a7..2a8b3fd0d 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp @@ -1,7 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -34,7 +35,6 @@ #include #include -#include #include #include @@ -257,29 +257,30 @@ private: template - struct per_polygon + struct is_invalid_polygon { - per_polygon(VisitPolicy& policy, Strategy const& strategy) + is_invalid_polygon(VisitPolicy& policy, Strategy const& strategy) : m_policy(policy) , m_strategy(strategy) {} template - inline bool apply(Polygon const& polygon) const + inline bool operator()(Polygon const& polygon) const { - return base::apply(polygon, m_policy, m_strategy); + return ! base::apply(polygon, m_policy, m_strategy); } VisitPolicy& m_policy; Strategy const& m_strategy; }; + public: template static inline bool apply(MultiPolygon const& multipolygon, VisitPolicy& visitor, Strategy const& strategy) { - typedef debug_validity_phase debug_phase; + using debug_phase = debug_validity_phase; if (BOOST_GEOMETRY_CONDITION(AllowEmptyMultiGeometries) && boost::empty(multipolygon)) @@ -290,22 +291,20 @@ public: // check validity of all polygons ring debug_phase::apply(1); - if (! detail::check_iterator_range - < - per_polygon, - false // do not check for empty multipolygon (done above) - >::apply(boost::begin(multipolygon), - boost::end(multipolygon), - per_polygon(visitor, strategy))) + if (std::any_of(boost::begin(multipolygon), boost::end(multipolygon), + is_invalid_polygon(visitor, strategy))) { return false; } - // compute turns and check if all are acceptable debug_phase::apply(2); - typedef has_valid_self_turns has_valid_turns; + using has_valid_turns = has_valid_self_turns + < + MultiPolygon, + typename Strategy::cs_tag + >; std::deque turns; bool has_invalid_turns = diff --git a/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp b/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp index 72ae593f8..2a3c4d9aa 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp @@ -2,8 +2,9 @@ // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -50,7 +51,6 @@ #include #include -#include #include #include @@ -86,17 +86,17 @@ class is_valid_polygon protected: template - struct per_ring + struct is_invalid_ring { - per_ring(VisitPolicy& policy, Strategy const& strategy) + is_invalid_ring(VisitPolicy& policy, Strategy const& strategy) : m_policy(policy) , m_strategy(strategy) {} template - inline bool apply(Ring const& ring) const + inline bool operator()(Ring const& ring) const { - return detail::is_valid::is_valid_ring + return ! detail::is_valid::is_valid_ring < Ring, false, true >::apply(ring, m_policy, m_strategy); @@ -111,14 +111,9 @@ protected: VisitPolicy& visitor, Strategy const& strategy) { - return - detail::check_iterator_range - < - per_ring, - true // allow for empty interior ring range - >::apply(boost::begin(interior_rings), - boost::end(interior_rings), - per_ring(visitor, strategy)); + return std::none_of(boost::begin(interior_rings), + boost::end(interior_rings), + is_invalid_ring(visitor, strategy)); } struct has_valid_rings diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp index 153fb1cf4..635b4a538 100644 --- a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp @@ -2,9 +2,10 @@ // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2014-2020. -// Modifications copyright (c) 2014-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014-2021. +// Modifications copyright (c) 2014-2021 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -25,7 +26,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp b/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp index d584e81e5..383dea5cb 100644 --- a/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp +++ b/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp @@ -298,11 +298,10 @@ public: bool is_outside(TurnInfo const& turn) const { return m_other_entry_points.empty() - || std::find_if(m_other_entry_points.begin(), + || std::none_of(m_other_entry_points.begin(), m_other_entry_points.end(), same_single( - turn.operations[other_op_id].seg_id)) - == m_other_entry_points.end(); + turn.operations[other_op_id].seg_id)); } overlay::operation_type get_exit_operation() const 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 7da7f2be5..57dee8c06 100644 --- a/include/boost/geometry/algorithms/detail/relate/multi_point_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/relate/multi_point_geometry.hpp @@ -94,9 +94,8 @@ struct multi_point_geometry_eb template bool apply(Point const& boundary_point, Strategy const& strategy) { - if ( std::find_if(m_points.begin(), m_points.end(), - find_pred(boundary_point, strategy)) - == m_points.end() ) + if ( std::none_of(m_points.begin(), m_points.end(), + find_pred(boundary_point, strategy))) { m_boundary_found = true; return false; diff --git a/include/boost/geometry/algorithms/is_empty.hpp b/include/boost/geometry/algorithms/is_empty.hpp index 52c308214..ddc16430e 100644 --- a/include/boost/geometry/algorithms/is_empty.hpp +++ b/include/boost/geometry/algorithms/is_empty.hpp @@ -2,6 +2,7 @@ // Copyright (c) 2015-2021, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -16,7 +17,6 @@ #include #include -#include #include #include @@ -62,10 +62,8 @@ class polygon_is_empty template static inline bool check_interior_rings(InteriorRings const& interior_rings) { - return check_iterator_range - < - range_is_empty, true // allow empty range - >::apply(boost::begin(interior_rings), boost::end(interior_rings)); + return std::all_of(boost::begin(interior_rings), boost::end(interior_rings), + []( auto const& range ){ return boost::empty(range); }); } public: @@ -83,12 +81,10 @@ struct multi_is_empty template static inline bool apply(MultiGeometry const& multigeometry) { - return check_iterator_range - < - Policy, true // allow empty range - >::apply(boost::begin(multigeometry), boost::end(multigeometry)); + return std::all_of(boost::begin(multigeometry), + boost::end(multigeometry), + []( auto const& range ){ return Policy::apply(range); }); } - }; }} // namespace detail::is_empty diff --git a/include/boost/geometry/policies/predicate_based_interrupt_policy.hpp b/include/boost/geometry/policies/predicate_based_interrupt_policy.hpp index 6d3d5be01..5715e9207 100644 --- a/include/boost/geometry/policies/predicate_based_interrupt_policy.hpp +++ b/include/boost/geometry/policies/predicate_based_interrupt_policy.hpp @@ -1,6 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. + +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -13,8 +15,6 @@ #include #include -#include - namespace boost { namespace geometry { @@ -43,12 +43,14 @@ struct stateless_predicate_based_interrupt_policy template inline bool apply(Range const& range) { - // if there is at least one unacceptable turn in the range, return false - has_intersections = !detail::check_iterator_range - < - IsAcceptableTurnPredicate, - AllowEmptyTurnRange - >::apply(boost::begin(range), boost::end(range)); + // if there is at least one unacceptable turn in the range, return true + bool const has_unacceptable_turn = std::any_of(boost::begin(range), boost::end(range), + [](auto const& turn) { + return ! IsAcceptableTurnPredicate::apply(turn); + }); + + has_intersections = has_unacceptable_turn + && !(AllowEmptyTurnRange && boost::empty(range)); return has_intersections; } @@ -78,12 +80,15 @@ struct predicate_based_interrupt_policy template inline bool apply(Range const& range) { - // if there is at least one unacceptable turn in the range, return false - has_intersections = !detail::check_iterator_range - < - IsAcceptableTurnPredicate, - AllowEmptyTurnRange - >::apply(boost::begin(range), boost::end(range), m_predicate); + // if there is at least one unacceptable turn in the range, return true + bool const has_unacceptable_turn = std::any_of(boost::begin(range), + boost::end(range), + [&]( auto const& turn ) { + return ! m_predicate.apply(turn); + }); + + has_intersections = has_unacceptable_turn + && !(AllowEmptyTurnRange && boost::empty(range)); return has_intersections; } diff --git a/test/algorithms/test_is_valid.hpp b/test/algorithms/test_is_valid.hpp index 0b5f2aed5..8756ccf4d 100644 --- a/test/algorithms/test_is_valid.hpp +++ b/test/algorithms/test_is_valid.hpp @@ -1,8 +1,9 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -49,8 +50,6 @@ #include #include -#include - #include #ifdef BOOST_GEOMETRY_TEST_DEBUG @@ -98,17 +97,17 @@ struct is_convertible_to_closed template struct is_convertible_to_closed { - typedef typename bg::ring_type::type ring_type; + using ring_type = typename bg::ring_type::type; template static inline bool apply_to_interior_rings(InteriorRings const& interior_rings) { - return bg::detail::check_iterator_range - < - is_convertible_to_closed - >::apply(boost::begin(interior_rings), - boost::end(interior_rings)); + return std::all_of(boost::begin(interior_rings), + boost::end(interior_rings), + []( auto const& ring ){ + return is_convertible_to_closed::apply(ring); + }); } static inline bool apply(Polygon const& polygon) @@ -121,16 +120,15 @@ struct is_convertible_to_closed template struct is_convertible_to_closed { - typedef typename boost::range_value::type polygon; + using polygon_type = typename boost::range_value::type; static inline bool apply(MultiPolygon const& multi_polygon) { - return bg::detail::check_iterator_range - < - is_convertible_to_closed, - false // do not allow empty multi-polygon - >::apply(boost::begin(multi_polygon), - boost::end(multi_polygon)); + return !boost::empty(multi_polygon) && // do not allow empty multi-polygon + std::none_of(boost::begin(multi_polygon), boost::end(multi_polygon), + []( auto const& polygon ){ + return ! is_convertible_to_closed::apply(polygon); + }); } };