default_policy.hpp 1.5 KB

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