]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/util/has_nan_coordinate.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / util / has_nan_coordinate.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2015-2020 Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
11
12 #ifndef BOOST_GEOMETRY_UTIL_HAS_NAN_COORDINATE_HPP
13 #define BOOST_GEOMETRY_UTIL_HAS_NAN_COORDINATE_HPP
14
15 #include <cstddef>
16 #include <type_traits>
17
18 #include <boost/geometry/core/access.hpp>
19 #include <boost/geometry/core/coordinate_dimension.hpp>
20 #include <boost/geometry/core/coordinate_type.hpp>
21
22 #include <boost/math/special_functions/fpclassify.hpp>
23
24
25 namespace boost { namespace geometry
26 {
27
28 #ifndef DOXYGEN_NO_DETAIL
29 namespace detail
30 {
31
32 struct isnan
33 {
34 template <typename T>
35 static inline bool apply(T const& t)
36 {
37 return boost::math::isnan(t);
38 }
39 };
40
41 template
42 <
43 typename Point,
44 typename Predicate,
45 bool Enable,
46 std::size_t I = 0,
47 std::size_t N = geometry::dimension<Point>::value
48 >
49 struct has_coordinate_with_property
50 {
51 static bool apply(Point const& point)
52 {
53 return Predicate::apply(geometry::get<I>(point))
54 || has_coordinate_with_property
55 <
56 Point, Predicate, Enable, I+1, N
57 >::apply(point);
58 }
59 };
60
61 template <typename Point, typename Predicate, std::size_t I, std::size_t N>
62 struct has_coordinate_with_property<Point, Predicate, false, I, N>
63 {
64 static inline bool apply(Point const&)
65 {
66 return false;
67 }
68 };
69
70 template <typename Point, typename Predicate, std::size_t N>
71 struct has_coordinate_with_property<Point, Predicate, true, N, N>
72 {
73 static bool apply(Point const& )
74 {
75 return false;
76 }
77 };
78
79 } // namespace detail
80 #endif // DOXYGEN_NO_DETAIL
81
82 template <typename Point>
83 bool has_nan_coordinate(Point const& point)
84 {
85 return detail::has_coordinate_with_property
86 <
87 Point,
88 detail::isnan,
89 std::is_floating_point
90 <
91 typename coordinate_type<Point>::type
92 >::value
93 >::apply(point);
94 }
95
96 }} // namespace boost::geometry
97
98 #endif // BOOST_GEOMETRY_UTIL_HAS_NAN_COORDINATE_HPP