boost_tuple.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  3. // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2018-2020.
  6. // Modifications copyright (c) 2018-2020, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (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)
  13. #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_TUPLE_HPP
  14. #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_TUPLE_HPP
  15. #include <cstddef>
  16. #include <type_traits>
  17. #include <boost/tuple/tuple.hpp>
  18. #include <boost/geometry/core/access.hpp>
  19. #include <boost/geometry/core/coordinate_dimension.hpp>
  20. #include <boost/geometry/core/coordinate_type.hpp>
  21. #include <boost/geometry/core/point_type.hpp>
  22. #include <boost/geometry/core/tags.hpp>
  23. namespace boost { namespace geometry
  24. {
  25. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  26. namespace traits
  27. {
  28. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  29. typename T6, typename T7, typename T8, typename T9, typename T10>
  30. struct tag<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
  31. {
  32. typedef point_tag type;
  33. };
  34. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  35. typename T6, typename T7, typename T8, typename T9, typename T10>
  36. struct coordinate_type<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
  37. {
  38. typedef T1 type;
  39. };
  40. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  41. typename T6, typename T7, typename T8, typename T9, typename T10>
  42. struct dimension<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
  43. : std::integral_constant
  44. <
  45. std::size_t,
  46. boost::tuples::length
  47. <
  48. boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
  49. >::value
  50. >
  51. {};
  52. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  53. typename T6, typename T7, typename T8, typename T9, typename T10,
  54. std::size_t Dimension>
  55. struct access
  56. <
  57. boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>,
  58. Dimension
  59. >
  60. {
  61. static inline T1 get(
  62. boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> const& point)
  63. {
  64. return point.template get<Dimension>();
  65. }
  66. static inline void set(
  67. boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& point,
  68. T1 const& value)
  69. {
  70. point.template get<Dimension>() = value;
  71. }
  72. };
  73. } // namespace traits
  74. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  75. }} // namespace boost::geometry
  76. // Convenience registration macro to bind boost::tuple to a CS
  77. #define BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(CoordinateSystem) \
  78. namespace boost { namespace geometry { namespace traits { \
  79. template <typename T1, typename T2, typename T3, typename T4, typename T5, \
  80. typename T6, typename T7, typename T8, typename T9, typename T10> \
  81. struct coordinate_system<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> > \
  82. { \
  83. typedef CoordinateSystem type; \
  84. }; \
  85. }}}
  86. #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_HPP