]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/integer_traits.hpp
Don't allow newline characters in document settings.
[lyx.git] / boost / boost / integer_traits.hpp
index 5510b1112d4c684dc0fc7107e480b53e8bf5b852..774d0588756ac51fcf48f5a33e626c7fc8c879ac 100644 (file)
@@ -1,16 +1,11 @@
 /* boost integer_traits.hpp header file
  *
  * Copyright Jens Maurer 2000
- * Permission to use, copy, modify, sell, and distribute this software
- * is hereby granted without fee provided that the above copyright notice
- * appears in all copies and that both that copyright notice and this
- * permission notice appear in supporting documentation,
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
  *
- * Jens Maurer makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * $Id: integer_traits.hpp,v 1.23 2003/08/27 10:30:53 johnmaddock Exp $
+ * $Id: integer_traits.hpp 72951 2011-07-07 04:57:37Z steven_watanabe $
  *
  * Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers
  */
 
 // These are an implementation detail and not part of the interface
 #include <limits.h>
-#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && !defined(BOOST_NO_CWCHAR)
+// we need wchar.h for WCHAR_MAX/MIN but not all platforms provide it,
+// and some may have <wchar.h> but not <cwchar> ...
+#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && (!defined(BOOST_NO_CWCHAR) || defined(sun) || defined(__sun) || defined(__QNX__))
 #include <wchar.h>
 #endif
 
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// ../../../boost/integer_traits.hpp:164:66: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
 
 namespace boost {
 template<class T>
@@ -91,7 +99,9 @@ class integer_traits<unsigned char>
 template<>
 class integer_traits<wchar_t>
   : public std::numeric_limits<wchar_t>,
-#if defined(WCHAR_MIN) && defined(WCHAR_MAX)
+    // Don't trust WCHAR_MIN and WCHAR_MAX with Mac OS X's native
+    // library: they are wrong!
+#if defined(WCHAR_MIN) && defined(WCHAR_MAX) && !defined(__APPLE__)
     public detail::integer_traits_base<wchar_t, WCHAR_MIN, WCHAR_MAX>
 #elif defined(__BORLANDC__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__))
     // No WCHAR_MIN and WCHAR_MAX, whar_t is short and unsigned:
@@ -101,6 +111,7 @@ class integer_traits<wchar_t>
     || (defined(__OpenBSD__) && defined(__GNUC__))\
     || (defined(__NetBSD__) && defined(__GNUC__))\
     || (defined(__FreeBSD__) && defined(__GNUC__))\
+    || (defined(__DragonFly__) && defined(__GNUC__))\
     || (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
     // No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as int.
     //  - SGI MIPSpro with native library
@@ -159,53 +170,84 @@ class integer_traits<unsigned long>
 #if defined(ULLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
 
 template<>
-class integer_traits<long long>
-  : public std::numeric_limits<long long>,
-    public detail::integer_traits_base<long long, LLONG_MIN, LLONG_MAX>
+class integer_traits< ::boost::long_long_type>
+  : public std::numeric_limits< ::boost::long_long_type>,
+    public detail::integer_traits_base< ::boost::long_long_type, LLONG_MIN, LLONG_MAX>
 { };
 
 template<>
-class integer_traits<unsigned long long>
-  : public std::numeric_limits<unsigned long long>,
-    public detail::integer_traits_base<unsigned long long, 0, ULLONG_MAX>
+class integer_traits< ::boost::ulong_long_type>
+  : public std::numeric_limits< ::boost::ulong_long_type>,
+    public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULLONG_MAX>
 { };
 
 #elif defined(ULONG_LONG_MAX) && defined(BOOST_HAS_LONG_LONG)
 
 template<>
-class integer_traits<long long>  : public std::numeric_limits<long long>,    public detail::integer_traits_base<long long, LONG_LONG_MIN, LONG_LONG_MAX>{ };
+class integer_traits< ::boost::long_long_type>  : public std::numeric_limits< ::boost::long_long_type>,    public detail::integer_traits_base< ::boost::long_long_type, LONG_LONG_MIN, LONG_LONG_MAX>{ };
 template<>
-class integer_traits<unsigned long long>
-  : public std::numeric_limits<unsigned long long>,
-    public detail::integer_traits_base<unsigned long long, 0, ULONG_LONG_MAX>
+class integer_traits< ::boost::ulong_long_type>
+  : public std::numeric_limits< ::boost::ulong_long_type>,
+    public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULONG_LONG_MAX>
 { };
 
 #elif defined(ULONGLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
 
 template<>
-class integer_traits<long long>
-  : public std::numeric_limits<long long>,
-    public detail::integer_traits_base<long long, LONGLONG_MIN, LONGLONG_MAX>
+class integer_traits< ::boost::long_long_type>
+  : public std::numeric_limits< ::boost::long_long_type>,
+    public detail::integer_traits_base< ::boost::long_long_type, LONGLONG_MIN, LONGLONG_MAX>
 { };
 
 template<>
-class integer_traits<unsigned long long>
-  : public std::numeric_limits<unsigned long long>,
-    public detail::integer_traits_base<unsigned long long, 0, ULONGLONG_MAX>
+class integer_traits< ::boost::ulong_long_type>
+  : public std::numeric_limits< ::boost::ulong_long_type>,
+    public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULONGLONG_MAX>
 { };
 
 #elif defined(_LLONG_MAX) && defined(_C2) && defined(BOOST_HAS_LONG_LONG)
 
 template<>
-class integer_traits<long long>
-  : public std::numeric_limits<long long>,
-    public detail::integer_traits_base<long long, -_LLONG_MAX - _C2, _LLONG_MAX>
+class integer_traits< ::boost::long_long_type>
+  : public std::numeric_limits< ::boost::long_long_type>,
+    public detail::integer_traits_base< ::boost::long_long_type, -_LLONG_MAX - _C2, _LLONG_MAX>
+{ };
+
+template<>
+class integer_traits< ::boost::ulong_long_type>
+  : public std::numeric_limits< ::boost::ulong_long_type>,
+    public detail::integer_traits_base< ::boost::ulong_long_type, 0, _ULLONG_MAX>
+{ };
+
+#elif defined(BOOST_HAS_LONG_LONG)
+//
+// we have long long but no constants, this happens for example with gcc in -ansi mode,
+// we'll just have to work out the values for ourselves (assumes 2's compliment representation):
+//
+template<>
+class integer_traits< ::boost::long_long_type>
+  : public std::numeric_limits< ::boost::long_long_type>,
+    public detail::integer_traits_base< ::boost::long_long_type, (1LL << (sizeof(::boost::long_long_type) * CHAR_BIT - 1)), ~(1LL << (sizeof(::boost::long_long_type) * CHAR_BIT - 1))>
+{ };
+
+template<>
+class integer_traits< ::boost::ulong_long_type>
+  : public std::numeric_limits< ::boost::ulong_long_type>,
+    public detail::integer_traits_base< ::boost::ulong_long_type, 0, ~0uLL>
+{ };
+
+#elif defined(BOOST_HAS_MS_INT64)
+
+template<>
+class integer_traits< __int64>
+  : public std::numeric_limits< __int64>,
+    public detail::integer_traits_base< __int64, _I64_MIN, _I64_MAX>
 { };
 
 template<>
-class integer_traits<unsigned long long>
-  : public std::numeric_limits<unsigned long long>,
-    public detail::integer_traits_base<unsigned long long, 0, _ULLONG_MAX>
+class integer_traits< unsigned __int64>
+  : public std::numeric_limits< unsigned __int64>,
+    public detail::integer_traits_base< unsigned __int64, 0, _UI64_MAX>
 { };
 
 #endif