Skip to content

Commit

Permalink
src: fix warnings in aliased_buffer
Browse files Browse the repository at this point in the history
* Unary minus usages on unsigned type
* Implicit casts to/from input parameters

PR-URL: #19665
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
  • Loading branch information
kfarnung committed Mar 31, 2018
1 parent 085ad54 commit 0d64f33
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/aliased_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,11 @@ class AliasedBuffer {
index_(that.index_) {
}

template <typename T>
inline Reference& operator=(const T& val) {
inline Reference& operator=(const NativeT& val) {
aliased_buffer_->SetValue(index_, val);
return *this;
}

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

template <typename T>
inline Reference& operator+=(const T& val) {
const T current = aliased_buffer_->GetValue(index_);
inline Reference& operator+=(const NativeT& val) {
const NativeT current = aliased_buffer_->GetValue(index_);
aliased_buffer_->SetValue(index_, current + val);
return *this;
}
Expand All @@ -152,9 +149,10 @@ class AliasedBuffer {
return this->operator+=(static_cast<NativeT>(val));
}

template <typename T>
inline Reference& operator-=(const T& val) {
return this->operator+=(-val);
inline Reference& operator-=(const NativeT& val) {
const NativeT current = aliased_buffer_->GetValue(index_);
aliased_buffer_->SetValue(index_, current - val);
return *this;
}

private:
Expand Down

0 comments on commit 0d64f33

Please sign in to comment.