summaryrefslogtreecommitdiff
path: root/boost/geometry/policies/predicate_based_interrupt_policy.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/policies/predicate_based_interrupt_policy.hpp')
-rw-r--r--boost/geometry/policies/predicate_based_interrupt_policy.hpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/boost/geometry/policies/predicate_based_interrupt_policy.hpp b/boost/geometry/policies/predicate_based_interrupt_policy.hpp
index 6d3d5be016..79f420790e 100644
--- a/boost/geometry/policies/predicate_based_interrupt_policy.hpp
+++ b/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-2023, 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
@@ -10,11 +12,12 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
#define BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP
+#include <algorithm>
+
#include <boost/range/begin.hpp>
+#include <boost/range/empty.hpp>
#include <boost/range/end.hpp>
-#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
-
namespace boost { namespace geometry
{
@@ -43,12 +46,14 @@ struct stateless_predicate_based_interrupt_policy
template <typename Range>
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 +83,15 @@ struct predicate_based_interrupt_policy
template <typename Range>
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;
}