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 namespace boost {
namespace gil {
25 template <
typename Deref,
28 typename Deref::value_type,
29 std::random_access_iterator_tag,
30 typename Deref::reference,
31 typename Deref::argument_type::template axis<Dim>::coord_t> {
32 using parent_t = iterator_facade<position_iterator<Deref,Dim>,
33 typename Deref::value_type,
34 std::random_access_iterator_tag,
35 typename Deref::reference,
36 typename Deref::argument_type::template axis<Dim>::coord_t>;
37 using difference_type =
typename parent_t::difference_type;
38 using reference =
typename parent_t::reference;
39 using point_t =
typename Deref::argument_type;
42 position_iterator(
const point_t& p,
const point_t& step,
const Deref& d) : _p(p), _step(step), _d(d) {}
48 const point_t& pos()
const {
return _p; }
49 const point_t& step()
const {
return _step; }
50 const Deref& deref_fn()
const {
return _d; }
52 void set_step(difference_type s) { _step[Dim]=s; }
55 reference
operator[](difference_type d)
const { point_t p=_p; p[Dim]+=d*_step[Dim];
return _d(p); }
62 friend class boost::iterator_core_access;
63 reference dereference()
const {
return _d(_p); }
64 void increment() { _p[Dim]+=_step[Dim]; }
65 void decrement() { _p[Dim]-=_step[Dim]; }
66 void advance(difference_type d) { _p[Dim]+=d*_step[Dim]; }
68 difference_type distance_to(
const position_iterator& it)
const {
return (it._p[Dim]-_p[Dim])/_step[Dim]; }
72 template <
typename Deref,
int Dim>
77 template <
typename Deref,
int Dim>
78 struct iterator_is_mutable<position_iterator<Deref,Dim> > :
public mpl::bool_<Deref::is_mutable> {
85 template <
typename Deref,
int Dim>
86 struct color_space_type<position_iterator<Deref,Dim> > :
public color_space_type<typename Deref::value_type> {};
88 template <
typename Deref,
int Dim>
89 struct channel_mapping_type<position_iterator<Deref,Dim> > :
public channel_mapping_type<typename Deref::value_type> {};
91 template <
typename Deref,
int Dim>
92 struct is_planar<position_iterator<Deref,Dim> > :
public mpl::false_ {};
94 template <
typename Deref,
int Dim>
101 template <
typename Deref,
int Dim>
Definition: algorithm.hpp:30
An iterator that remembers its current X,Y position and invokes a function object with it upon derefe...
Definition: position_iterator.hpp:27
reference operator[](difference_type d) const
Definition: position_iterator.hpp:55
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:929
Definition: color_convert.hpp:30
Metafunction predicate returning whether the given iterator allows for changing its values...
Definition: pixel_iterator.hpp:48
Returns the type of an iterator just like the input iterator, except operating over immutable values...
Definition: pixel_iterator.hpp:39
Base template for types that model HasDynamicXStepTypeConcept.
Definition: dynamic_step.hpp:17