Fix macro and member function confilct for min and max (GH #1214)

This commit is contained in:
irwir 2023-06-23 21:09:08 +03:00 committed by GitHub
parent 0cf084506d
commit a5f47381b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

14
misc.h
View File

@ -783,7 +783,7 @@ inline bool SafeConvert(sword32 from, word64 &to)
template<>
inline bool SafeConvert(word64 from, sword64 &to)
{
if (from > static_cast<word64>(std::numeric_limits<sword64>::max()))
if (from > static_cast<word64>((std::numeric_limits<sword64>::max)()))
return false;
to = static_cast<sword64>(from);
return true;
@ -827,7 +827,7 @@ inline bool SafeConvert(sword32 from, sword64 &to)
template<>
inline bool SafeConvert(word64 from, word32 &to)
{
if (from > static_cast<word64>(std::numeric_limits<word32>::max()))
if (from > static_cast<word64>((std::numeric_limits<word32>::max)()))
return false;
to = static_cast<word32>(from);
return true;
@ -845,7 +845,7 @@ inline bool SafeConvert(sword64 from, word32 &to)
{
if (from < 0)
return false;
else if (from > static_cast<sword64>(std::numeric_limits<word32>::max()))
else if (from > static_cast<sword64>((std::numeric_limits<word32>::max)()))
return false;
to = static_cast<word32>(from);
return true;
@ -877,7 +877,7 @@ inline bool SafeConvert(sword32 from, word32 &to)
template<>
inline bool SafeConvert(word64 from, sword32 &to)
{
if (from > static_cast<word64>(std::numeric_limits<sword32>::max()))
if (from > static_cast<word64>((std::numeric_limits<sword32>::max)()))
return false;
to = static_cast<sword32>(from);
return true;
@ -893,9 +893,9 @@ inline bool SafeConvert(word64 from, sword32 &to)
template<>
inline bool SafeConvert(sword64 from, sword32 &to)
{
if (from > static_cast<sword64>(std::numeric_limits<sword32>::max()))
if (from > static_cast<sword64>((std::numeric_limits<sword32>::max)()))
return false;
else if (from < static_cast<sword64>(std::numeric_limits<sword32>::min()))
else if (from < static_cast<sword64>((std::numeric_limits<sword32>::min)()))
return false;
to = static_cast<sword32>(from);
return true;
@ -911,7 +911,7 @@ inline bool SafeConvert(sword64 from, sword32 &to)
template<>
inline bool SafeConvert(word32 from, sword32 &to)
{
if (from > static_cast<word32>(std::numeric_limits<sword32>::max()))
if (from > static_cast<word32>((std::numeric_limits<sword32>::max)()))
return false;
to = static_cast<sword32>(from);
return true;