File indexing completed on 2025-01-18 09:35:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
0016 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
0017
0018
0019 #include <boost/config.hpp>
0020
0021 #define BOOST_GEOMETRY_ADAPTED_STD_ARRAY_TAG_DEFINED
0022
0023
0024 #include <array>
0025 #include <cstddef>
0026 #include <type_traits>
0027
0028 #include <boost/geometry/core/access.hpp>
0029 #include <boost/geometry/core/cs.hpp>
0030 #include <boost/geometry/core/coordinate_dimension.hpp>
0031 #include <boost/geometry/core/coordinate_type.hpp>
0032 #include <boost/geometry/core/tags.hpp>
0033
0034
0035 namespace boost { namespace geometry
0036 {
0037
0038
0039 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0040 namespace traits
0041 {
0042
0043
0044 #ifndef DOXYGEN_NO_DETAIL
0045 namespace detail
0046 {
0047
0048
0049
0050
0051 template <bool>
0052 struct std_array_tag
0053 {
0054 typedef geometry_not_recognized_tag type;
0055 };
0056
0057
0058 template <>
0059 struct std_array_tag<true>
0060 {
0061 typedef point_tag type;
0062 };
0063
0064
0065 }
0066 #endif
0067
0068
0069
0070 template <typename CoordinateType, std::size_t DimensionCount>
0071 struct tag<std::array<CoordinateType, DimensionCount> >
0072 : detail::std_array_tag<std::is_arithmetic<CoordinateType>::value> {};
0073
0074
0075 template <typename CoordinateType, std::size_t DimensionCount>
0076 struct coordinate_type<std::array<CoordinateType, DimensionCount> >
0077 {
0078 typedef CoordinateType type;
0079 };
0080
0081
0082 template <typename CoordinateType, std::size_t DimensionCount>
0083 struct dimension<std::array<CoordinateType, DimensionCount> >
0084 : std::integral_constant<std::size_t, DimensionCount>
0085 {};
0086
0087
0088 template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
0089 struct access<std::array<CoordinateType, DimensionCount>, Dimension>
0090 {
0091 static inline CoordinateType get(std::array<CoordinateType, DimensionCount> const& a)
0092 {
0093 return a[Dimension];
0094 }
0095
0096 static inline void set(std::array<CoordinateType, DimensionCount>& a,
0097 CoordinateType const& value)
0098 {
0099 a[Dimension] = value;
0100 }
0101 };
0102
0103
0104 }
0105 #endif
0106
0107
0108 }}
0109
0110
0111 #define BOOST_GEOMETRY_REGISTER_STD_ARRAY_CS(CoordinateSystem) \
0112 namespace boost { namespace geometry { namespace traits { \
0113 template <class T, std::size_t N> \
0114 struct coordinate_system<std::array<T, N> > \
0115 { \
0116 typedef CoordinateSystem type; \
0117 }; \
0118 }}}
0119
0120 #endif
0121