Skip to content

Commit 75d23ab

Browse files
kfarnungtargos
authored andcommitted
src: fix warnings in aliased_buffer
* Unary minus usages on unsigned type * Implicit casts to/from input parameters PR-URL: #19665 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Khaidi Chu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
1 parent 0b27416 commit 75d23ab

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/aliased_buffer.h

+7-9
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,11 @@ class AliasedBuffer {
126126
index_(that.index_) {
127127
}
128128

129-
template <typename T>
130-
inline Reference& operator=(const T& val) {
129+
inline Reference& operator=(const NativeT& val) {
131130
aliased_buffer_->SetValue(index_, val);
132131
return *this;
133132
}
134133

135-
// This is not caught by the template operator= above.
136134
inline Reference& operator=(const Reference& val) {
137135
return *this = static_cast<NativeT>(val);
138136
}
@@ -141,9 +139,8 @@ class AliasedBuffer {
141139
return aliased_buffer_->GetValue(index_);
142140
}
143141

144-
template <typename T>
145-
inline Reference& operator+=(const T& val) {
146-
const T current = aliased_buffer_->GetValue(index_);
142+
inline Reference& operator+=(const NativeT& val) {
143+
const NativeT current = aliased_buffer_->GetValue(index_);
147144
aliased_buffer_->SetValue(index_, current + val);
148145
return *this;
149146
}
@@ -152,9 +149,10 @@ class AliasedBuffer {
152149
return this->operator+=(static_cast<NativeT>(val));
153150
}
154151

155-
template <typename T>
156-
inline Reference& operator-=(const T& val) {
157-
return this->operator+=(-val);
152+
inline Reference& operator-=(const NativeT& val) {
153+
const NativeT current = aliased_buffer_->GetValue(index_);
154+
aliased_buffer_->SetValue(index_, current - val);
155+
return *this;
158156
}
159157

160158
private:

0 commit comments

Comments
 (0)