identity_view.hpp 1.7 KB

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