8 #ifndef BOOST_GIL_POSITION_ITERATOR_HPP
9 #define BOOST_GIL_POSITION_ITERATOR_HPP
11 #include <boost/gil/locator.hpp>
13 #include <boost/iterator/iterator_facade.hpp>
15 #include <type_traits>
17 namespace boost {
namespace gil {
30 template <
typename Deref,
int Dim>
32 typename Deref::value_type,
33 std::random_access_iterator_tag,
34 typename Deref::reference,
35 typename Deref::argument_type::template axis<Dim>::coord_t> {
36 using parent_t = iterator_facade<position_iterator<Deref,Dim>,
37 typename Deref::value_type,
38 std::random_access_iterator_tag,
39 typename Deref::reference,
40 typename Deref::argument_type::template axis<Dim>::coord_t>;
41 using difference_type =
typename parent_t::difference_type;
42 using reference =
typename parent_t::reference;
43 using point_t =
typename Deref::argument_type;
46 position_iterator(point_t
const& p, point_t
const& step, Deref
const& d) : _p(p), _step(step), _d(d) {}
61 auto pos()
const -> point_t
const& {
return _p; }
62 auto step()
const -> point_t
const& {
return _step; }
63 auto deref_fn()
const -> Deref
const& {
return _d; }
65 void set_step(difference_type s) { _step[Dim]=s; }
80 friend class boost::iterator_core_access;
81 reference dereference()
const {
return _d(_p); }
82 void increment() { _p[Dim]+=_step[Dim]; }
83 void decrement() { _p[Dim]-=_step[Dim]; }
84 void advance(difference_type d) { _p[Dim]+=d*_step[Dim]; }
86 difference_type distance_to(
const position_iterator& it)
const {
return (it._p[Dim]-_p[Dim])/_step[Dim]; }
87 bool equal(
const position_iterator& it)
const {
return _p==it._p; }
90 template <
typename Deref,
int Dim>
91 struct const_iterator_type<position_iterator<Deref,Dim> > {
92 using type = position_iterator<typename Deref::const_t,Dim>;
95 template <
typename Deref,
int Dim>
96 struct iterator_is_mutable<position_iterator<Deref, Dim>>
97 : std::integral_constant<bool, Deref::is_mutable>
105 template <
typename Deref,
int Dim>
106 struct color_space_type<position_iterator<Deref,Dim> > :
public color_space_type<typename Deref::value_type> {};
108 template <
typename Deref,
int Dim>
109 struct channel_mapping_type<position_iterator<Deref,Dim> > :
public channel_mapping_type<typename Deref::value_type> {};
111 template <
typename Deref,
int Dim>
112 struct is_planar<position_iterator<Deref, Dim>> : std::false_type {};
114 template <
typename Deref,
int Dim>
115 struct channel_type<position_iterator<Deref,Dim> > :
public channel_type<typename Deref::value_type> {};
121 template <
typename Deref,
int Dim>
122 struct dynamic_x_step_type<position_iterator<Deref,Dim> > {
123 using type = position_iterator<Deref,Dim>;
BOOST_FORCEINLINE bool equal(boost::gil::iterator_from_2d< Loc1 > first, boost::gil::iterator_from_2d< Loc1 > last, boost::gil::iterator_from_2d< Loc2 > first2)
std::equal(I1,I1,I2) with I1 and I2 being a iterator_from_2d
Definition: algorithm.hpp:1087
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36
An iterator that remembers its current X,Y position and invokes a function object with it upon derefe...
Definition: position_iterator.hpp:35
auto operator[](difference_type d) const -> reference
Definition: position_iterator.hpp:68