33 #ifndef SHARK_CORE_ITERATORS_H 34 #define SHARK_CORE_ITERATORS_H 36 #include <boost/version.hpp> 37 #include "Impl/boost_iterator_facade_fixed.hpp" 39 #include <boost/range/iterator.hpp> 45 template<
class Iterator>
47 IndexedIterator<Iterator>,
48 typename boost::iterator_value<Iterator>::type,
49 std::random_access_iterator_tag,
50 typename boost::iterator_reference<Iterator>::type
60 : m_iterator(iterator.m_iterator),m_index(iterator.
index){}
63 template<
class IteratorT>
65 : m_iterator(Iterator(iterator)),m_index(startIndex){}
71 typedef SHARK_ITERATOR_FACADE<
73 typename boost::iterator_value<Iterator>::type,
74 boost::random_access_traversal_tag,
75 typename boost::iterator_reference<Iterator>::type
80 typename base_type::reference dereference()
const {
93 void advance(std::ptrdiff_t n){
100 return other.m_iterator - m_iterator;
105 return m_iterator == other.m_iterator;
116 template<
class Sequence,
class ValueType,
class Reference>
118 ProxyIterator<Sequence,ValueType,Reference>,
121 std::random_access_iterator_tag,
128 : m_sequence(&seq),m_position(position) {}
130 template<
class S,
class V,
class R>
132 : m_sequence(other.m_sequence),m_position(other.m_position) {}
145 void advance(std::ptrdiff_t n){
150 std::ptrdiff_t distance_to(
const Iter& other)
const{
151 return (std::ptrdiff_t)other.m_position - (std::ptrdiff_t)m_position;
155 bool equal(Iter
const& other)
const{
156 return (m_position == other.m_position);
158 Reference dereference()
const {
159 return Reference(*m_sequence,m_position);
163 std::size_t m_position;
166 template<
class Container>
168 IndexingIterator<Container>,
169 typename Container::value_type,
170 std::random_access_iterator_tag,
171 typename boost::mpl::if_<
172 std::is_const<Container>,
173 typename Container::const_reference,
174 typename Container::reference
181 IndexingIterator(Container& container, std::size_t pos):m_container(&container), m_index(
std::ptrdiff_t(pos)){}
185 : m_container(iterator.m_container){}
197 void advance(std::ptrdiff_t n){
203 return other.m_index - m_index;
208 return m_index == other.m_index;
210 typename IndexingIterator::reference dereference()
const {
211 return (*m_container)[m_index];
214 Container* m_container;
215 std::ptrdiff_t m_index;