value_type.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2014-2015, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  4. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_ITERATORS_DETAIL_SEGMENT_ITERATOR_VALUE_TYPE_HPP
  7. #define BOOST_GEOMETRY_ITERATORS_DETAIL_SEGMENT_ITERATOR_VALUE_TYPE_HPP
  8. #include <iterator>
  9. #include <boost/mpl/if.hpp>
  10. #include <boost/type_traits/is_reference.hpp>
  11. #include <boost/geometry/iterators/point_iterator.hpp>
  12. #include <boost/geometry/util/bare_type.hpp>
  13. #include <boost/geometry/geometries/segment.hpp>
  14. #include <boost/geometry/geometries/pointing_segment.hpp>
  15. namespace boost { namespace geometry
  16. {
  17. #ifndef DOXYGEN_NO_DETAIL
  18. namespace detail { namespace segment_iterator
  19. {
  20. template <typename Geometry>
  21. struct value_type
  22. {
  23. typedef typename std::iterator_traits
  24. <
  25. geometry::point_iterator<Geometry>
  26. >::reference point_iterator_reference_type;
  27. typedef typename detail::point_iterator::value_type
  28. <
  29. Geometry
  30. >::type point_iterator_value_type;
  31. // If the reference type of the point iterator is not really a
  32. // reference, then dereferencing a point iterator would create
  33. // a temporary object.
  34. // In this case using a pointing_segment to represent the
  35. // dereferenced value of the segment iterator cannot be used, as
  36. // it would store pointers to temporary objects. Instead we use a
  37. // segment, which does a full copy of the temporary objects
  38. // returned by the point iterator.
  39. typedef typename boost::mpl::if_
  40. <
  41. boost::is_reference<point_iterator_reference_type>,
  42. geometry::model::pointing_segment<point_iterator_value_type>,
  43. geometry::model::segment
  44. <
  45. typename geometry::util::bare_type
  46. <
  47. point_iterator_value_type
  48. >::type
  49. >
  50. >::type type;
  51. };
  52. }} // namespace detail::segment_iterator
  53. #endif // DOXYGEN_NO_DETAIL
  54. }} // namespace boost::geometry
  55. #endif // BOOST_GEOMETRY_ITERATORS_DETAIL_SEGMENT_ITERATOR_VALUE_TYPE_HPP