1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
14 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
15 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
19 #include <boost/type_traits/is_arithmetic.hpp>
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>
27 namespace boost { namespace geometry
31 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
36 #ifndef DOXYGEN_NO_DETAIL
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
46 typedef geometry_not_recognized_tag type;
51 struct c_array_tag<true>
53 typedef point_tag type;
58 #endif // DOXYGEN_NO_DETAIL
61 // Assign the point-tag, preventing arrays of points getting a point-tag
62 template <typename CoordinateType, std::size_t DimensionCount>
63 struct tag<CoordinateType[DimensionCount]>
64 : detail::c_array_tag<boost::is_arithmetic<CoordinateType>::value> {};
67 template <typename CoordinateType, std::size_t DimensionCount>
68 struct coordinate_type<CoordinateType[DimensionCount]>
70 typedef CoordinateType type;
74 template <typename CoordinateType, std::size_t DimensionCount>
75 struct dimension<CoordinateType[DimensionCount]>: boost::mpl::int_<DimensionCount> {};
78 template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
79 struct access<CoordinateType[DimensionCount], Dimension>
81 static inline CoordinateType get(CoordinateType const p[DimensionCount])
86 static inline void set(CoordinateType p[DimensionCount],
87 CoordinateType const& value)
95 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
98 }} // namespace boost::geometry
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]> \
106 typedef CoordinateSystem type; \
111 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP