mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
explicit cast
This commit is contained in:
parent
9da74ca5fb
commit
eb584f748e
@ -529,8 +529,8 @@ from_chars_result_t<UC> parse_int_string(UC const* p, UC const* pend, T& value,
|
|||||||
// this weird workaround is required because:
|
// this weird workaround is required because:
|
||||||
// - converting unsigned to signed when its value is greater than signed max is UB pre-C++23.
|
// - converting unsigned to signed when its value is greater than signed max is UB pre-C++23.
|
||||||
// - reinterpret_casting (~i + 1) would work, but it is not constexpr
|
// - reinterpret_casting (~i + 1) would work, but it is not constexpr
|
||||||
// this is always optimized into a neg instruction.
|
// this is always optimized into a neg instruction (note: T is an integer type)
|
||||||
value = T(-std::numeric_limits<T>::max() - T(i - std::numeric_limits<T>::max()));
|
value = T(-std::numeric_limits<T>::max() - T(i - uint64_t(std::numeric_limits<T>::max())));
|
||||||
#ifdef FASTFLOAT_VISUAL_STUDIO
|
#ifdef FASTFLOAT_VISUAL_STUDIO
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user