From 4527b873788373edb630046b0ab586255aa15e44 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 8 Dec 2023 05:09:58 -0800 Subject: Try to work around a compiler issue with HexPrinter --- al/source.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/al/source.cpp b/al/source.cpp index 9c449434..a6fe4225 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -1371,21 +1371,22 @@ struct PropType { static const char *Name() { return "float"; } }; template<> struct PropType { static const char *Name() { return "double"; } }; -template struct HexPrinter { - char mStr[sizeof(T)*2 + 3]{}; + std::array mStr{}; + + template HexPrinter(T value) { using ST = std::make_signed_t>; if constexpr(std::is_same_v) - std::snprintf(mStr, std::size(mStr), "0x%x", value); + std::snprintf(mStr.data(), mStr.size(), "0x%x", value); else if constexpr(std::is_same_v) - std::snprintf(mStr, std::size(mStr), "0x%lx", value); + std::snprintf(mStr.data(), mStr.size(), "0x%lx", value); else if constexpr(std::is_same_v) - std::snprintf(mStr, std::size(mStr), "0x%llx", value); + std::snprintf(mStr.data(), mStr.size(), "0x%llx", value); } - const char *c_str() const noexcept { return mStr; } + [[nodiscard]] auto c_str() const noexcept -> const char* { return mStr.data(); } }; -- cgit v1.2.3