identity_view.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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-2021.
  6. // Modifications copyright (c) 2020-2021 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_IDENTITY_VIEW_HPP
  14. #define BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP
  15. #include <boost/range/iterator_range.hpp>
  16. #include <boost/range/begin.hpp>
  17. #include <boost/range/end.hpp>
  18. namespace boost { namespace geometry
  19. {
  20. // Silence warning C4512: assignment operator could not be generated
  21. #if defined(_MSC_VER)
  22. #pragma warning(push)
  23. #pragma warning(disable : 4512)
  24. #endif
  25. /*!
  26. \brief View on a range, not modifying anything
  27. \tparam Range original range
  28. \ingroup views
  29. */
  30. template <typename Range>
  31. struct identity_view
  32. {
  33. using const_iterator = typename boost::range_iterator<Range const>::type;
  34. using iterator = typename boost::range_iterator<Range>::type;
  35. explicit inline identity_view(Range& r)
  36. : m_begin(boost::begin(r))
  37. , m_end(boost::end(r))
  38. {}
  39. inline const_iterator begin() const { return m_begin; }
  40. inline const_iterator end() const { return m_end; }
  41. inline iterator begin() { return m_begin; }
  42. inline iterator end() { return m_end; }
  43. private:
  44. iterator m_begin;
  45. iterator m_end;
  46. };
  47. #if defined(_MSC_VER)
  48. #pragma warning(pop)
  49. #endif
  50. }} // namespace boost::geometry
  51. #endif // BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP