aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-12-08 05:09:58 -0800
committerChris Robinson <[email protected]>2023-12-08 05:09:58 -0800
commit4527b873788373edb630046b0ab586255aa15e44 (patch)
treef1a4ca37f1d9c565f3b155c884189d7cfdb6aceb /al
parent8f661a2f59e63cbed540b512dc564a3aca7c4211 (diff)
Try to work around a compiler issue with HexPrinter
Diffstat (limited to 'al')
-rw-r--r--al/source.cpp13
1 files 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<ALfloat> { static const char *Name() { return "float"; } };
template<>
struct PropType<ALdouble> { static const char *Name() { return "double"; } };
-template<typename T>
struct HexPrinter {
- char mStr[sizeof(T)*2 + 3]{};
+ std::array<char,32> mStr{};
+
+ template<typename T>
HexPrinter(T value)
{
using ST = std::make_signed_t<std::remove_cv_t<T>>;
if constexpr(std::is_same_v<ST,int>)
- 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<ST,long>)
- 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<ST,long long>)
- 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(); }
};