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
7// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
9
10// Use, modification and distribution is subject to the Boost Software License,
11// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12// http://www.boost.org/LICENSE_1_0.txt)
13
14#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
15#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
16
17#include <cstddef>
18
19#include <boost/type_traits/is_arithmetic.hpp>
20
21#include <boost/geometry/core/access.hpp>
22#include <boost/geometry/core/cs.hpp>
23#include <boost/geometry/core/coordinate_dimension.hpp>
24#include <boost/geometry/core/coordinate_type.hpp>
25#include <boost/geometry/core/tags.hpp>
26
27namespace boost { namespace geometry
28{
29
30
31#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
32namespace traits
33{
34
35
36#ifndef DOXYGEN_NO_DETAIL
37namespace detail
38{
39
40
41// Create class and specialization to indicate the tag
42// for normal cases and the case that the type of the c-array is arithmetic
43template <bool>
44struct c_array_tag
45{
46 typedef geometry_not_recognized_tag type;
47};
48
49
50template <>
51struct c_array_tag<true>
52{
53 typedef point_tag type;
54};
55
56
57} // namespace detail
58#endif // DOXYGEN_NO_DETAIL
59
60
61// Assign the point-tag, preventing arrays of points getting a point-tag
62template <typename CoordinateType, std::size_t DimensionCount>
63struct tag<CoordinateType[DimensionCount]>
64 : detail::c_array_tag<boost::is_arithmetic<CoordinateType>::value> {};
65
66
67template <typename CoordinateType, std::size_t DimensionCount>
68struct coordinate_type<CoordinateType[DimensionCount]>
69{
70 typedef CoordinateType type;
71};
72
73
74template <typename CoordinateType, std::size_t DimensionCount>
75struct dimension<CoordinateType[DimensionCount]>: boost::mpl::int_<DimensionCount> {};
76
77
78template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
79struct access<CoordinateType[DimensionCount], Dimension>
80{
81 static inline CoordinateType get(CoordinateType const p[DimensionCount])
82 {
83 return p[Dimension];
84 }
85
86 static inline void set(CoordinateType p[DimensionCount],
87 CoordinateType const& value)
88 {
89 p[Dimension] = value;
90 }
91};
92
93
94} // namespace traits
95#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
96
97
98}} // namespace boost::geometry
99
100
101#define BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(CoordinateSystem) \
102 namespace boost { namespace geometry { namespace traits { \
103 template <typename T, std::size_t N> \
104 struct coordinate_system<T[N]> \
105 { \
106 typedef CoordinateSystem type; \
107 }; \
108 }}}
109
110
111#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
112

source code of boost/boost/geometry/geometries/adapted/c_array.hpp