DGtal 1.4.0
Loading...
Searching...
No Matches
ConstIteratorAdapter.h
1
17#pragma once
18
31#if defined(ConstIteratorAdapter_RECURSES)
32#error Recursive header files inclusion detected in ConstIteratorAdapter.h
33#else // defined(ConstIteratorAdapter_RECURSES)
35#define ConstIteratorAdapter_RECURSES
36
37#if !defined ConstIteratorAdapter_h
39#define ConstIteratorAdapter_h
40
42// Inclusions
43#include <iostream>
44#include "DGtal/base/Common.h"
45#include "DGtal/base/IteratorCirculatorTraits.h"
46#include <boost/iterator/iterator_adaptor.hpp>
47#include <boost/utility.hpp>
49
50namespace DGtal
51{
52
54 // template class ConstIteratorAdapter
84 template <typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value >
86 : public boost::iterator_adaptor< ConstIteratorAdapter<TIterator,TLightFunctor,TReturnType>,
87 TIterator, TReturnType, boost::use_default, TReturnType >
88 {
89 typedef typename
90 boost::iterator_adaptor< ConstIteratorAdapter<TIterator,TLightFunctor,TReturnType>,
91 TIterator, TReturnType, boost::use_default, TReturnType >
93
95
96 public:
97
99
100
105
112 ConstIteratorAdapter(TIterator const& i, TLightFunctor f)
113 : Super(i), myF(f) { }
114
120 template <
121 class OtherFunctor
122 , class OtherIterator
123 , class OtherReturnType>
129
135 TLightFunctor functor() const
136 { return myF; }
137
138 private:
139
146 typename Super::reference dereference() const
147 { return myF(*this->base()); }
148
150 TLightFunctor myF;
151 };
152
153
154} // namespace DGtal
155
156
158// Includes inline functions.
159//#include "DGtal/base/ConstIteratorAdapter.ih"
160
161// //
163
164#endif // !defined ConstIteratorAdapter_h
165
166#undef ConstIteratorAdapter_RECURSES
167#endif // else defined(ConstIteratorAdapter_RECURSES)
This class adapts any iterator so that operator* returns another element than the one pointed to by t...
ConstIteratorAdapter(ConstIteratorAdapter< OtherFunctor, OtherIterator, OtherReturnType > const &other)
boost::iterator_adaptor< ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >, TIterator, TReturnType, boost::use_default, TReturnType > Super
IteratorCirculatorTraits< TIterator >::Type Type
Super::reference dereference() const
friend class boost::iterator_core_access
ConstIteratorAdapter(TIterator const &i, TLightFunctor f)
DGtal is the top-level namespace which contains all DGtal functions and types.