Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:27

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2010 Alfredo Correa
0004 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
0005 // Copyright (c) 2016 Norbert Wenzel
0006 
0007 // This file was modified by Oracle on 2020.
0008 // Modifications copyright (c) 2020, Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 
0011 // Use, modification and distribution is subject to the Boost Software License,
0012 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0013 // http://www.boost.org/LICENSE_1_0.txt)
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 // Create class and specialization to indicate the tag
0050 // for normal cases and the case that the type of the std-array is arithmetic
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 } // namespace detail
0066 #endif // DOXYGEN_NO_DETAIL
0067 
0068 
0069 // Assign the point-tag, preventing arrays of points getting a point-tag
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 } // namespace traits
0105 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0106 
0107 
0108 }} // namespace boost::geometry
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 // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
0121