File indexing completed on 2025-01-18 09:36:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_GEOMETRY_UTIL_HAS_NAN_COORDINATE_HPP
0013 #define BOOST_GEOMETRY_UTIL_HAS_NAN_COORDINATE_HPP
0014
0015 #include <cstddef>
0016 #include <type_traits>
0017
0018 #include <boost/geometry/core/access.hpp>
0019 #include <boost/geometry/core/coordinate_dimension.hpp>
0020 #include <boost/geometry/core/coordinate_type.hpp>
0021
0022 #include <boost/math/special_functions/fpclassify.hpp>
0023
0024
0025 namespace boost { namespace geometry
0026 {
0027
0028 #ifndef DOXYGEN_NO_DETAIL
0029 namespace detail
0030 {
0031
0032 struct isnan
0033 {
0034 template <typename T>
0035 static inline bool apply(T const& t)
0036 {
0037 return boost::math::isnan(t);
0038 }
0039 };
0040
0041 template
0042 <
0043 typename Point,
0044 typename Predicate,
0045 bool Enable,
0046 std::size_t I = 0,
0047 std::size_t N = geometry::dimension<Point>::value
0048 >
0049 struct has_coordinate_with_property
0050 {
0051 static bool apply(Point const& point)
0052 {
0053 return Predicate::apply(geometry::get<I>(point))
0054 || has_coordinate_with_property
0055 <
0056 Point, Predicate, Enable, I+1, N
0057 >::apply(point);
0058 }
0059 };
0060
0061 template <typename Point, typename Predicate, std::size_t I, std::size_t N>
0062 struct has_coordinate_with_property<Point, Predicate, false, I, N>
0063 {
0064 static inline bool apply(Point const&)
0065 {
0066 return false;
0067 }
0068 };
0069
0070 template <typename Point, typename Predicate, std::size_t N>
0071 struct has_coordinate_with_property<Point, Predicate, true, N, N>
0072 {
0073 static bool apply(Point const& )
0074 {
0075 return false;
0076 }
0077 };
0078
0079 }
0080 #endif
0081
0082 template <typename Point>
0083 bool has_nan_coordinate(Point const& point)
0084 {
0085 return detail::has_coordinate_with_property
0086 <
0087 Point,
0088 detail::isnan,
0089 std::is_floating_point
0090 <
0091 typename coordinate_type<Point>::type
0092 >::value
0093 >::apply(point);
0094 }
0095
0096 }}
0097
0098 #endif