identity_view.hpp 1.9 KB

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