mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-02-06 17:59:52 +08:00
FASTFLOAT_HAS_BIT_CAST fix for old standards.
This commit is contained in:
parent
051d15119e
commit
cd61547b63
@ -251,11 +251,14 @@ using parse_options = parse_options_t<char>;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace fast_float {
|
namespace fast_float {
|
||||||
|
#if FASTFLOAT_HAS_BIT_CAST
|
||||||
template <typename To, typename From>
|
template <typename To, typename From>
|
||||||
fastfloat_really_inline constexpr To bit_cast(const From &from) noexcept {
|
fastfloat_really_inline constexpr To bit_cast(const From &from) noexcept {
|
||||||
#if FASTFLOAT_HAS_BIT_CAST
|
|
||||||
return std::bit_cast<To>(from);
|
return std::bit_cast<To>(from);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
template <typename To, typename From>
|
||||||
|
fastfloat_really_inline To bit_cast(const From &from) noexcept {
|
||||||
// Implementation of std::bit_cast for pre-C++20.
|
// Implementation of std::bit_cast for pre-C++20.
|
||||||
static_assert(sizeof(To) == sizeof(From),
|
static_assert(sizeof(To) == sizeof(From),
|
||||||
"bit_cast requires source and destination to be the same size");
|
"bit_cast requires source and destination to be the same size");
|
||||||
@ -263,8 +266,8 @@ fastfloat_really_inline constexpr To bit_cast(const From &from) noexcept {
|
|||||||
// The cast suppresses a bogus -Wclass-memaccess on GCC.
|
// The cast suppresses a bogus -Wclass-memaccess on GCC.
|
||||||
std::memcpy(static_cast<void *>(&to), &from, sizeof(to));
|
std::memcpy(static_cast<void *>(&to), &from, sizeof(to));
|
||||||
return to;
|
return to;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
fastfloat_really_inline constexpr bool cpp20_and_in_constexpr() noexcept {
|
fastfloat_really_inline constexpr bool cpp20_and_in_constexpr() noexcept {
|
||||||
#if FASTFLOAT_HAS_IS_CONSTANT_EVALUATED
|
#if FASTFLOAT_HAS_IS_CONSTANT_EVALUATED
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user