diff --git a/code/espurna/sensor.cpp b/code/espurna/sensor.cpp index add5769d..e32ba159 100644 --- a/code/espurna/sensor.cpp +++ b/code/espurna/sensor.cpp @@ -220,6 +220,13 @@ struct sensor_magnitude_t { constexpr static double _unset = std::numeric_limits::quiet_NaN(); static unsigned char _counts[MAGNITUDE_MAX]; + sensor_magnitude_t& operator=(const sensor_magnitude_t&) = default; + + void move(sensor_magnitude_t&& other) noexcept { + *this = other; + other.filter = nullptr; + } + public: static unsigned char counts(unsigned char type) { @@ -227,15 +234,18 @@ struct sensor_magnitude_t { } sensor_magnitude_t() = delete; - sensor_magnitude_t& operator=(const sensor_magnitude_t&) = default; - sensor_magnitude_t(const sensor_magnitude_t&) = delete; sensor_magnitude_t(sensor_magnitude_t&& other) noexcept { *this = other; other.filter = nullptr; } - ~sensor_magnitude_t() { + sensor_magnitude_t& operator=(sensor_magnitude_t&& other) noexcept { + move(std::move(other)); + return *this; + } + + ~sensor_magnitude_t() noexcept { delete filter; }