mirror of
https://github.com/boostorg/conversion.git
synced 2025-08-03 14:34:33 +02:00
remove minmax hack from win32.hpp and fix all places that could be affected by the minmax macros
[SVN r22394]
This commit is contained in:
@@ -129,12 +129,12 @@ namespace boost
|
||||
template <class T>
|
||||
struct signed_numeric_limits : std::numeric_limits<T>
|
||||
{
|
||||
static inline T min()
|
||||
static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
{
|
||||
return std::numeric_limits<T>::min() >= 0
|
||||
return (std::numeric_limits<T>::min)() >= 0
|
||||
// unary minus causes integral promotion, thus the static_cast<>
|
||||
? static_cast<T>(-std::numeric_limits<T>::max())
|
||||
: std::numeric_limits<T>::min();
|
||||
? static_cast<T>(-(std::numeric_limits<T>::max)())
|
||||
: (std::numeric_limits<T>::min)();
|
||||
};
|
||||
};
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace boost
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
|
||||
BOOST_STATIC_CONSTANT(bool, is_signed = true);
|
||||
static long long max()
|
||||
static long long max BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
{
|
||||
# ifdef LONGLONG_MAX
|
||||
return LONGLONG_MAX;
|
||||
@@ -170,7 +170,7 @@ namespace boost
|
||||
# endif
|
||||
}
|
||||
|
||||
static long long min()
|
||||
static long long min BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
{
|
||||
# ifdef LONGLONG_MIN
|
||||
return LONGLONG_MIN;
|
||||
@@ -185,7 +185,7 @@ namespace boost
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
|
||||
BOOST_STATIC_CONSTANT(bool, is_signed = false);
|
||||
static unsigned long long max()
|
||||
static unsigned long long max BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
{
|
||||
# ifdef ULONGLONG_MAX
|
||||
return ULONGLONG_MAX;
|
||||
@@ -194,7 +194,7 @@ namespace boost
|
||||
# endif
|
||||
}
|
||||
|
||||
static unsigned long long min() { return 0; }
|
||||
static unsigned long long min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; }
|
||||
};
|
||||
# endif
|
||||
} // namespace detail
|
||||
@@ -314,10 +314,10 @@ namespace boost
|
||||
template <class T>
|
||||
struct fixed_numeric_limits : public std::numeric_limits<T>
|
||||
{
|
||||
static inline T min()
|
||||
static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
{
|
||||
return std::numeric_limits<T>::is_signed && std::numeric_limits<T>::min() >= 0
|
||||
? T(-std::numeric_limits<T>::max()) : std::numeric_limits<T>::min();
|
||||
return std::numeric_limits<T>::is_signed && (std::numeric_limits<T>::min)() >= 0
|
||||
? T(-(std::numeric_limits<T>::max)()) : (std::numeric_limits<T>::min)();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -351,8 +351,8 @@ namespace boost
|
||||
const bool result_is_signed = result_traits::is_signed;
|
||||
const bool same_sign = arg_is_signed == result_is_signed;
|
||||
|
||||
if (less_than_type_min<arg_is_signed, result_is_signed>::check(arg, result_traits::min())
|
||||
|| greater_than_type_max<same_sign, arg_is_signed>::check(arg, result_traits::max())
|
||||
if (less_than_type_min<arg_is_signed, result_is_signed>::check(arg, (result_traits::min)())
|
||||
|| greater_than_type_max<same_sign, arg_is_signed>::check(arg, (result_traits::max)())
|
||||
)
|
||||
|
||||
#else // We need to use #pragma hacks if available
|
||||
@@ -364,8 +364,8 @@ namespace boost
|
||||
#pragma option push -w-8012
|
||||
# endif
|
||||
if ((arg < 0 && !result_traits::is_signed) // loss of negative range
|
||||
|| (arg_traits::is_signed && arg < result_traits::min()) // underflow
|
||||
|| arg > result_traits::max()) // overflow
|
||||
|| (arg_traits::is_signed && arg < (result_traits::min)()) // underflow
|
||||
|| arg > (result_traits::max)()) // overflow
|
||||
# if BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#elif defined(__BORLANDC__)
|
||||
|
@@ -92,8 +92,8 @@ void test_conversion_to_int()
|
||||
BOOST_CHECK_THROW(lexical_cast<int>('A'),boost::bad_lexical_cast);
|
||||
BOOST_CHECK_EQUAL(1,lexical_cast<int>(1));
|
||||
BOOST_CHECK_EQUAL(
|
||||
std::numeric_limits<int>::max(),
|
||||
lexical_cast<int>(std::numeric_limits<int>::max()));
|
||||
(std::numeric_limits<int>::max)(),
|
||||
lexical_cast<int>((std::numeric_limits<int>::max)()));
|
||||
BOOST_CHECK_EQUAL(1,lexical_cast<int>(1.0));
|
||||
|
||||
BOOST_CHECK_THROW(lexical_cast<int>(1.23), boost::bad_lexical_cast);
|
||||
@@ -123,8 +123,8 @@ void test_conversion_to_double()
|
||||
BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(1));
|
||||
BOOST_CHECK_EQUAL(1.23, lexical_cast<double>(1.23));
|
||||
BOOST_CHECK_CLOSE(
|
||||
std::numeric_limits<double>::max() / 2,
|
||||
lexical_cast<double>(std::numeric_limits<double>::max() / 2),
|
||||
(std::numeric_limits<double>::max)() / 2,
|
||||
lexical_cast<double>((std::numeric_limits<double>::max)() / 2),
|
||||
std::numeric_limits<double>::epsilon());
|
||||
BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(true));
|
||||
BOOST_CHECK_EQUAL(0.0, lexical_cast<double>(false));
|
||||
|
Reference in New Issue
Block a user