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(
const point_t& p,
const point_t& step,
const Deref& d) : _p(p), _step(step), _d(d) {}
52 const point_t& pos()
const {
return _p; }
53 const point_t& step()
const {
return _step; }
54 const Deref& deref_fn()
const {
return _d; }
56 void set_step(difference_type s) { _step[Dim]=s; }
59 reference
operator[](difference_type d)
const { point_t p=_p; p[Dim]+=d*_step[Dim];
return _d(p); }
66 friend class boost::iterator_core_access;
67 reference dereference()
const {
return _d(_p); }
68 void increment() { _p[Dim]+=_step[Dim]; }
69 void decrement() { _p[Dim]-=_step[Dim]; }
70 void advance(difference_type d) { _p[Dim]+=d*_step[Dim]; }
72 difference_type distance_to(
const position_iterator& it)
const {
return (it._p[Dim]-_p[Dim])/_step[Dim]; }
76 template <
typename Deref,
int Dim>
81 template <
typename Deref,
int Dim>
83 : std::integral_constant<bool, Deref::is_mutable>
91 template <
typename Deref,
int Dim>
92 struct color_space_type<position_iterator<Deref,Dim> > :
public color_space_type<typename Deref::value_type> {};
94 template <
typename Deref,
int Dim>
95 struct channel_mapping_type<position_iterator<Deref,Dim> > :
public channel_mapping_type<typename Deref::value_type> {};
97 template <
typename Deref,
int Dim>
98 struct is_planar<position_iterator<Deref, Dim>> : std::false_type {};
100 template <
typename Deref,
int Dim>
107 template <
typename Deref,
int Dim>
reference operator[](difference_type d) const
Definition: position_iterator.hpp:59
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:31
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:1029
Definition: color_convert.hpp:31
Metafunction predicate returning whether the given iterator allows for changing its values...
Definition: pixel_iterator.hpp:49
Returns the type of an iterator just like the input iterator, except operating over immutable values...
Definition: pixel_iterator.hpp:40
Base template for types that model HasDynamicXStepTypeConcept.
Definition: dynamic_step.hpp:17