reversible_view.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2020.
  6. // Modifications copyright (c) 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_VIEWS_REVERSIBLE_VIEW_HPP
  14. #define BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
  15. #include <boost/version.hpp>
  16. #include <boost/range/adaptor/reversed.hpp>
  17. #include <boost/geometry/core/ring_type.hpp>
  18. #include <boost/geometry/core/tag.hpp>
  19. #include <boost/geometry/core/tags.hpp>
  20. #include <boost/geometry/views/identity_view.hpp>
  21. namespace boost { namespace geometry
  22. {
  23. /*!
  24. \brief Flag for iterating a reversible_view in forward or reverse direction
  25. \ingroup views
  26. */
  27. enum iterate_direction { iterate_forward, iterate_reverse };
  28. /*!
  29. \brief View on a range, reversing direction if necessary
  30. \tparam Range original range
  31. \tparam Direction direction of iteration
  32. \ingroup views
  33. */
  34. template <typename Range, iterate_direction Direction>
  35. struct reversible_view {};
  36. #ifndef DOXYGEN_NO_SPECIALIZATIONS
  37. template <typename Range>
  38. struct reversible_view<Range, iterate_forward>
  39. {
  40. typedef identity_view<Range> type;
  41. };
  42. template <typename Range>
  43. struct reversible_view<Range, iterate_reverse>
  44. {
  45. #if BOOST_VERSION > 104500
  46. typedef boost::reversed_range<Range> type;
  47. #else
  48. // For older versions of Boost
  49. typedef boost::range_detail::reverse_range<Range> type;
  50. #endif
  51. };
  52. #endif // DOXYGEN_NO_SPECIALIZATIONS
  53. }} // namespace boost::geometry
  54. #endif // BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP