Give uint8_clamped a defaulted (and also trivial) default constructor, copy constructor, and copy-assignment operator.

This also allows uint8_clamped to be permissibly memmove'd and memcpy'd.
This commit is contained in:
trav90 2018-09-19 18:59:49 -05:00 committed by Roy Tam
commit 3bfbbf5d40

View file

@ -457,8 +457,8 @@ ClampDoubleToUint8(const double x);
struct uint8_clamped {
uint8_t val;
uint8_clamped() { }
uint8_clamped(const uint8_clamped& other) : val(other.val) { }
uint8_clamped() = default;
uint8_clamped(const uint8_clamped& other) = default;
// invoke our assignment helpers for constructor conversion
explicit uint8_clamped(uint8_t x) { *this = x; }
@ -469,10 +469,7 @@ struct uint8_clamped {
explicit uint8_clamped(int32_t x) { *this = x; }
explicit uint8_clamped(double x) { *this = x; }
uint8_clamped& operator=(const uint8_clamped& x) {
val = x.val;
return *this;
}
uint8_clamped& operator=(const uint8_clamped& x) = default;
uint8_clamped& operator=(uint8_t x) {
val = x;