boost_tuple.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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.
  6. // Modifications copyright (c) 2018, 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 <boost/tuple/tuple.hpp>
  17. #include <boost/geometry/core/access.hpp>
  18. #include <boost/geometry/core/coordinate_dimension.hpp>
  19. #include <boost/geometry/core/coordinate_type.hpp>
  20. #include <boost/geometry/core/point_type.hpp>
  21. #include <boost/geometry/core/tags.hpp>
  22. namespace boost { namespace geometry
  23. {
  24. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  25. namespace traits
  26. {
  27. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  28. typename T6, typename T7, typename T8, typename T9, typename T10>
  29. struct tag<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
  30. {
  31. typedef point_tag type;
  32. };
  33. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  34. typename T6, typename T7, typename T8, typename T9, typename T10>
  35. struct coordinate_type<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
  36. {
  37. typedef T1 type;
  38. };
  39. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  40. typename T6, typename T7, typename T8, typename T9, typename T10>
  41. struct dimension<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
  42. : boost::mpl::int_
  43. <
  44. boost::tuples::length
  45. <
  46. boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
  47. >::value
  48. >
  49. {};
  50. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  51. typename T6, typename T7, typename T8, typename T9, typename T10,
  52. std::size_t Dimension>
  53. struct access
  54. <
  55. boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>,
  56. Dimension
  57. >
  58. {
  59. static inline T1 get(
  60. boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> const& point)
  61. {
  62. return point.template get<Dimension>();
  63. }
  64. static inline void set(
  65. boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& point,
  66. T1 const& value)
  67. {
  68. point.template get<Dimension>() = value;
  69. }
  70. };
  71. } // namespace traits
  72. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  73. }} // namespace boost::geometry
  74. // Convenience registration macro to bind boost::tuple to a CS
  75. #define BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(CoordinateSystem) \
  76. namespace boost { namespace geometry { namespace traits { \
  77. template <typename T1, typename T2, typename T3, typename T4, typename T5, \
  78. typename T6, typename T7, typename T8, typename T9, typename T10> \
  79. struct coordinate_system<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> > \
  80. { \
  81. typedef CoordinateSystem type; \
  82. }; \
  83. }}}
  84. #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_HPP