From ef0a48c12e51f4e330b63989441e7bb14a5f3d51 Mon Sep 17 00:00:00 2001 From: "Stephen F. Booth" Date: Sat, 7 Dec 2024 22:37:20 -0600 Subject: [PATCH] Work around `byteSwap` not using fixed width types --- taglib/shn/shnfile.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/taglib/shn/shnfile.cpp b/taglib/shn/shnfile.cpp index 24f6a8b5..3d2a5f91 100644 --- a/taglib/shn/shnfile.cpp +++ b/taglib/shn/shnfile.cpp @@ -223,8 +223,20 @@ namespace { T value = *reinterpret_cast(reinterpret_cast(p) + n); auto system_big = Utils::systemByteOrder() == Utils::BigEndian; - if(big != system_big) - value = Utils::byteSwap(value); + if constexpr (std::is_same_v) { + if(big != system_big) + value = Utils::byteSwap(static_cast(value)); + } + else if constexpr (std::is_same_v) { + if(big != system_big) + value = Utils::byteSwap(static_cast(value)); + } + else if constexpr (std::is_same_v) { + if(big != system_big) + value = Utils::byteSwap(static_cast(value)); + } + else + static_assert(false, "Invalid typename T"); return value; }