diff options
Diffstat (limited to 'src/serialbus/qmodbuspdu.h')
-rw-r--r-- | src/serialbus/qmodbuspdu.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/serialbus/qmodbuspdu.h b/src/serialbus/qmodbuspdu.h index 7a2e46c..61ea3a7 100644 --- a/src/serialbus/qmodbuspdu.h +++ b/src/serialbus/qmodbuspdu.h @@ -133,19 +133,21 @@ private: template<typename ... Args> void encode(Args ... newData) { m_data.clear(); - Q_CONSTEXPR quint32 argCount = sizeof...(Args); - if (argCount > 0) { + constexpr size_t argCount = sizeof...(Args); + if constexpr (argCount > 0) { QDataStream stream(&m_data, QIODevice::WriteOnly); char tmp[argCount] = { (encode(&stream, newData), void(), '0')... }; Q_UNUSED(tmp); } } template<typename ... Args> void decode(Args ... newData) const { - Q_CONSTEXPR quint32 argCount = sizeof...(Args); - if (argCount > 0 && !m_data.isEmpty()) { - QDataStream stream(m_data); - char tmp[argCount] = { (decode(&stream, newData), void(), '0')... }; - Q_UNUSED(tmp); + constexpr size_t argCount = sizeof...(Args); + if constexpr (argCount > 0) { + if (!m_data.isEmpty()) { + QDataStream stream(m_data); + char tmp[argCount] = { (decode(&stream, newData), void(), '0')... }; + Q_UNUSED(tmp); + } } } |