reversible_view.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. // 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_VIEWS_REVERSIBLE_VIEW_HPP
  11. #define BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
  12. #include <boost/version.hpp>
  13. #include <boost/range.hpp>
  14. #include <boost/range/adaptor/reversed.hpp>
  15. #include <boost/geometry/core/ring_type.hpp>
  16. #include <boost/geometry/core/tag.hpp>
  17. #include <boost/geometry/core/tags.hpp>
  18. #include <boost/geometry/views/identity_view.hpp>
  19. namespace boost { namespace geometry
  20. {
  21. /*!
  22. \brief Flag for iterating a reversible_view in forward or reverse direction
  23. \ingroup views
  24. */
  25. enum iterate_direction { iterate_forward, iterate_reverse };
  26. /*!
  27. \brief View on a range, reversing direction if necessary
  28. \tparam Range original range
  29. \tparam Direction direction of iteration
  30. \ingroup views
  31. */
  32. template <typename Range, iterate_direction Direction>
  33. struct reversible_view {};
  34. #ifndef DOXYGEN_NO_SPECIALIZATIONS
  35. template <typename Range>
  36. struct reversible_view<Range, iterate_forward>
  37. {
  38. typedef identity_view<Range> type;
  39. };
  40. template <typename Range>
  41. struct reversible_view<Range, iterate_reverse>
  42. {
  43. #if BOOST_VERSION > 104500
  44. typedef boost::reversed_range<Range> type;
  45. #else
  46. // For older versions of Boost
  47. typedef boost::range_detail::reverse_range<Range> type;
  48. #endif
  49. };
  50. #endif // DOXYGEN_NO_SPECIALIZATIONS
  51. }} // namespace boost::geometry
  52. #endif // BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP