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:
Eric Niebler
2004-02-26 18:27:02 +00:00
parent 9f5ec17603
commit 463284f46f
2 changed files with 19 additions and 19 deletions

View File

@@ -129,12 +129,12 @@ namespace boost
template <class T> template <class T>
struct signed_numeric_limits : std::numeric_limits<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<> // unary minus causes integral promotion, thus the static_cast<>
? static_cast<T>(-std::numeric_limits<T>::max()) ? static_cast<T>(-(std::numeric_limits<T>::max)())
: std::numeric_limits<T>::min(); : (std::numeric_limits<T>::min)();
}; };
}; };
@@ -161,7 +161,7 @@ namespace boost
{ {
BOOST_STATIC_CONSTANT(bool, is_specialized = true); BOOST_STATIC_CONSTANT(bool, is_specialized = true);
BOOST_STATIC_CONSTANT(bool, is_signed = true); BOOST_STATIC_CONSTANT(bool, is_signed = true);
static long long max() static long long max BOOST_PREVENT_MACRO_SUBSTITUTION ()
{ {
# ifdef LONGLONG_MAX # ifdef LONGLONG_MAX
return LONGLONG_MAX; return LONGLONG_MAX;
@@ -170,7 +170,7 @@ namespace boost
# endif # endif
} }
static long long min() static long long min BOOST_PREVENT_MACRO_SUBSTITUTION ()
{ {
# ifdef LONGLONG_MIN # ifdef LONGLONG_MIN
return LONGLONG_MIN; return LONGLONG_MIN;
@@ -185,7 +185,7 @@ namespace boost
{ {
BOOST_STATIC_CONSTANT(bool, is_specialized = true); BOOST_STATIC_CONSTANT(bool, is_specialized = true);
BOOST_STATIC_CONSTANT(bool, is_signed = false); BOOST_STATIC_CONSTANT(bool, is_signed = false);
static unsigned long long max() static unsigned long long max BOOST_PREVENT_MACRO_SUBSTITUTION ()
{ {
# ifdef ULONGLONG_MAX # ifdef ULONGLONG_MAX
return ULONGLONG_MAX; return ULONGLONG_MAX;
@@ -194,7 +194,7 @@ namespace boost
# endif # endif
} }
static unsigned long long min() { return 0; } static unsigned long long min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; }
}; };
# endif # endif
} // namespace detail } // namespace detail
@@ -314,10 +314,10 @@ namespace boost
template <class T> template <class T>
struct fixed_numeric_limits : public std::numeric_limits<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 return std::numeric_limits<T>::is_signed && (std::numeric_limits<T>::min)() >= 0
? T(-std::numeric_limits<T>::max()) : std::numeric_limits<T>::min(); ? 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 result_is_signed = result_traits::is_signed;
const bool same_sign = arg_is_signed == result_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()) 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()) || greater_than_type_max<same_sign, arg_is_signed>::check(arg, (result_traits::max)())
) )
#else // We need to use #pragma hacks if available #else // We need to use #pragma hacks if available
@@ -364,8 +364,8 @@ namespace boost
#pragma option push -w-8012 #pragma option push -w-8012
# endif # endif
if ((arg < 0 && !result_traits::is_signed) // loss of negative range if ((arg < 0 && !result_traits::is_signed) // loss of negative range
|| (arg_traits::is_signed && arg < result_traits::min()) // underflow || (arg_traits::is_signed && arg < (result_traits::min)()) // underflow
|| arg > result_traits::max()) // overflow || arg > (result_traits::max)()) // overflow
# if BOOST_MSVC # if BOOST_MSVC
# pragma warning(pop) # pragma warning(pop)
#elif defined(__BORLANDC__) #elif defined(__BORLANDC__)

View File

@@ -92,8 +92,8 @@ void test_conversion_to_int()
BOOST_CHECK_THROW(lexical_cast<int>('A'),boost::bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast<int>('A'),boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(1,lexical_cast<int>(1)); BOOST_CHECK_EQUAL(1,lexical_cast<int>(1));
BOOST_CHECK_EQUAL( BOOST_CHECK_EQUAL(
std::numeric_limits<int>::max(), (std::numeric_limits<int>::max)(),
lexical_cast<int>(std::numeric_limits<int>::max())); lexical_cast<int>((std::numeric_limits<int>::max)()));
BOOST_CHECK_EQUAL(1,lexical_cast<int>(1.0)); BOOST_CHECK_EQUAL(1,lexical_cast<int>(1.0));
BOOST_CHECK_THROW(lexical_cast<int>(1.23), boost::bad_lexical_cast); 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.0, lexical_cast<double>(1));
BOOST_CHECK_EQUAL(1.23, lexical_cast<double>(1.23)); BOOST_CHECK_EQUAL(1.23, lexical_cast<double>(1.23));
BOOST_CHECK_CLOSE( BOOST_CHECK_CLOSE(
std::numeric_limits<double>::max() / 2, (std::numeric_limits<double>::max)() / 2,
lexical_cast<double>(std::numeric_limits<double>::max() / 2), lexical_cast<double>((std::numeric_limits<double>::max)() / 2),
std::numeric_limits<double>::epsilon()); std::numeric_limits<double>::epsilon());
BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(true)); BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(true));
BOOST_CHECK_EQUAL(0.0, lexical_cast<double>(false)); BOOST_CHECK_EQUAL(0.0, lexical_cast<double>(false));