]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/index/detail/algorithms/is_valid.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / index / detail / algorithms / is_valid.hpp
1 // Boost.Geometry Index
2 //
3 // n-dimensional Indexable validity check
4 //
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
6 //
7 // This file was modified by Oracle on 2020-2021.
8 // Modifications copyright (c) 2020-2021 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10 //
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14
15 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_IS_VALID_HPP
16 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_IS_VALID_HPP
17
18 #include <cstddef>
19
20 #include <boost/geometry/core/access.hpp>
21 #include <boost/geometry/core/coordinate_dimension.hpp>
22 #include <boost/geometry/core/static_assert.hpp>
23
24 namespace boost { namespace geometry { namespace index { namespace detail {
25
26 namespace dispatch {
27
28 template <typename Box,
29 std::size_t Dimension = geometry::dimension<Box>::value>
30 struct is_valid_box
31 {
32 static inline bool apply(Box const& b)
33 {
34 return is_valid_box<Box, Dimension - 1>::apply(b) &&
35 ( get<min_corner, Dimension - 1>(b) <= get<max_corner, Dimension - 1>(b) );
36 }
37 };
38
39 template <typename Box>
40 struct is_valid_box<Box, 1>
41 {
42 static inline bool apply(Box const& b)
43 {
44 return get<min_corner, 0>(b) <= get<max_corner, 0>(b);
45 }
46 };
47
48 template <typename Indexable,
49 typename Tag = typename geometry::tag<Indexable>::type>
50 struct is_valid
51 {
52 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
53 "Not implemented for this Indexable type.",
54 Indexable, Tag);
55 };
56
57 template <typename Indexable>
58 struct is_valid<Indexable, point_tag>
59 {
60 static inline bool apply(Indexable const&)
61 {
62 return true;
63 }
64 };
65
66 template <typename Indexable>
67 struct is_valid<Indexable, box_tag>
68 {
69 static inline bool apply(Indexable const& b)
70 {
71 return dispatch::is_valid_box<Indexable>::apply(b);
72 }
73 };
74
75 template <typename Indexable>
76 struct is_valid<Indexable, segment_tag>
77 {
78 static inline bool apply(Indexable const&)
79 {
80 return true;
81 }
82 };
83
84 } // namespace dispatch
85
86 template <typename Indexable>
87 inline bool is_valid(Indexable const& b)
88 {
89 // CONSIDER: detection of NaNs
90 // e.g. by comparison of b with copy of b
91
92 return dispatch::is_valid<Indexable>::apply(b);
93 }
94
95 }}}} // namespace boost::geometry::index::detail
96
97 #endif // BOOST_GEOMETRY_DETAIL_INDEX_ALGORITHMS_IS_VALID_HPP