@@ -14,16 +14,21 @@ class RMatrix {
14
14
public:
15
15
16
16
template <typename V>
17
- class row_iterator
18
- : public std::iterator<std::random_access_iterator_tag, V, std::size_t > {
17
+ class row_iterator {
19
18
20
19
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)
22
27
: start_(row.start_), parentNrow_(row.parent_.nrow()), index_(i)
23
28
{
24
29
}
25
30
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)
27
32
: start_(start), parentNrow_(parentNrow), index_(index)
28
33
{
29
34
}
@@ -57,23 +62,23 @@ class RMatrix {
57
62
return tmp ;
58
63
}
59
64
60
- row_iterator operator +(std:: size_t n) const {
65
+ row_iterator operator +(difference_type n) const {
61
66
return row_iterator (start_, parentNrow_ ,index_ + n ) ;
62
67
}
63
- row_iterator operator -(std:: size_t n) const {
68
+ row_iterator operator -(difference_type n) const {
64
69
return row_iterator (start_, parentNrow_, index_ - n ) ;
65
70
}
66
71
67
- std:: size_t operator +(const row_iterator& other) const {
72
+ difference_type operator +(const row_iterator& other) const {
68
73
return index_ + other.index_ ;
69
74
}
70
75
71
- std:: size_t operator -(const row_iterator& other) const {
76
+ difference_type operator -(const row_iterator& other) const {
72
77
return index_ - other.index_ ;
73
78
}
74
79
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 ; }
77
82
78
83
bool operator ==(const row_iterator& other) const { return index_ == other.index_ ; }
79
84
bool operator !=(const row_iterator& other) const { return index_ != other.index_ ; }
@@ -83,16 +88,16 @@ class RMatrix {
83
88
bool operator >=(const row_iterator& other) const { return index_ >= other.index_ ; }
84
89
85
90
86
- inline V& operator *() { return start_[index_ * parentNrow_]; }
91
+ inline reference operator *() { return start_[index_ * parentNrow_]; }
87
92
88
- inline V* operator ->() { return &(start_[index_ * parentNrow_]); }
93
+ inline pointer operator ->() { return &(start_[index_ * parentNrow_]); }
89
94
90
- inline V& operator [](int i) { return start_[(index_+i) * parentNrow_]; }
95
+ inline reference operator [](int i) { return start_[(index_+i) * parentNrow_]; }
91
96
92
97
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_;
96
101
};
97
102
98
103
typedef row_iterator<T> iterator;
0 commit comments