Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 29619a2

Browse files
committed
src: fix warnings in aliased_buffer
* Unary minus usages on unsigned type * Implicit casts to/from input parameters
1 parent d50069c commit 29619a2

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

src/aliased_buffer.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,11 @@ class AliasedBuffer {
127127
index_(that.index_) {
128128
}
129129

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

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

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

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

161159
private:

0 commit comments

Comments
 (0)