]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/geometries/adapted/std_array.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / geometries / adapted / std_array.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2010 Alfredo Correa
4 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2016 Norbert Wenzel
6
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
12 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
13
14
15 #define BOOST_GEOMETRY_ADAPTED_STD_ARRAY_TAG_DEFINED
16
17
18 #include <cstddef>
19
20 #include <boost/type_traits/is_arithmetic.hpp>
21
22 #include <boost/geometry/core/access.hpp>
23 #include <boost/geometry/core/cs.hpp>
24 #include <boost/geometry/core/coordinate_dimension.hpp>
25 #include <boost/geometry/core/coordinate_type.hpp>
26 #include <boost/geometry/core/tags.hpp>
27
28 #include <array>
29
30 namespace boost { namespace geometry
31 {
32
33
34 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
35 namespace traits
36 {
37
38
39 #ifndef DOXYGEN_NO_DETAIL
40 namespace detail
41 {
42
43
44 // Create class and specialization to indicate the tag
45 // for normal cases and the case that the type of the std-array is arithmetic
46 template <bool>
47 struct std_array_tag
48 {
49 typedef geometry_not_recognized_tag type;
50 };
51
52
53 template <>
54 struct std_array_tag<true>
55 {
56 typedef point_tag type;
57 };
58
59
60 } // namespace detail
61 #endif // DOXYGEN_NO_DETAIL
62
63
64 // Assign the point-tag, preventing arrays of points getting a point-tag
65 template <typename CoordinateType, std::size_t DimensionCount>
66 struct tag<std::array<CoordinateType, DimensionCount> >
67 : detail::std_array_tag<boost::is_arithmetic<CoordinateType>::value> {};
68
69
70 template <typename CoordinateType, std::size_t DimensionCount>
71 struct coordinate_type<std::array<CoordinateType, DimensionCount> >
72 {
73 typedef CoordinateType type;
74 };
75
76
77 template <typename CoordinateType, std::size_t DimensionCount>
78 struct dimension<std::array<CoordinateType, DimensionCount> >: boost::mpl::int_<DimensionCount> {};
79
80
81 template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
82 struct access<std::array<CoordinateType, DimensionCount>, Dimension>
83 {
84 static inline CoordinateType get(std::array<CoordinateType, DimensionCount> const& a)
85 {
86 return a[Dimension];
87 }
88
89 static inline void set(std::array<CoordinateType, DimensionCount>& a,
90 CoordinateType const& value)
91 {
92 a[Dimension] = value;
93 }
94 };
95
96
97 } // namespace traits
98 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
99
100
101 }} // namespace boost::geometry
102
103
104 #define BOOST_GEOMETRY_REGISTER_STD_ARRAY_CS(CoordinateSystem) \
105 namespace boost { namespace geometry { namespace traits { \
106 template <class T, std::size_t N> \
107 struct coordinate_system<std::array<T, N> > \
108 { \
109 typedef CoordinateSystem type; \
110 }; \
111 }}}
112
113
114 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
115