]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. | |
4 | // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
5 | // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. | |
6 | ||
20effc67 TL |
7 | // This file was modified by Oracle on 2020. |
8 | // Modifications copyright (c) 2020 Oracle and/or its affiliates. | |
9 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
10 | ||
7c673cae FG |
11 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library |
12 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
13 | ||
14 | // Use, modification and distribution is subject to the Boost Software License, | |
15 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
16 | // http://www.boost.org/LICENSE_1_0.txt) | |
17 | ||
18 | #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP | |
19 | #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP | |
20 | ||
21 | #include <cstddef> | |
20effc67 | 22 | #include <type_traits> |
7c673cae FG |
23 | |
24 | #include <boost/geometry/core/access.hpp> | |
25 | #include <boost/geometry/core/cs.hpp> | |
26 | #include <boost/geometry/core/coordinate_dimension.hpp> | |
27 | #include <boost/geometry/core/coordinate_type.hpp> | |
28 | #include <boost/geometry/core/tags.hpp> | |
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 c-array is arithmetic | |
46 | template <bool> | |
47 | struct c_array_tag | |
48 | { | |
49 | typedef geometry_not_recognized_tag type; | |
50 | }; | |
51 | ||
52 | ||
53 | template <> | |
54 | struct c_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<CoordinateType[DimensionCount]> | |
20effc67 | 67 | : detail::c_array_tag<std::is_arithmetic<CoordinateType>::value> {}; |
7c673cae FG |
68 | |
69 | ||
70 | template <typename CoordinateType, std::size_t DimensionCount> | |
71 | struct coordinate_type<CoordinateType[DimensionCount]> | |
72 | { | |
73 | typedef CoordinateType type; | |
74 | }; | |
75 | ||
76 | ||
77 | template <typename CoordinateType, std::size_t DimensionCount> | |
20effc67 TL |
78 | struct dimension<CoordinateType[DimensionCount]> |
79 | : std::integral_constant<std::size_t, DimensionCount> | |
80 | {}; | |
7c673cae FG |
81 | |
82 | ||
83 | template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension> | |
84 | struct access<CoordinateType[DimensionCount], Dimension> | |
85 | { | |
86 | static inline CoordinateType get(CoordinateType const p[DimensionCount]) | |
87 | { | |
88 | return p[Dimension]; | |
89 | } | |
90 | ||
91 | static inline void set(CoordinateType p[DimensionCount], | |
92 | CoordinateType const& value) | |
93 | { | |
94 | p[Dimension] = value; | |
95 | } | |
96 | }; | |
97 | ||
98 | ||
99 | } // namespace traits | |
100 | #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS | |
101 | ||
102 | ||
103 | }} // namespace boost::geometry | |
104 | ||
105 | ||
106 | #define BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(CoordinateSystem) \ | |
107 | namespace boost { namespace geometry { namespace traits { \ | |
108 | template <typename T, std::size_t N> \ | |
109 | struct coordinate_system<T[N]> \ | |
110 | { \ | |
111 | typedef CoordinateSystem type; \ | |
112 | }; \ | |
113 | }}} | |
114 | ||
115 | ||
116 | #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP |