QCborStreamReader: use std::bit_cast in _toFloatingPoint
Change-Id: Ic5b53111dbdb9073bb45fffd7c1bcb0c80b5df62 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
e62407b429
commit
8e1c333661
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user