boost_tuple.hpp 3.2 KB

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