1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2010 Alfredo Correa
4 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2016 Norbert Wenzel
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)
11 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
12 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
15 #define BOOST_GEOMETRY_ADAPTED_STD_ARRAY_TAG_DEFINED
20 #include <boost/type_traits/is_arithmetic.hpp>
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>
30 namespace boost { namespace geometry
34 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
39 #ifndef DOXYGEN_NO_DETAIL
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
49 typedef geometry_not_recognized_tag type;
54 struct std_array_tag<true>
56 typedef point_tag type;
61 #endif // DOXYGEN_NO_DETAIL
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> {};
70 template <typename CoordinateType, std::size_t DimensionCount>
71 struct coordinate_type<std::array<CoordinateType, DimensionCount> >
73 typedef CoordinateType type;
77 template <typename CoordinateType, std::size_t DimensionCount>
78 struct dimension<std::array<CoordinateType, DimensionCount> >: boost::mpl::int_<DimensionCount> {};
81 template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
82 struct access<std::array<CoordinateType, DimensionCount>, Dimension>
84 static inline CoordinateType get(std::array<CoordinateType, DimensionCount> const& a)
89 static inline void set(std::array<CoordinateType, DimensionCount>& a,
90 CoordinateType const& value)
98 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
101 }} // namespace boost::geometry
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> > \
109 typedef CoordinateSystem type; \
114 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP