[point_iterator] add free functions points_front and points_back that return the first and last point of a geometry

This commit is contained in:
Menelaos Karavelas
2014-05-05 09:50:04 +03:00
parent 454ece176a
commit cd1d490d2e

View File

@@ -10,6 +10,7 @@
#ifndef BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP
#define BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP
#include <boost/assert.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/range.hpp>
@@ -280,6 +281,30 @@ points_end(Geometry& geometry)
}
// MK:: need to add doc here
template <typename Geometry>
inline typename point_type<Geometry>::type
points_front(Geometry& geometry)
{
BOOST_ASSERT( dispatch::points_begin<Geometry>::apply(geometry)
!= dispatch::points_end<Geometry>::apply(geometry) );
return *dispatch::points_begin<Geometry>::apply(geometry);
}
// MK:: need to add doc here
template <typename Geometry>
inline typename point_type<Geometry>::type
points_back(Geometry& geometry)
{
BOOST_ASSERT( dispatch::points_begin<Geometry>::apply(geometry)
!= dispatch::points_end<Geometry>::apply(geometry) );
return *--dispatch::points_end<Geometry>::apply(geometry);
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP