mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-09-13 14:12:25 +08:00
Merge pull request #399 from dg0yt/max
Fix compatibility with min()/max() macros
This commit is contained in:
commit
13ecd70727
@ -804,7 +804,7 @@ parse_int_string(UC const *p, UC const *pend, T &value,
|
|||||||
|
|
||||||
// check other types overflow
|
// check other types overflow
|
||||||
if (!std::is_same<T, uint64_t>::value) {
|
if (!std::is_same<T, uint64_t>::value) {
|
||||||
if (i > uint64_t(std::numeric_limits<T>::max()) + uint64_t(negative)) {
|
if (i > uint64_t((std::numeric_limits<T>::max)()) + uint64_t(negative)) {
|
||||||
answer.ec = std::errc::result_out_of_range;
|
answer.ec = std::errc::result_out_of_range;
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
@ -821,8 +821,8 @@ parse_int_string(UC const *p, UC const *pend, T &value,
|
|||||||
// - 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 (note: T is an integer
|
// this is always optimized into a neg instruction (note: T is an integer
|
||||||
// type)
|
// type)
|
||||||
value = T(-std::numeric_limits<T>::max() -
|
value = T(-(std::numeric_limits<T>::max)() -
|
||||||
T(i - uint64_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
|
||||||
|
|||||||
@ -96,7 +96,7 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept {
|
|||||||
// asm). The value does not need to be std::numeric_limits<float>::min(), any
|
// asm). The value does not need to be std::numeric_limits<float>::min(), any
|
||||||
// small value so that 1 + x should round to 1 would do (after accounting for
|
// small value so that 1 + x should round to 1 would do (after accounting for
|
||||||
// excess precision, as in 387 instructions).
|
// excess precision, as in 387 instructions).
|
||||||
static float volatile fmin = std::numeric_limits<float>::min();
|
static float volatile fmin = (std::numeric_limits<float>::min)();
|
||||||
float fmini = fmin; // we copy it so that it gets loaded at most once.
|
float fmini = fmin; // we copy it so that it gets loaded at most once.
|
||||||
//
|
//
|
||||||
// Explanation:
|
// Explanation:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user