mn_iterator_pair.hpp
Go to the documentation of this file.
1 
19 #ifndef MINLIB_a10be6a3_06c2_4e9b_ab95_98e0b19e2835_H_
20 #define MINLIB_a10be6a3_06c2_4e9b_ab95_98e0b19e2835_H_
21 
22 #include "mn_config.hpp"
23 
24 #include "mn_iterator.hpp"
25 #include "container/mn_pair.hpp"
26 #include "container/mn_triple.hpp"
27 
28 namespace mn {
29  template<typename TIterator, typename UIterator, typename TCategory>
30  class basic_iterator_pair : public mn::container::pair<TIterator, UIterator> {
31  private:
33  public:
34  using iterator_category = TCategory ;
35  using value_type = void;
39  using pointer = self_type*;
40  using reference = self_type&;
41 
43 
44  basic_iterator_pair(const TIterator& _itFirst, const UIterator& _itSecond)
45  : base_type(_itFirst, _itSecond) { }
46 
48  : base_type(other.first, other.second) { }
49 
50  operator UIterator() const {
51  return base_type::first;
52  }
53  operator TIterator() const {
54  return base_type::second;
55  }
56 
60  return *this;
61  }
65  return *this;
66  }
67 
69  self_type copy(*this); ++(*this); return copy;
70  }
71 
73  self_type copy(*this); --(*this); return copy;
74  }
75 
76  difference_type operator - (const self_type& other) const {
77  return base_type::first - other.first;
78  }
79 
81  return self_type(base_type::first + delta,
82  base_type::second + delta);
83  }
85  return self_type(base_type::first - delta,
86  base_type::second - delta);
87  }
88  };
89 
90 
91 
92 
93  template<typename TIterator, typename UIterator, typename VIterator, typename TCategory>
94  class basic_iterator_triple : public mn::container::triple<TIterator, UIterator, VIterator> {
95  private:
97  public:
98  using iterator_category = TCategory ;
99  using value_type = void;
103  using pointer = self_type*;
105 
107 
108  basic_iterator_pair(const TIterator& _itFirst, const UIterator& _itSecond, const VIterator& _itThird)
109  : base_type(_itFirst, _itSecond, _itThird) { }
110 
112  : base_type(other.first, other.second, other.third) { }
113 
114  operator UIterator() const {
115  return base_type::first;
116  }
117  operator TIterator() const {
118  return base_type::second;
119  }
120  operator VIterator() const {
121  return base_type::third;
122  }
123 
128  return *this;
129  }
134  return *this;
135  }
136 
138  self_type copy(*this); ++(*this); return copy;
139  }
140 
142  self_type copy(*this); --(*this); return copy;
143  }
144 
145  difference_type operator - (const self_type& other) const {
146  return base_type::first - other.first;
147  }
148 
150  return self_type(base_type::first + delta,
151  base_type::second + delta,
152  base_type::third + delta );
153  }
155  return self_type(base_type::first - delta,
156  base_type::second - delta,
157  base_type::third - delta );
158  }
159  };
160 }
161 
162 
163 #endif
Definition: mn_iterator_pair.hpp:30
basic_iterator_pair()
Definition: mn_iterator_pair.hpp:42
basic_iterator_pair< TIterator, UIterator, TCategory > self_type
Definition: mn_iterator_pair.hpp:38
self_type operator+(difference_type delta) const
Definition: mn_iterator_pair.hpp:80
TCategory iterator_category
Definition: mn_iterator_pair.hpp:34
basic_iterator_pair(const self_type &other)
Definition: mn_iterator_pair.hpp:47
reference & operator++()
Definition: mn_iterator_pair.hpp:57
difference_type operator-(const self_type &other) const
Definition: mn_iterator_pair.hpp:76
basic_iterator_pair(const TIterator &_itFirst, const UIterator &_itSecond)
Definition: mn_iterator_pair.hpp:44
self_type operator--(int)
Definition: mn_iterator_pair.hpp:72
typename traits_type::difference_type difference_type
Definition: mn_iterator_pair.hpp:37
self_type operator++(int)
Definition: mn_iterator_pair.hpp:68
void value_type
Definition: mn_iterator_pair.hpp:35
Definition: mn_iterator_pair.hpp:94
void value_type
Definition: mn_iterator_pair.hpp:99
basic_iterator_pair(const TIterator &_itFirst, const UIterator &_itSecond, const VIterator &_itThird)
Definition: mn_iterator_pair.hpp:108
difference_type operator-(const self_type &other) const
Definition: mn_iterator_pair.hpp:145
self_type operator--(int)
Definition: mn_iterator_pair.hpp:141
basic_iterator_pair< TIterator, UIterator, TCategory, VIterator > self_type
Definition: mn_iterator_pair.hpp:102
reference & operator++()
Definition: mn_iterator_pair.hpp:124
self_type operator++(int)
Definition: mn_iterator_pair.hpp:137
self_type operator+(difference_type delta) const
Definition: mn_iterator_pair.hpp:149
basic_iterator_pair()
Definition: mn_iterator_pair.hpp:106
basic_iterator_pair(const self_type &other)
Definition: mn_iterator_pair.hpp:111
typename traits_type::difference_type difference_type
Definition: mn_iterator_pair.hpp:101
TCategory iterator_category
Definition: mn_iterator_pair.hpp:98
Definition: mn_allocator_typetraits.hpp:25
typename IterT::difference_type difference_type
Definition: mn_iterator.hpp:43
void copy(const T *src, const T *last, T *dest)
Definition: mn_algorithm.hpp:79
Definition: mn_iterator.hpp:41
Definition: mn_pair.hpp:28
second_type second
Definition: mn_pair.hpp:73
first_type first
Definition: mn_pair.hpp:72
Definition: mn_triple.hpp:29
first_type first
Definition: mn_triple.hpp:76
third_type third
Definition: mn_triple.hpp:78
second_type second
Definition: mn_triple.hpp:77