]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/detail/limits.hpp
Don't allow newline characters in document settings.
[lyx.git] / boost / boost / detail / limits.hpp
index e1da40598617f81c8d3882bae141986dfc13e3c1..6f018dfaca79badd4842f5e4cbbb623b06b0f6d2 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright 2001 John Maddock
+// Distributed under the Boost Software License, Version 1.0. (See accompany-
+// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
 /*
  * Copyright (c) 1997
  * Silicon Graphics Computer Systems, Inc.
  * are almost certainly incorrect for any other platform.
  */
 
+/* The above comment is almost certainly out of date. This file works
+ * on systems other than SGI MIPSpro C++ now.
+ */
+
 /*
  * Revision history:
+ * 21 Sep 2001:
+ *    Only include <cwchar> if BOOST_NO_CWCHAR is defined. (Darin Adler)
+ * 10 Aug 2001:
+ *    Added MIPS (big endian) to the big endian family. (Jens Maurer)
  * 13 Apr 2001:
  *    Added powerpc to the big endian family. (Jeremy Siek)
  * 5 Apr 2001:
  *    Added sparc (big endian) processor support (John Maddock).
  * Initial sub:
- *     Modified by Jens Maurer for gcc 2.95 on x86.
+ *      Modified by Jens Maurer for gcc 2.95 on x86.
  */
 
 #ifndef BOOST_SGI_CPP_LIMITS
 #include <climits>
 #include <cfloat>
 #include <boost/config.hpp>
+#include <boost/detail/endian.hpp>
 
-#if defined(__sparc) || defined(__sparc__) || defined(__powerpc__) || defined(__hppa)
-#define BOOST_BIG_ENDIAN
-#elif !defined(__i386__)
-#error The file boost/detail/limits.hpp needs to be set up for your CPU type.
+#ifndef BOOST_NO_CWCHAR
+#include <cwchar> // for WCHAR_MIN and WCHAR_MAX
 #endif
 
 namespace std {
@@ -79,14 +90,13 @@ enum float_denorm_style {
 #endif /* BOOST_NO_INCLASS_MEMBER_INITIALIZATION */
 
 // 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);
@@ -140,8 +150,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,
@@ -180,7 +190,7 @@ public:
     const unsigned int _S_word[4] = { 0, 0, 0, Word };
     return *reinterpret_cast<const Number*>(
         reinterpret_cast<const char *>(&_S_word)+16-
-               (sizeof(Number) == 12 ? 10 : sizeof(Number)));
+                (sizeof(Number) == 12 ? 10 : sizeof(Number)));
   } 
 };
 
@@ -269,24 +279,23 @@ class numeric_limits<unsigned char>
 {};
 
 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
-#if !defined(WCHAR_MAX) || !defined(WCHAR_MIN)
-#if !defined(_WIN32) && !defined(__CYGWIN__)
-template<>
-class numeric_limits<wchar_t>
-  : public _Integer_limits<wchar_t, INT_MIN, INT_MAX>
-{};
-#else
 template<>
 class numeric_limits<wchar_t>
+#if !defined(WCHAR_MAX) || !defined(WCHAR_MIN)
+#if defined(_WIN32) || defined(__CYGWIN__)
   : public _Integer_limits<wchar_t, 0, USHRT_MAX>
-{};
+#elif defined(__hppa)
+// wchar_t has "unsigned int" as the underlying type
+  : public _Integer_limits<wchar_t, 0, UINT_MAX>
+#else
+// assume that wchar_t has "int" as the underlying type
+  : public _Integer_limits<wchar_t, INT_MIN, INT_MAX>
 #endif
 #else
-template<>
-class numeric_limits<wchar_t>
+// we have WCHAR_MIN and WCHAR_MAX defined, so use it
   : public _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX>
-{};
 #endif
+{};
 #endif
 
 template<>
@@ -324,24 +333,21 @@ class numeric_limits<unsigned long>
 // Some compilers have long long, but don't define the
 // LONGLONG_MIN and LONGLONG_MAX macros in limits.h.  This
 // assumes that long long is 64 bits.
-#if !defined(LONGLONG_MIN) && !defined(LONGLONG_MAX) \
-                           && !defined(ULONGLONG_MAX)
+#if !defined(LONGLONG_MAX) && !defined(ULONGLONG_MAX)
 
-#define ULONGLONG_MAX 0xffffffffffffffffLLU
-#define LONGLONG_MAX 0x7fffffffffffffffLL
-#define LONGLONG_MIN (-LONGLONG_MAX - 1)
+# define ULONGLONG_MAX 0xffffffffffffffffLLU
+# define LONGLONG_MAX 0x7fffffffffffffffLL
 
 #endif
 
-template<>
-class numeric_limits<long long>
-  : public _Integer_limits<long long, LONGLONG_MIN, LONGLONG_MAX>
-{};
+#if !defined(LONGLONG_MIN)
+# define LONGLONG_MIN (-LONGLONG_MAX - 1)
+#endif 
 
-template<>
-class numeric_limits<unsigned long long>
-  : public _Integer_limits<unsigned long long, 0, ULONGLONG_MAX>
-{};
+
+#if !defined(ULONGLONG_MIN)
+# define ULONGLONG_MIN 0
+#endif 
 
 #endif /* __GNUC__ */
 
@@ -368,9 +374,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.
 };
@@ -396,9 +402,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.
 };
@@ -424,9 +430,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.
 };