1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2015, Oracle and/or its affiliates.
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_POLICIES_IS_VALID_DEFAULT_POLICY_HPP
11 #define BOOST_GEOMETRY_POLICIES_IS_VALID_DEFAULT_POLICY_HPP
13 #include <boost/geometry/algorithms/validity_failure_type.hpp>
16 namespace boost { namespace geometry
20 template <bool AllowDuplicates = true, bool AllowSpikes = true>
21 class is_valid_default_policy
24 static inline bool is_valid(validity_failure_type failure)
26 return failure == no_failure
27 || (AllowDuplicates && failure == failure_duplicate_points);
30 static inline bool is_valid(validity_failure_type failure, bool is_linear)
32 return is_valid(failure)
33 || (is_linear && AllowSpikes && failure == failure_spikes);
37 template <validity_failure_type Failure>
38 static inline bool apply()
40 return is_valid(Failure);
43 template <validity_failure_type Failure, typename Data>
44 static inline bool apply(Data const&)
46 return is_valid(Failure);
49 template <validity_failure_type Failure, typename Data1, typename Data2>
50 static inline bool apply(Data1 const& data1, Data2 const&)
52 return is_valid(Failure, data1);
57 }} // namespace boost::geometry
59 #endif // BOOST_GEOMETRY_POLICIES_IS_VALID_DEFAULT_POLICY_HPP