1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014-2020, Oracle and/or its affiliates.
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
11 #ifndef BOOST_GEOMETRY_ITERATORS_DETAIL_SEGMENT_ITERATOR_VALUE_TYPE_HPP
12 #define BOOST_GEOMETRY_ITERATORS_DETAIL_SEGMENT_ITERATOR_VALUE_TYPE_HPP
16 #include <boost/geometry/geometries/segment.hpp>
17 #include <boost/geometry/geometries/pointing_segment.hpp>
18 #include <boost/geometry/iterators/point_iterator.hpp>
19 #include <boost/geometry/util/type_traits_std.hpp>
21 namespace boost { namespace geometry
24 #ifndef DOXYGEN_NO_DETAIL
25 namespace detail { namespace segment_iterator
28 template <typename Geometry>
31 typedef typename std::iterator_traits
33 geometry::point_iterator<Geometry>
34 >::reference point_iterator_reference_type;
36 typedef typename detail::point_iterator::value_type
39 >::type point_iterator_value_type;
41 // If the reference type of the point iterator is not really a
42 // reference, then dereferencing a point iterator would create
43 // a temporary object.
44 // In this case using a pointing_segment to represent the
45 // dereferenced value of the segment iterator cannot be used, as
46 // it would store pointers to temporary objects. Instead we use a
47 // segment, which does a full copy of the temporary objects
48 // returned by the point iterator.
49 typedef std::conditional_t
51 std::is_reference<point_iterator_reference_type>::value,
52 geometry::model::pointing_segment<point_iterator_value_type>,
53 geometry::model::segment
55 typename util::remove_cptrref
57 point_iterator_value_type
63 }} // namespace detail::segment_iterator
64 #endif // DOXYGEN_NO_DETAIL
66 }} // namespace boost::geometry
68 #endif // BOOST_GEOMETRY_ITERATORS_DETAIL_SEGMENT_ITERATOR_VALUE_TYPE_HPP