QCborStreamReader: use std::bit_cast in _toFloatingPoint

Change-Id: Ic5b53111dbdb9073bb45fffd7c1bcb0c80b5df62
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Thiago Macieira 2025-02-12 22:27:31 -08:00 committed by Marc Mutz
parent e62407b429
commit 8e1c333661

View File

@ -11,6 +11,9 @@
#include <QtCore/qstring.h>
#include <QtCore/qstringview.h>
#ifdef __cpp_lib_bit_cast
#include <bit>
#endif
#include <memory>
QT_REQUIRE_CONFIG(cborstreamreader);
@ -188,9 +191,13 @@ private:
{
using UIntFP = typename QIntegerForSizeof<FP>::Unsigned;
UIntFP u = UIntFP(value64);
#ifdef __cpp_lib_bit_cast
return std::bit_cast<FP>(u);
#else
FP f;
memcpy(static_cast<void *>(&f), &u, sizeof(f));
return f;
#endif
}
friend QCborStreamReaderPrivate;