point_reverse_iterator.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2014-2021, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Licensed under the Boost Software License version 1.0.
  6. // http://www.boost.org/users/license.html
  7. #ifndef BOOST_GEOMETRY_ITERATORS_POINT_REVERSE_ITERATOR_HPP
  8. #define BOOST_GEOMETRY_ITERATORS_POINT_REVERSE_ITERATOR_HPP
  9. #include <iterator>
  10. #include <type_traits>
  11. #include <boost/geometry/iterators/point_iterator.hpp>
  12. namespace boost { namespace geometry
  13. {
  14. // MK:: need to add doc here
  15. template <typename Geometry>
  16. class point_reverse_iterator
  17. : public std::reverse_iterator<point_iterator<Geometry> >
  18. {
  19. private:
  20. typedef std::reverse_iterator<point_iterator<Geometry> > base_type;
  21. template <typename OtherGeometry> friend class point_reverse_iterator;
  22. template <typename G>
  23. friend inline point_reverse_iterator<G> points_rbegin(G&);
  24. template <typename G>
  25. friend inline point_reverse_iterator<G> points_rend(G&);
  26. inline point_reverse_iterator(base_type const& base_it)
  27. : base_type(base_it) {}
  28. public:
  29. inline point_reverse_iterator() = default;
  30. template
  31. <
  32. typename OtherGeometry,
  33. std::enable_if_t
  34. <
  35. std::is_convertible
  36. <
  37. std::reverse_iterator<point_iterator<OtherGeometry> >,
  38. std::reverse_iterator<point_iterator<Geometry> >
  39. >::value,
  40. int
  41. > = 0
  42. >
  43. inline point_reverse_iterator(point_reverse_iterator<OtherGeometry> const& other)
  44. : base_type(other.base())
  45. {}
  46. };
  47. // MK:: need to add doc here
  48. template <typename Geometry>
  49. inline point_reverse_iterator<Geometry>
  50. points_rbegin(Geometry& geometry)
  51. {
  52. return std::reverse_iterator
  53. <
  54. point_iterator<Geometry>
  55. >(points_end(geometry));
  56. }
  57. // MK:: need to add doc here
  58. template <typename Geometry>
  59. inline point_reverse_iterator<Geometry>
  60. points_rend(Geometry& geometry)
  61. {
  62. return std::reverse_iterator
  63. <
  64. point_iterator<Geometry>
  65. >(points_begin(geometry));
  66. }
  67. }} // namespace boost::geometry
  68. #endif // BOOST_GEOMETRY_ITERATORS_POINT_REVERSE_ITERATOR_HPP