8 #ifndef BOOST_GIL_PIXEL_ITERATOR_ADAPTOR_HPP
9 #define BOOST_GIL_PIXEL_ITERATOR_ADAPTOR_HPP
11 #include <boost/gil/concepts.hpp>
12 #include <boost/gil/pixel_iterator.hpp>
14 #include <boost/iterator/iterator_facade.hpp>
18 namespace boost {
namespace gil {
27 template <
typename Iterator,
31 typename DFn::value_type,
32 typename std::iterator_traits<Iterator>::iterator_category,
33 typename DFn::reference,
37 using parent_t = iterator_adaptor<dereference_iterator_adaptor<Iterator,DFn>,
39 typename DFn::value_type,
40 typename std::iterator_traits<Iterator>::iterator_category,
41 typename DFn::reference,
43 using reference =
typename DFn::result_type;
44 using difference_type =
typename std::iterator_traits<Iterator>::difference_type;
45 using dereference_fn = DFn;
48 template <
typename Iterator1>
51 template <
typename Iterator1,
typename DFn1>
55 reference
operator[](difference_type d)
const {
return *(*
this+d);}
60 bool operator< (
const dereference_iterator_adaptor& p)
const {
return this->base_reference()< p.base_reference(); }
61 bool operator>=(
const dereference_iterator_adaptor& p)
const {
return this->base_reference()>=p.base_reference(); }
62 bool operator<=(
const dereference_iterator_adaptor& p)
const {
return this->base_reference()<=p.base_reference(); }
63 bool operator==(
const dereference_iterator_adaptor& p)
const {
return this->base_reference()==p.base_reference(); }
64 bool operator!=(
const dereference_iterator_adaptor& p)
const {
return this->base_reference()!=p.base_reference(); }
66 Iterator& base() {
return this->base_reference(); }
67 const Iterator& base()
const {
return this->base_reference(); }
68 const DFn& deref_fn()
const {
return _deref_fn; }
70 template <
typename Iterator1,
typename DFn1>
71 friend class dereference_iterator_adaptor;
72 friend class boost::iterator_core_access;
74 reference dereference()
const {
return _deref_fn(*(this->base_reference())); }
77 template <
typename I,
typename DFn>
78 struct const_iterator_type<dereference_iterator_adaptor<I,DFn> > {
79 using type = dereference_iterator_adaptor<typename const_iterator_type<I>::type,
typename DFn::const_t>;
82 template <
typename I,
typename DFn>
83 struct iterator_is_mutable<dereference_iterator_adaptor<I, DFn>>
84 : std::integral_constant<bool, DFn::is_mutable>
88 template <
typename I,
typename DFn>
89 struct is_iterator_adaptor<dereference_iterator_adaptor<I, DFn>> : std::true_type {};
91 template <
typename I,
typename DFn>
92 struct iterator_adaptor_get_base<dereference_iterator_adaptor<I, DFn>>
97 template <
typename I,
typename DFn,
typename NewBaseIterator>
98 struct iterator_adaptor_rebind<dereference_iterator_adaptor<I,DFn>,NewBaseIterator> {
99 using type = dereference_iterator_adaptor<NewBaseIterator,DFn>;
106 template <
typename I,
typename DFn>
107 struct color_space_type<dereference_iterator_adaptor<I,DFn> > :
public color_space_type<typename DFn::value_type> {};
109 template <
typename I,
typename DFn>
110 struct channel_mapping_type<dereference_iterator_adaptor<I,DFn> > :
public channel_mapping_type<typename DFn::value_type> {};
112 template <
typename I,
typename DFn>
113 struct is_planar<dereference_iterator_adaptor<I,DFn> > :
public is_planar<typename DFn::value_type> {};
115 template <
typename I,
typename DFn>
116 struct channel_type<dereference_iterator_adaptor<I,DFn> > :
public channel_type<typename DFn::value_type> {};
123 template <
typename Iterator,
typename DFn>
124 struct byte_to_memunit<dereference_iterator_adaptor<Iterator,DFn>> :
public byte_to_memunit<Iterator> {};
126 template <
typename Iterator,
typename DFn>
127 inline auto memunit_step(dereference_iterator_adaptor<Iterator,DFn>
const& p)
128 ->
typename std::iterator_traits<Iterator>::difference_type
130 return memunit_step(p.base());
133 template <
typename Iterator,
typename DFn>
134 inline auto memunit_distance(dereference_iterator_adaptor<Iterator,DFn>
const& p1,
135 dereference_iterator_adaptor<Iterator,DFn>
const& p2)
136 ->
typename std::iterator_traits<Iterator>::difference_type
138 return memunit_distance(p1.base(),p2.base());
141 template <
typename Iterator,
typename DFn>
142 inline void memunit_advance(dereference_iterator_adaptor<Iterator,DFn>& p,
143 typename std::iterator_traits<Iterator>::difference_type diff) {
144 memunit_advance(p.base(), diff);
147 template <
typename Iterator,
typename DFn>
148 inline auto memunit_advanced(dereference_iterator_adaptor<Iterator,DFn>
const& p,
149 typename std::iterator_traits<Iterator>::difference_type diff)
150 -> dereference_iterator_adaptor<Iterator,DFn>
152 return dereference_iterator_adaptor<Iterator,DFn>(memunit_advanced(p.base(), diff), p.deref_fn());
156 template <
typename Iterator,
typename DFn>
157 inline auto memunit_advanced_ref(dereference_iterator_adaptor<Iterator,DFn>
const& p,
158 typename std::iterator_traits<Iterator>::difference_type diff)
159 ->
typename std::iterator_traits<dereference_iterator_adaptor<Iterator,DFn> >::reference
161 return *memunit_advanced(p, diff);
168 template <
typename Iterator,
typename DFn>
169 struct dynamic_x_step_type<dereference_iterator_adaptor<Iterator,DFn> > {
170 using type = dereference_iterator_adaptor<typename dynamic_x_step_type<Iterator>::type,DFn>;
175 template <
typename Iterator,
typename Deref>
181 static type make(
const Iterator& it,
const Deref& d) {
return type(it,d); }
186 template <
typename Iterator,
typename PREV_DEREF,
typename Deref>
Composes two dereference function objects. Similar to std::unary_compose but needs to pull some alias...
Definition: utilities.hpp:131
An adaptor over an existing iterator that provides for custom filter on dereferencing the object....
Definition: pixel_iterator_adaptor.hpp:34
reference operator[](difference_type d) const
Definition: pixel_iterator_adaptor.hpp:55
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36
Represents a unary function object that can be invoked upon dereferencing a pixel iterator.
Definition: pixel_dereference.hpp:54
Returns the type (and creates an instance) of an iterator that invokes the given dereference adaptor ...
Definition: pixel_iterator_adaptor.hpp:176