$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r57579 - sandbox/integer/boost
From: john_at_[hidden]
Date: 2009-11-11 13:53:32
Author: johnmaddock
Date: 2009-11-11 13:53:30 EST (Wed, 11 Nov 2009)
New Revision: 57579
URL: http://svn.boost.org/trac/boost/changeset/57579
Log:
Double oops - get the right versions!
Text files modified: 
   sandbox/integer/boost/integer.hpp        |   383 +++++++++++++++++++++++++++++++++------ 
   sandbox/integer/boost/integer_fwd.hpp    |    78 +++++---                                
   sandbox/integer/boost/integer_traits.hpp |    81 +------                                 
   3 files changed, 385 insertions(+), 157 deletions(-)
Modified: sandbox/integer/boost/integer.hpp
==============================================================================
--- sandbox/integer/boost/integer.hpp	(original)
+++ sandbox/integer/boost/integer.hpp	2009-11-11 13:53:30 EST (Wed, 11 Nov 2009)
@@ -7,6 +7,12 @@
 //  See http://www.boost.org/libs/integer for documentation.
 
 //  Revision History
+//   16 Jul 08  Added MPL-compatible variants of the minimum-size and value-
+//              based integer templates. (Daryle Walker)
+//   15 Jul 08  Added exact-integer templates; added MPL-compatible variant of
+//              processor-optimized integer template. (Daryle Walker)
+//   14 Jul 08  Added extended-integer support. (Daryle Walker)
+//   13 Jul 08  Redid implmentation. (Daryle Walker)
 //   22 Sep 01  Added value-based integer templates. (Daryle Walker)
 //   01 Apr 01  Modified to use new <boost/limits.hpp> header. (John Maddock)
 //   30 Jul 00  Add typename syntax fix (Jens Maurer)
@@ -17,108 +23,357 @@
 
 #include <boost/integer_fwd.hpp>  // self include
 
-#include <boost/integer_traits.hpp>  // for boost::integer_traits
-#include <boost/limits.hpp>          // for std::numeric_limits
+#include <boost/config.hpp>             // for BOOST_STATIC_CONSTANT, etc.
+#include <boost/cstdint.hpp>            // for boost::uintmax_t, intmax_t
+#include <boost/integer_traits.hpp>     // for boost::integer_traits
+#include <boost/limits.hpp>             // for std::numeric_limits
+#include <boost/utility/enable_if.hpp>  // for boost::enable_if_c
+
+#include <boost/detail/extended_integer.hpp>  // for BOOST_HAS_XINT, etc.
+
+#include <climits>  // for UCHAR_MAX, USHRT_MAX, UINT_MAX, ULONG_MAX, etc.
 
 namespace boost
 {
 
-  //  Helper templates  ------------------------------------------------------//
+  //  integer template mapping a type to its processor-optimized analog  -----//
+
+  //  Some types can be handled better by the processor than others.  This
+  //  template metafunction should map various built-in integral types to
+  //  the processor's perferred type for the given type's value range
+  template < typename BaseInt >
+  struct fast_integral
+  {
+      typedef BaseInt  type;
+  };
+
+  // Platform-specific specializations should go here.
 
   //  fast integers from least integers
   //  int_fast_t<> works correctly for unsigned too, in spite of the name.
   template< typename LeastInt >
-  struct int_fast_t { typedef LeastInt fast; }; // imps may specialize
+  struct int_fast_t { typedef typename fast_integral<LeastInt>::type fast; };
 
-  //  convert category to type 
-  template< int Category > struct int_least_helper {}; // default is empty
+namespace detail
+{
+
+  //  Helper templates  ------------------------------------------------------//
 
-  //  specializatons: 1=long, 2=int, 3=short, 4=signed char,
-  //     6=unsigned long, 7=unsigned int, 8=unsigned short, 9=unsigned char
-  //  no specializations for 0 and 5: requests for a type > long are in error
-  template<> struct int_least_helper<1> { typedef long least; };
-  template<> struct int_least_helper<2> { typedef int least; };
-  template<> struct int_least_helper<3> { typedef short least; };
-  template<> struct int_least_helper<4> { typedef signed char least; };
-  template<> struct int_least_helper<6> { typedef unsigned long least; };
-  template<> struct int_least_helper<7> { typedef unsigned int least; };
-  template<> struct int_least_helper<8> { typedef unsigned short least; };
-  template<> struct int_least_helper<9> { typedef unsigned char least; };
+  //  convert integer category to type ; default is empty
+  template< int Rank, typename Signedness > struct  int_least_helper {};
+
+  //  specializatons: 1=(unsigned) __int64/long long, 2=(unsigned) long,
+  //     3=unsigned/int, 4=(unsigned) short, 5=(un)signed char
+  //  no specializations for 0: requests for a type > (unsigned) (long) long are
+  //     in error
+#if BOOST_HAS_XINT
+  template<> struct int_least_helper<1,   signed>  { typedef  xint_t least; };
+  template<> struct int_least_helper<1, unsigned>  { typedef uxint_t least; };
+#endif
+  template<> struct int_least_helper<2, signed> { typedef long least; };
+  template<> struct int_least_helper<2, unsigned>
+   { typedef unsigned long least; };
+  template<> struct int_least_helper<3, signed> { typedef int least; };
+  template<> struct int_least_helper<3, unsigned>
+   { typedef unsigned int least; };
+  template<> struct int_least_helper<4, signed> { typedef short least; };
+  template<> struct int_least_helper<4, unsigned>
+   { typedef unsigned short least; };
+  template<> struct int_least_helper<5, signed> { typedef signed char least; };
+  template<> struct int_least_helper<5, unsigned>
+   { typedef unsigned char least; };
+
+  //  category bounds
+  enum
+  {
+#if BOOST_HAS_XINT
+      lowest_integral_rank  = 1,
+#else
+      lowest_integral_rank  = 2,
+#endif
+      highest_integral_rank = 5
+  };
+
+  //  map a bit count to a category
+  template < int BitsIncludingSign >
+  struct int_rank_helper
+  {
+      BOOST_STATIC_CONSTANT( int, mantissa = BitsIncludingSign - 1 );
+#if BOOST_HAS_XINT
+      BOOST_STATIC_CONSTANT( int, extended_ = (mantissa <= std::numeric_limits<
+       xint_t >::digits) );
+#else
+      BOOST_STATIC_CONSTANT( int, extended_ = 1 );
+#endif
+      BOOST_STATIC_CONSTANT( int, rank = (BitsIncludingSign > 0) * (extended_ +
+       (mantissa <= std::numeric_limits< long >::digits) +
+       (mantissa <= std::numeric_limits< int >::digits) +
+       (mantissa <= std::numeric_limits< short >::digits) +
+       (mantissa <= std::numeric_limits< signed char >::digits)) );
+  };
+
+  template < int Bits >
+  struct uint_rank_helper
+  {
+#if BOOST_HAS_XINT
+      BOOST_STATIC_CONSTANT( int, extended_ = (Bits <= std::numeric_limits<
+       uxint_t >::digits) );
+#else
+      BOOST_STATIC_CONSTANT( int, extended_ = 1 );
+#endif
+      BOOST_STATIC_CONSTANT( int, rank = (Bits >= 0) * (extended_ +
+       (Bits <= std::numeric_limits< unsigned long >::digits) +
+       (Bits <= std::numeric_limits< unsigned int >::digits) +
+       (Bits <= std::numeric_limits< unsigned short >::digits) +
+       (Bits <= std::numeric_limits< unsigned char >::digits)) );
+  };
+
+  template < int BitsIncludingSign >
+  struct int_exact_rank_helper   { BOOST_STATIC_CONSTANT( int, rank = 0 ); };
+  template < int Bits >
+  struct uint_exact_rank_helper  { BOOST_STATIC_CONSTANT( int, rank = 0 ); };
+
+#define BOOST_PRIVATE_INT_EXACT_BUILDER(Type, Rank) \
+  template < > \
+  struct int_exact_rank_helper<std::numeric_limits< Type >::digits + 1> \
+  { BOOST_STATIC_CONSTANT( int, rank = Rank ); }
+#define BOOST_PRIVATE_UINT_EXACT_BUILDER(Type, Rank) \
+  template < > \
+  struct uint_exact_rank_helper<std::numeric_limits< Type >::digits> \
+  { BOOST_STATIC_CONSTANT( int, rank = Rank ); }
+
+#if BOOST_HAS_XINT && (BOOST_UXINT_MAX > ULONG_MAX)
+  BOOST_PRIVATE_INT_EXACT_BUILDER( xint_t, 1 );
+  BOOST_PRIVATE_UINT_EXACT_BUILDER( uxint_t, 1 );
+#endif
+#if ULONG_MAX > UINT_MAX
+  BOOST_PRIVATE_INT_EXACT_BUILDER( long, 2 );
+  BOOST_PRIVATE_UINT_EXACT_BUILDER( unsigned long, 2 );
+#endif
+#if UINT_MAX > USHRT_MAX
+  BOOST_PRIVATE_INT_EXACT_BUILDER( int, 3 );
+  BOOST_PRIVATE_UINT_EXACT_BUILDER( unsigned, 3 );
+#endif
+#if USHRT_MAX > UCHAR_MAX
+  BOOST_PRIVATE_INT_EXACT_BUILDER( short, 4 );
+  BOOST_PRIVATE_UINT_EXACT_BUILDER( unsigned short, 4 );
+#endif
+  BOOST_PRIVATE_INT_EXACT_BUILDER( signed char, 5 );
+  BOOST_PRIVATE_UINT_EXACT_BUILDER( unsigned char, 5 );
+
+#undef BOOST_PRIVATE_INT_EXACT_BUILDER
+#undef BOOST_PRIVATE_UINT_EXACT_BUILDER
+
+  //  map an extreme value to a category
+  template < intmax_t MaxValue >
+  struct int_max_rank_helper
+  {
+#if BOOST_HAS_XINT
+      BOOST_STATIC_CONSTANT( int, extended_ = (MaxValue <=
+       boost::integer_traits< xint_t >::const_max) );
+#else
+      BOOST_STATIC_CONSTANT( int, extended_ = 1 );
+#endif
+      BOOST_STATIC_CONSTANT( int, rank = (MaxValue > 0) * (extended_ +
+       (MaxValue <= boost::integer_traits< long >::const_max) +
+       (MaxValue <= boost::integer_traits< int >::const_max) +
+       (MaxValue <= boost::integer_traits< short >::const_max) +
+       (MaxValue <= boost::integer_traits< signed char >::const_max)) );
+  };
+
+  template < intmax_t MinValue >
+  struct int_min_rank_helper
+  {
+#if BOOST_HAS_XINT
+      BOOST_STATIC_CONSTANT( int, extended_ = (MinValue >=
+       boost::integer_traits< xint_t >::const_min) );
+#else
+      BOOST_STATIC_CONSTANT( int, extended_ = 1 );
+#endif
+      BOOST_STATIC_CONSTANT( int, rank = (MinValue < 0) * (extended_ +
+       (MinValue >= boost::integer_traits< long >::const_min) +
+       (MinValue >= boost::integer_traits< int >::const_min) +
+       (MinValue >= boost::integer_traits< short >::const_min) +
+       (MinValue >= boost::integer_traits< signed char >::const_min)) );
+  };
+
+  template < uintmax_t Value >
+  struct uint_max_rank_helper
+  {
+#if BOOST_HAS_XINT
+      BOOST_STATIC_CONSTANT( int, extended_ = (Value <= boost::integer_traits<
+       uxint_t >::const_max) );
+#else
+      BOOST_STATIC_CONSTANT( int, extended_ = 1 );
+#endif
+      BOOST_STATIC_CONSTANT( int, rank = extended_ +
+       (Value <= boost::integer_traits< unsigned long >::const_max) +
+       (Value <= boost::integer_traits< unsigned int >::const_max) +
+       (Value <= boost::integer_traits< unsigned short >::const_max) +
+       (Value <= boost::integer_traits< unsigned char >::const_max) );
+  };
+
+  //  convert rank to type, Boost.MPL-style
+  template < int Rank, typename Signedness, class Enable = void >
+  struct integral_rank_to_type
+  {
+      BOOST_STATIC_CONSTANT( bool, is_specialized = false );
+      // No "signed" nor "type" here
+  };
+
+  template < int Rank >
+  struct integral_rank_to_type< Rank, signed, typename
+   enable_if_c<(lowest_integral_rank <= Rank) && (Rank <=
+   highest_integral_rank)>::type >
+  {
+      BOOST_STATIC_CONSTANT( bool, is_specialized = true );
+      BOOST_STATIC_CONSTANT( bool, is_signed = true );
+      typedef typename int_least_helper< Rank, signed >::least  type;
+  };
+
+  template < int Rank >
+  struct integral_rank_to_type< Rank, unsigned, typename
+   enable_if_c<(lowest_integral_rank <= Rank) && (Rank <=
+   highest_integral_rank)>::type >
+  {
+      BOOST_STATIC_CONSTANT( bool, is_specialized = true );
+      BOOST_STATIC_CONSTANT( bool, is_signed = false );
+      typedef typename int_least_helper< Rank, unsigned >::least  type;
+  };
+
+} // namespace detail
+
+  //  MPL-compatible integer-mapping class templates  ------------------------//
+
+  //  minimum number of bits
+  template < int Bits, typename Signedness >
+  struct sized_integral
+  {
+      BOOST_STATIC_CONSTANT( bool, is_specialized = false );
+      BOOST_STATIC_CONSTANT( int, bit_count = Bits );
+  };
+
+  template < int BitsIncludingSign >
+  struct sized_integral< BitsIncludingSign, signed >
+      : detail::integral_rank_to_type<
+         detail::int_rank_helper<BitsIncludingSign>::rank, signed >
+  {
+      BOOST_STATIC_CONSTANT( int, bit_count = BitsIncludingSign );
+  };
+
+  template < int Bits >
+  struct sized_integral< Bits, unsigned >
+      : detail::integral_rank_to_type<
+         detail::uint_rank_helper<Bits>::rank, unsigned >
+  {
+      BOOST_STATIC_CONSTANT( int, bit_count = Bits );
+  };
+
+  //  exact number of bits
+  template < int Bits, typename Signedness >
+  struct exact_integral
+  {
+      BOOST_STATIC_CONSTANT( bool, is_specialized = false );
+      BOOST_STATIC_CONSTANT( int, bit_count = Bits );
+  };
+
+  template < int BitsIncludingSign >
+  struct exact_integral< BitsIncludingSign, signed >
+      : detail::integral_rank_to_type<
+         detail::int_exact_rank_helper<BitsIncludingSign>::rank, signed >
+  {
+      BOOST_STATIC_CONSTANT( int, bit_count = BitsIncludingSign );
+  };
+
+  template < int Bits >
+  struct exact_integral< Bits, unsigned >
+      : detail::integral_rank_to_type<
+         detail::uint_exact_rank_helper<Bits>::rank, unsigned >
+  {
+      BOOST_STATIC_CONSTANT( int, bit_count = Bits );
+  };
+
+  //  maximum supported (positive) value, signed
+  template < intmax_t MaxValue >
+  struct maximum_signed_integral
+      : detail::integral_rank_to_type<
+         detail::int_max_rank_helper<MaxValue>::rank, signed >
+  {
+      BOOST_STATIC_CONSTANT( intmax_t, bound = MaxValue );
+  };
+
+  //  minimum supported (negative) value
+  template < intmax_t MinValue >
+  struct minimum_signed_integral
+      : detail::integral_rank_to_type<
+         detail::int_min_rank_helper<MinValue>::rank, signed >
+  {
+      BOOST_STATIC_CONSTANT( intmax_t, bound = MinValue );
+  };
+
+  //  maximum supported (nonnegative) value, unsigned
+  template < uintmax_t Value >
+  struct maximum_unsigned_integral
+      : detail::integral_rank_to_type<
+         detail::uint_max_rank_helper<Value>::rank, unsigned >
+  {
+      BOOST_STATIC_CONSTANT( uintmax_t, bound = Value );
+  };
 
   //  integer templates specifying number of bits  ---------------------------//
 
   //  signed
-  template< int Bits >   // bits (including sign) required
+  template< int Bits >   // minimum bits (including sign) required
   struct int_t 
   {
-      typedef typename int_least_helper
-        <
-          (Bits-1 <= std::numeric_limits<long>::digits) +
-          (Bits-1 <= std::numeric_limits<int>::digits) +
-          (Bits-1 <= std::numeric_limits<short>::digits) +
-          (Bits-1 <= std::numeric_limits<signed char>::digits)
-        >::least  least;
-      typedef typename int_fast_t<least>::fast  fast;
+      typedef typename sized_integral<Bits, signed>::type  least;
+      typedef typename int_fast_t<least>::fast             fast;
+  };
+
+  template< int Bits >   // exact bits (including sign) desired
+  struct int_exact_t
+  {
+      typedef typename exact_integral<Bits, signed>::type  exact;
   };
 
   //  unsigned
-  template< int Bits >   // bits required
+  template< int Bits >   // minimum bits required
   struct uint_t 
   {
-      typedef typename int_least_helper
-        < 
-          5 +
-          (Bits <= std::numeric_limits<unsigned long>::digits) +
-          (Bits <= std::numeric_limits<unsigned int>::digits) +
-          (Bits <= std::numeric_limits<unsigned short>::digits) +
-          (Bits <= std::numeric_limits<unsigned char>::digits)
-        >::least  least;
-      typedef typename int_fast_t<least>::fast  fast;
+      typedef typename sized_integral<Bits, unsigned>::type  least;
+      typedef typename int_fast_t<least>::fast               fast;
       // int_fast_t<> works correctly for unsigned too, in spite of the name.
   };
 
+  template< int Bits >   // exact bits desired
+  struct uint_exact_t
+  {
+      typedef typename exact_integral<Bits, unsigned>::type  exact;
+  };
+
   //  integer templates specifying extreme value  ----------------------------//
 
   //  signed
-  template< long MaxValue >   // maximum value to require support
+  template< intmax_t MaxValue >   // maximum value to require support
   struct int_max_value_t 
   {
-      typedef typename int_least_helper
-        <
-          (MaxValue <= integer_traits<long>::const_max) +
-          (MaxValue <= integer_traits<int>::const_max) +
-          (MaxValue <= integer_traits<short>::const_max) +
-          (MaxValue <= integer_traits<signed char>::const_max)
-        >::least  least;
-      typedef typename int_fast_t<least>::fast  fast;
+      typedef typename maximum_signed_integral<MaxValue>::type  least;
+      typedef typename int_fast_t<least>::fast                  fast;
   };
 
-  template< long MinValue >   // minimum value to require support
+  template< intmax_t MinValue >   // minimum value to require support
   struct int_min_value_t 
   {
-      typedef typename int_least_helper
-        <
-          (MinValue >= integer_traits<long>::const_min) +
-          (MinValue >= integer_traits<int>::const_min) +
-          (MinValue >= integer_traits<short>::const_min) +
-          (MinValue >= integer_traits<signed char>::const_min)
-        >::least  least;
-      typedef typename int_fast_t<least>::fast  fast;
+      typedef typename minimum_signed_integral<MinValue>::type  least;
+      typedef typename int_fast_t<least>::fast                  fast;
   };
 
   //  unsigned
-  template< unsigned long Value >   // maximum value to require support
+  template< uintmax_t Value >   // maximum value to require support
   struct uint_value_t 
   {
-      typedef typename int_least_helper
-        < 
-          5 +
-          (Value <= integer_traits<unsigned long>::const_max) +
-          (Value <= integer_traits<unsigned int>::const_max) +
-          (Value <= integer_traits<unsigned short>::const_max) +
-          (Value <= integer_traits<unsigned char>::const_max)
-        >::least  least;
-      typedef typename int_fast_t<least>::fast  fast;
+      typedef typename maximum_unsigned_integral<Value>::type  least;
+      typedef typename int_fast_t<least>::fast                 fast;
   };
 
 
Modified: sandbox/integer/boost/integer_fwd.hpp
==============================================================================
--- sandbox/integer/boost/integer_fwd.hpp	(original)
+++ sandbox/integer/boost/integer_fwd.hpp	2009-11-11 13:53:30 EST (Wed, 11 Nov 2009)
@@ -9,11 +9,12 @@
 #ifndef BOOST_INTEGER_FWD_HPP
 #define BOOST_INTEGER_FWD_HPP
 
-#include <climits>  // for UCHAR_MAX, etc.
 #include <cstddef>  // for std::size_t
 
-#include <boost/config.hpp>  // for BOOST_NO_INTRINSIC_WCHAR_T
-#include <boost/limits.hpp>  // for std::numeric_limits
+#include <boost/config.hpp>   // for BOOST_NO_INTRINSIC_WCHAR_T, etc.
+#include <boost/cstdint.hpp>  // for boost::uintmax_t, intmax_t
+
+#include <boost/detail/extended_integer.hpp>  // for BOOST_HAS_XINT, etc.
 
 
 namespace boost
@@ -24,6 +25,13 @@
 
 // Only has typedefs or using statements, with #conditionals
 
+// ALERT: the forward declarations of items in <boost/integer.hpp> need items
+// from this header.  That means that <boost/cstdint.hpp> cannot #include this
+// forwarding header, to avoid infinite recursion!  One day, maybe
+// boost::uintmax_t and boost::intmax_t could be segregated into their own
+// header file (which can't #include this header), <boost/integer.hpp> will use
+// that header, and <boost/cstdint.hpp> could refer to <boost/integer.hpp>.
+
 
 //  From <boost/integer_traits.hpp>  -----------------------------------------//
 
@@ -65,61 +73,73 @@
 template <  >
     class integer_traits< unsigned long >;
 
-#ifdef ULLONG_MAX
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && BOOST_HAS_XINT
 template <  >
-    class integer_traits<  ::boost::long_long_type>;
+    class integer_traits< ::boost::detail::xint_t >;
 
 template <  >
-    class integer_traits<  ::boost::ulong_long_type >;
+    class integer_traits< ::boost::detail::uxint_t >;
 #endif
 
 
 //  From <boost/integer.hpp>  ------------------------------------------------//
 
+template < typename BaseInt >
+    struct fast_integral;
+
 template < typename LeastInt >
     struct int_fast_t;
 
+template < int Bits, typename Signedness >
+    struct sized_integral;
+
+template < int Bits, typename Signedness >
+    struct exact_integral;
+
+template < intmax_t MaxValue >
+    struct maximum_signed_integral;
+
+template < intmax_t MinValue >
+    struct minimum_signed_integral;
+
+template < uintmax_t Value >
+    struct maximum_unsigned_integral;
+
 template< int Bits >
     struct int_t;
 
 template< int Bits >
+    struct int_exact_t;
+
+template< int Bits >
     struct uint_t;
 
-template< long MaxValue >
+template< int Bits >
+    struct uint_exact_t;
+
+template< intmax_t MaxValue >
     struct int_max_value_t;
 
-template< long MinValue >
+template< intmax_t MinValue >
     struct int_min_value_t;
 
-template< unsigned long Value >
+template< uintmax_t Value >
     struct uint_value_t;
 
 
 //  From <boost/integer/integer_mask.hpp>  -----------------------------------//
 
-template < std::size_t Bit >
-    struct high_bit_mask_t;
+template < int Offset >
+    struct integer_hi_mask;
 
-template < std::size_t Bits >
-    struct low_bits_mask_t;
-
-template <  >
-    struct low_bits_mask_t< ::std::numeric_limits<unsigned char>::digits >;
-
-#if USHRT_MAX > UCHAR_MAX
-template <  >
-    struct low_bits_mask_t< ::std::numeric_limits<unsigned short>::digits >;
-#endif
+template < int Length >
+    struct integer_lo_mask;
 
-#if UINT_MAX > USHRT_MAX
-template <  >
-    struct low_bits_mask_t< ::std::numeric_limits<unsigned int>::digits >;
-#endif
+template < std::size_t Bit >
+    class high_bit_mask_t;
 
-#if ULONG_MAX > UINT_MAX
-template <  >
-    struct low_bits_mask_t< ::std::numeric_limits<unsigned long>::digits >;
-#endif
+template < std::size_t Bits >
+    class low_bits_mask_t;
 
 
 //  From <boost/integer/static_log2.hpp>  ------------------------------------//
Modified: sandbox/integer/boost/integer_traits.hpp
==============================================================================
--- sandbox/integer/boost/integer_traits.hpp	(original)
+++ sandbox/integer/boost/integer_traits.hpp	2009-11-11 13:53:30 EST (Wed, 11 Nov 2009)
@@ -27,6 +27,8 @@
 #include <wchar.h>
 #endif
 
+#include <boost/detail/extended_integer.hpp>  // for BOOST_HAS_XINT, etc.
+
 
 namespace boost {
 template<class T>
@@ -155,77 +157,28 @@
     public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
 { };
 
-#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T)
-#if defined(ULLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
-
-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, LLONG_MIN, 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(ULONG_LONG_MAX) && defined(BOOST_HAS_LONG_LONG)
-
-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, LONG_LONG_MIN, LONG_LONG_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, ULONG_LONG_MAX>
-{ };
-
-#elif defined(ULONGLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
-
-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, LONGLONG_MIN, LONGLONG_MAX>
-{ };
+#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && BOOST_HAS_XINT
 
-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, ULONGLONG_MAX>
-{ };
-
-#elif defined(_LLONG_MAX) && defined(_C2) && defined(BOOST_HAS_LONG_LONG)
-
-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, -_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):
+#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 3)))
+// 
+// The following code emits warnings when built with -pedantic, and there appears
+// to be no other way of suppressing these warnings as use of __extension__ has no 
+// effect, so declare the rest of this header a system header.
 //
+#  pragma GCC system_header
+#endif
+
 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) - 1)), ~(1LL << (sizeof(::boost::long_long_type) - 1))>
+class integer_traits< detail::xint_t >
+  : public std::numeric_limits< detail::xint_t >,
+    public detail::integer_traits_base< detail::xint_t, BOOST_XINT_MIN, BOOST_XINT_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, ~0uLL>
+class integer_traits< detail::uxint_t >
+  : public std::numeric_limits< detail::uxint_t >,
+    public detail::integer_traits_base< detail::uxint_t, 0u, BOOST_UXINT_MAX >
 { };
-
-#endif
 #endif
 
 } // namespace boost