@@ -14,16 +14,21 @@ class RMatrix {
1414 public:
1515
1616 template <typename V>
17- class row_iterator
18- : public std::iterator<std::random_access_iterator_tag, V, std::size_t > {
17+ class row_iterator {
1918
2019 public:
21- inline row_iterator (Row& row, std::size_t i)
20+ using iterator_category = std::random_access_iterator_tag;
21+ using value_type = V;
22+ using difference_type = std::size_t ;
23+ using pointer = value_type*;
24+ using reference = value_type&;
25+
26+ inline row_iterator (Row& row, difference_type i)
2227 : start_(row.start_), parentNrow_(row.parent_.nrow()), index_(i)
2328 {
2429 }
2530
26- inline row_iterator (V* start, std:: size_t parentNrow, std:: size_t index)
31+ inline row_iterator (pointer start, difference_type parentNrow, difference_type index)
2732 : start_(start), parentNrow_(parentNrow), index_(index)
2833 {
2934 }
@@ -57,23 +62,23 @@ class RMatrix {
5762 return tmp ;
5863 }
5964
60- row_iterator operator +(std:: size_t n) const {
65+ row_iterator operator +(difference_type n) const {
6166 return row_iterator (start_, parentNrow_ ,index_ + n ) ;
6267 }
63- row_iterator operator -(std:: size_t n) const {
68+ row_iterator operator -(difference_type n) const {
6469 return row_iterator (start_, parentNrow_, index_ - n ) ;
6570 }
6671
67- std:: size_t operator +(const row_iterator& other) const {
72+ difference_type operator +(const row_iterator& other) const {
6873 return index_ + other.index_ ;
6974 }
7075
71- std:: size_t operator -(const row_iterator& other) const {
76+ difference_type operator -(const row_iterator& other) const {
7277 return index_ - other.index_ ;
7378 }
7479
75- row_iterator& operator +=(std:: size_t n) { index_ += n ; return *this ; }
76- row_iterator& operator -=(std:: size_t n) { index_ -= n ; return *this ; }
80+ row_iterator& operator +=(difference_type n) { index_ += n ; return *this ; }
81+ row_iterator& operator -=(difference_type n) { index_ -= n ; return *this ; }
7782
7883 bool operator ==(const row_iterator& other) const { return index_ == other.index_ ; }
7984 bool operator !=(const row_iterator& other) const { return index_ != other.index_ ; }
@@ -83,16 +88,16 @@ class RMatrix {
8388 bool operator >=(const row_iterator& other) const { return index_ >= other.index_ ; }
8489
8590
86- inline V& operator *() { return start_[index_ * parentNrow_]; }
91+ inline reference operator *() { return start_[index_ * parentNrow_]; }
8792
88- inline V* operator ->() { return &(start_[index_ * parentNrow_]); }
93+ inline pointer operator ->() { return &(start_[index_ * parentNrow_]); }
8994
90- inline V& operator [](int i) { return start_[(index_+i) * parentNrow_]; }
95+ inline reference operator [](int i) { return start_[(index_+i) * parentNrow_]; }
9196
9297 private:
93- V* start_;
94- std:: size_t parentNrow_;
95- std:: size_t index_;
98+ pointer start_;
99+ difference_type parentNrow_;
100+ difference_type index_;
96101 };
97102
98103 typedef row_iterator<T> iterator;
0 commit comments