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 8a67e3222a
commit 95f6278e82
4 changed files with 23 additions and 70 deletions

View File

@ -53,6 +53,9 @@
# include BOOST_PLATFORM_CONFIG
#endif
// used in various places to guard against the min/max macros
#define BOOST_PREVENT_MACRO_SUBSTITUTION
// get config suffix code:
#include <boost/config/suffix.hpp>

View File

@ -43,44 +43,3 @@
#endif
//
// disable min/max macros:
//
#ifdef min
# undef min
#endif
#ifdef max
# undef max
#endif
#ifndef NOMINMAX
# define NOMINMAX
#endif
#ifdef BOOST_MSVC
#include <algorithm> // for existing std::min and std::max
namespace std{
// Apparently, something in the Microsoft libraries requires the "long"
// overload, because it calls the min/max functions with arguments of
// slightly different type. (If this proves to be incorrect, this
// whole "BOOST_MSVC" section can be removed.)
inline long min(long __a, long __b) {
return __b < __a ? __b : __a;
}
inline long max(long __a, long __b) {
return __a < __b ? __b : __a;
}
// The "long double" overload is required, otherwise user code calling
// min/max for floating-point numbers will use the "long" overload.
// (SourceForge bug #495495)
inline long double min(long double __a, long double __b) {
return __b < __a ? __b : __a;
}
inline long double max(long double __a, long double __b) {
return __a < __b ? __b : __a;
}
}
using std::min;
using std::max;
# endif

View File

@ -94,23 +94,14 @@ enum float_denorm_style {
static const __mem_type __mem_name = __mem_value
#endif /* BOOST_NO_INCLASS_MEMBER_INITIALIZATION */
// Deal with min/max for MinGW
#ifdef min
# undef min
#endif
#ifdef max
# undef max
#endif
// Base class for all specializations of numeric_limits.
template <class __number>
class _Numeric_limits_base {
public:
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, false);
static __number min() throw() { return __number(); }
static __number max() throw() { return __number(); }
static __number min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __number(); }
static __number max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __number(); }
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits, 0);
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits10, 0);
@ -164,8 +155,8 @@ class _Integer_limits : public _Numeric_limits_base<_Int>
public:
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);
static _Int min() throw() { return __imin; }
static _Int max() throw() { return __imax; }
static _Int min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __imin; }
static _Int max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __imax; }
BOOST_STL_DECLARE_LIMITS_MEMBER(int,
digits,
@ -388,9 +379,9 @@ template<> class numeric_limits<float>
round_to_nearest>
{
public:
static float min() throw() { return FLT_MIN; }
static float min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return FLT_MIN; }
static float denorm_min() throw() { return FLT_MIN; }
static float max() throw() { return FLT_MAX; }
static float max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return FLT_MAX; }
static float epsilon() throw() { return FLT_EPSILON; }
static float round_error() throw() { return 0.5f; } // Units: ulps.
};
@ -416,9 +407,9 @@ template<> class numeric_limits<double>
round_to_nearest>
{
public:
static double min() throw() { return DBL_MIN; }
static double min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return DBL_MIN; }
static double denorm_min() throw() { return DBL_MIN; }
static double max() throw() { return DBL_MAX; }
static double max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return DBL_MAX; }
static double epsilon() throw() { return DBL_EPSILON; }
static double round_error() throw() { return 0.5; } // Units: ulps.
};
@ -444,9 +435,9 @@ template<> class numeric_limits<long double>
round_to_nearest>
{
public:
static long double min() throw() { return LDBL_MIN; }
static long double min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return LDBL_MIN; }
static long double denorm_min() throw() { return LDBL_MIN; }
static long double max() throw() { return LDBL_MAX; }
static long double max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return LDBL_MAX; }
static long double epsilon() throw() { return LDBL_EPSILON; }
static long double round_error() throw() { return 4; } // Units: ulps.
};

View File

@ -65,14 +65,14 @@ void test_integral_limits(const T &, const char * msg)
typedef std::numeric_limits<T> lim;
std::cout << "Testing " << msg
<< " (size " << sizeof(T) << ")"
<< " min: " << make_char_numeric_for_streaming(lim::min())
<< ", max: " << make_char_numeric_for_streaming(lim::max())
<< " min: " << make_char_numeric_for_streaming((lim::min)())
<< ", max: " << make_char_numeric_for_streaming((lim::max)())
<< std::endl;
BOOST_TEST(lim::is_specialized);
BOOST_TEST(lim::is_integer);
// BOOST_TEST(lim::is_modulo);
BOOST_TEST(lim::min() < lim::max());
BOOST_TEST((lim::min)() < (lim::max)());
}
template <class T>
@ -107,16 +107,16 @@ void test_float_limits(const T &, const char * msg)
<< ", traps: " << lim::traps
<< ", bounded: " << lim::is_bounded
<< ", exact: " << lim::is_exact << '\n'
<< "min: " << lim::min() << ", max: " << lim::max() << '\n'
<< "min: " << (lim::min)() << ", max: " << (lim::max)() << '\n'
<< "infinity: " << infinity << ", QNaN: " << qnan << '\n';
print_hex_val(lim::max(), "max");
print_hex_val((lim::max)(), "max");
print_hex_val(infinity, "infinity");
print_hex_val(qnan, "qnan");
print_hex_val(snan, "snan");
BOOST_TEST(lim::max() > 1000);
BOOST_TEST(lim::min() > 0);
BOOST_TEST(lim::min() < 0.001);
BOOST_TEST((lim::max)() > 1000);
BOOST_TEST((lim::min)() > 0);
BOOST_TEST((lim::min)() < 0.001);
BOOST_TEST(lim::epsilon() > 0);
if(lim::is_iec559) {
@ -130,8 +130,8 @@ void test_float_limits(const T &, const char * msg)
if(lim::has_infinity) {
// Make sure those values are not 0 or similar nonsense.
// Infinity must compare as if larger than the maximum representable value.
BOOST_TEST(infinity > lim::max());
BOOST_TEST(-infinity < -lim::max());
BOOST_TEST(infinity > (lim::max)());
BOOST_TEST(-infinity < -(lim::max)());
} else {
std::cout << "Does not have infinity" << std::endl;
}