Merge pull request #239 from sdebionne/fix/iterators

Fix point_iterator with raw pointer base
This commit is contained in:
Adam Wulkiewicz 2015-03-06 06:17:08 +01:00
commit 2e18afacce
2 changed files with 13 additions and 54 deletions

View File

@ -11,6 +11,7 @@
#define BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP
#include <boost/assert.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/range.hpp>
@ -245,33 +246,26 @@ struct points_end<MultiPolygon, multi_polygon_tag>
// MK:: need to add doc here
template <typename Geometry>
class point_iterator
: public detail::point_iterator::iterator_type<Geometry>::type
: public boost::iterator_adaptor
<
point_iterator<Geometry>,
typename detail::point_iterator::iterator_type<Geometry>::type
>
{
private:
typedef typename detail::point_iterator::iterator_type<Geometry>::type base;
inline base* base_ptr()
{
return this;
}
inline base const* base_ptr() const
{
return this;
}
template <typename OtherGeometry> friend class point_iterator;
template <typename G> friend inline point_iterator<G> points_begin(G&);
template <typename G> friend inline point_iterator<G> points_end(G&);
inline point_iterator(base const& base_it) : base(base_it) {}
inline point_iterator(typename point_iterator::base_type& base_it)
: point_iterator::iterator_adaptor_(base_it) {}
public:
inline point_iterator() {}
template <typename OtherGeometry>
inline point_iterator(point_iterator<OtherGeometry> const& other)
: base(*other.base_ptr())
: point_iterator::iterator_adaptor_(other.base())
{
static const bool is_conv
= boost::is_convertible<
@ -289,32 +283,6 @@ public:
NOT_CONVERTIBLE,
(point_iterator<OtherGeometry>));
}
inline point_iterator& operator++() // prefix
{
base::operator++();
return *this;
}
inline point_iterator& operator--() // prefix
{
base::operator--();
return *this;
}
inline point_iterator operator++(int) // postfix
{
point_iterator copy(*this);
base::operator++();
return copy;
}
inline point_iterator operator--(int) // postfix
{
point_iterator copy(*this);
base::operator--();
return copy;
}
};

View File

@ -27,17 +27,7 @@ class point_reverse_iterator
: public std::reverse_iterator<point_iterator<Geometry> >
{
private:
typedef std::reverse_iterator<point_iterator<Geometry> > base;
inline base* base_ptr()
{
return this;
}
inline base const* base_ptr() const
{
return this;
}
typedef std::reverse_iterator<point_iterator<Geometry> > base_type;
template <typename OtherGeometry> friend class point_reverse_iterator;
template <typename G>
@ -46,7 +36,8 @@ private:
template <typename G>
friend inline point_reverse_iterator<G> points_rend(G&);
inline point_reverse_iterator(base const& base_it) : base(base_it) {}
inline point_reverse_iterator(base_type const& base_it)
: base_type(base_it) {}
public:
inline point_reverse_iterator() {}
@ -54,7 +45,7 @@ public:
template <typename OtherGeometry>
inline
point_reverse_iterator(point_reverse_iterator<OtherGeometry> const& other)
: base(*other.base_ptr())
: base_type(other.base())
{
static const bool is_conv = boost::is_convertible
<