Skip to content

Commit 9217839

Browse files
committed
remove friend identifier and define the + and - operator outside of class
1 parent ed4a43a commit 9217839

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

libs/libvtrutil/src/vtr_strong_id_range.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,6 @@ class StrongIdIterator {
8888
return StrongId(size_t(id_) + offset);
8989
}
9090

91-
///@brief + operator
92-
template<typename IdType>
93-
friend StrongIdIterator<IdType> operator+(
94-
const StrongIdIterator<IdType>& lhs,
95-
ssize_t n) {
96-
StrongIdIterator ret = lhs;
97-
ret += n;
98-
return ret;
99-
}
100-
101-
///@brief - operator
102-
template<typename IdType>
103-
friend StrongIdIterator<IdType> operator-(
104-
const StrongIdIterator<IdType>& lhs,
105-
ssize_t n) {
106-
StrongIdIterator ret = lhs;
107-
ret -= n;
108-
return ret;
109-
}
110-
11191
///@brief ~ operator
11292
template<typename IdType>
11393
friend ssize_t operator-(
@@ -123,26 +103,46 @@ class StrongIdIterator {
123103

124104
///@brief == operator
125105
template<typename IdType>
126-
friend bool operator==(const StrongIdIterator<IdType>& lhs, const StrongIdIterator<IdType>& rhs) {
127-
return lhs.id_ == rhs.id_;
106+
bool operator==(const StrongIdIterator<IdType>& other) {
107+
return id_ == other.id_;
128108
}
129109

130110
///@brief != operator
131111
template<typename IdType>
132-
friend bool operator!=(const StrongIdIterator<IdType>& lhs, const StrongIdIterator<IdType>& rhs) {
133-
return lhs.id_ != rhs.id_;
112+
bool operator!=(const StrongIdIterator<IdType>& other) {
113+
return id_ != other.id_;
134114
}
135115

136116
///@brief < operator
137117
template<typename IdType>
138-
friend bool operator<(const StrongIdIterator<IdType>& lhs, const StrongIdIterator<IdType>& rhs) {
139-
return lhs.id_ < rhs.id_;
118+
bool operator<(const StrongIdIterator<IdType>& other) {
119+
return id_ < other.id_;
140120
}
141121

142122
private:
143123
StrongId id_;
144124
};
145125

126+
///@brief + operator
127+
template<typename IdType>
128+
inline StrongIdIterator<IdType> operator+(
129+
const StrongIdIterator<IdType>& lhs,
130+
ssize_t n) {
131+
StrongIdIterator ret = lhs;
132+
ret += n;
133+
return ret;
134+
}
135+
136+
///@brief - operator
137+
template<typename IdType>
138+
inline StrongIdIterator<IdType> operator-(
139+
const StrongIdIterator<IdType>& lhs,
140+
ssize_t n) {
141+
StrongIdIterator ret = lhs;
142+
ret -= n;
143+
return ret;
144+
}
145+
146146
/**
147147
* @brief StrongIdRange class
148148
*

0 commit comments

Comments
 (0)