From 32a31255ec7e03fe7c8f0c47e175d33ca74ef53a Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 26 Feb 2024 22:56:45 +0100 Subject: [PATCH] [WIP] common_type_t --- inc/msp/ByteVector.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/inc/msp/ByteVector.hpp b/inc/msp/ByteVector.hpp index 1831613..931b4d9 100644 --- a/inc/msp/ByteVector.hpp +++ b/inc/msp/ByteVector.hpp @@ -319,11 +319,14 @@ class ByteVector : public std::vector { typename std::enable_if::value, T2>::type* = nullptr> bool unpack(T1& val, T2 scale, T2 offset = 0) const { + using cast_type = std::common_type_t; + bool rc = true; encoding_T tmp = 0; rc &= unpack(tmp); - val = static_cast(tmp) / scale; - val -= offset; + val = static_cast(static_cast(tmp) / + static_cast(scale) - + static_cast(offset)); return rc; }