1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2015, Oracle and/or its affiliates.
4 
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6 
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9 
10 #ifndef BOOST_GEOMETRY_POLICIES_IS_VALID_DEFAULT_POLICY_HPP
11 #define BOOST_GEOMETRY_POLICIES_IS_VALID_DEFAULT_POLICY_HPP
12 
13 #include <boost/geometry/algorithms/validity_failure_type.hpp>
14 
15 
16 namespace boost { namespace geometry
17 {
18 
19 
20 template <bool AllowDuplicates = true, bool AllowSpikes = true>
21 class is_valid_default_policy
22 {
23 protected:
is_valid(validity_failure_type failure)24     static inline bool is_valid(validity_failure_type failure)
25     {
26         return failure == no_failure
27             || (AllowDuplicates && failure == failure_duplicate_points);
28     }
29 
is_valid(validity_failure_type failure,bool is_linear)30     static inline bool is_valid(validity_failure_type failure, bool is_linear)
31     {
32         return is_valid(failure)
33             || (is_linear && AllowSpikes && failure == failure_spikes);
34     }
35 
36 public:
37     template <validity_failure_type Failure>
apply()38     static inline bool apply()
39     {
40         return is_valid(Failure);
41     }
42 
43     template <validity_failure_type Failure, typename Data>
apply(Data const &)44     static inline bool apply(Data const&)
45     {
46         return is_valid(Failure);
47     }
48 
49     template <validity_failure_type Failure, typename Data1, typename Data2>
apply(Data1 const & data1,Data2 const &)50     static inline bool apply(Data1 const& data1, Data2 const&)
51     {
52         return is_valid(Failure, data1);
53     }
54 };
55 
56 
57 }} // namespace boost::geometry
58 
59 #endif // BOOST_GEOMETRY_POLICIES_IS_VALID_DEFAULT_POLICY_HPP
60