epoc32/include/stdapis/boost/integer.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/integer.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,127 @@
     1.4 +//  boost integer.hpp header file  -------------------------------------------//
     1.5 +
     1.6 +//  Copyright Beman Dawes and Daryle Walker 1999.  Distributed under the Boost
     1.7 +//  Software License, Version 1.0. (See accompanying file
     1.8 +//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     1.9 +
    1.10 +//  See http://www.boost.org/libs/integer for documentation.
    1.11 +
    1.12 +//  Revision History
    1.13 +//   22 Sep 01  Added value-based integer templates. (Daryle Walker)
    1.14 +//   01 Apr 01  Modified to use new <boost/limits.hpp> header. (John Maddock)
    1.15 +//   30 Jul 00  Add typename syntax fix (Jens Maurer)
    1.16 +//   28 Aug 99  Initial version
    1.17 +
    1.18 +#ifndef BOOST_INTEGER_HPP
    1.19 +#define BOOST_INTEGER_HPP
    1.20 +
    1.21 +#include <boost/integer_fwd.hpp>  // self include
    1.22 +
    1.23 +#include <boost/integer_traits.hpp>  // for boost::integer_traits
    1.24 +#include <boost/limits.hpp>          // for std::numeric_limits
    1.25 +
    1.26 +namespace boost
    1.27 +{
    1.28 +
    1.29 +  //  Helper templates  ------------------------------------------------------//
    1.30 +
    1.31 +  //  fast integers from least integers
    1.32 +  //  int_fast_t<> works correctly for unsigned too, in spite of the name.
    1.33 +  template< typename LeastInt >
    1.34 +  struct int_fast_t { typedef LeastInt fast; }; // imps may specialize
    1.35 +
    1.36 +  //  convert category to type 
    1.37 +  template< int Category > struct int_least_helper {}; // default is empty
    1.38 +
    1.39 +  //  specializatons: 1=long, 2=int, 3=short, 4=signed char,
    1.40 +  //     6=unsigned long, 7=unsigned int, 8=unsigned short, 9=unsigned long
    1.41 +  //  no specializations for 0 and 5: requests for a type > long are in error
    1.42 +  template<> struct int_least_helper<1> { typedef long least; };
    1.43 +  template<> struct int_least_helper<2> { typedef int least; };
    1.44 +  template<> struct int_least_helper<3> { typedef short least; };
    1.45 +  template<> struct int_least_helper<4> { typedef signed char least; };
    1.46 +  template<> struct int_least_helper<6> { typedef unsigned long least; };
    1.47 +  template<> struct int_least_helper<7> { typedef unsigned int least; };
    1.48 +  template<> struct int_least_helper<8> { typedef unsigned short least; };
    1.49 +  template<> struct int_least_helper<9> { typedef unsigned char least; };
    1.50 +
    1.51 +  //  integer templates specifying number of bits  ---------------------------//
    1.52 +
    1.53 +  //  signed
    1.54 +  template< int Bits >   // bits (including sign) required
    1.55 +  struct int_t 
    1.56 +  {
    1.57 +      typedef typename int_least_helper
    1.58 +        <
    1.59 +          (Bits-1 <= std::numeric_limits<long>::digits) +
    1.60 +          (Bits-1 <= std::numeric_limits<int>::digits) +
    1.61 +          (Bits-1 <= std::numeric_limits<short>::digits) +
    1.62 +          (Bits-1 <= std::numeric_limits<signed char>::digits)
    1.63 +        >::least  least;
    1.64 +      typedef typename int_fast_t<least>::fast  fast;
    1.65 +  };
    1.66 +
    1.67 +  //  unsigned
    1.68 +  template< int Bits >   // bits required
    1.69 +  struct uint_t 
    1.70 +  {
    1.71 +      typedef typename int_least_helper
    1.72 +        < 
    1.73 +          5 +
    1.74 +          (Bits <= std::numeric_limits<unsigned long>::digits) +
    1.75 +          (Bits <= std::numeric_limits<unsigned int>::digits) +
    1.76 +          (Bits <= std::numeric_limits<unsigned short>::digits) +
    1.77 +          (Bits <= std::numeric_limits<unsigned char>::digits)
    1.78 +        >::least  least;
    1.79 +      typedef typename int_fast_t<least>::fast  fast;
    1.80 +      // int_fast_t<> works correctly for unsigned too, in spite of the name.
    1.81 +  };
    1.82 +
    1.83 +  //  integer templates specifying extreme value  ----------------------------//
    1.84 +
    1.85 +  //  signed
    1.86 +  template< long MaxValue >   // maximum value to require support
    1.87 +  struct int_max_value_t 
    1.88 +  {
    1.89 +      typedef typename int_least_helper
    1.90 +        <
    1.91 +          (MaxValue <= integer_traits<long>::const_max) +
    1.92 +          (MaxValue <= integer_traits<int>::const_max) +
    1.93 +          (MaxValue <= integer_traits<short>::const_max) +
    1.94 +          (MaxValue <= integer_traits<signed char>::const_max)
    1.95 +        >::least  least;
    1.96 +      typedef typename int_fast_t<least>::fast  fast;
    1.97 +  };
    1.98 +
    1.99 +  template< long MinValue >   // minimum value to require support
   1.100 +  struct int_min_value_t 
   1.101 +  {
   1.102 +      typedef typename int_least_helper
   1.103 +        <
   1.104 +          (MinValue >= integer_traits<long>::const_min) +
   1.105 +          (MinValue >= integer_traits<int>::const_min) +
   1.106 +          (MinValue >= integer_traits<short>::const_min) +
   1.107 +          (MinValue >= integer_traits<signed char>::const_min)
   1.108 +        >::least  least;
   1.109 +      typedef typename int_fast_t<least>::fast  fast;
   1.110 +  };
   1.111 +
   1.112 +  //  unsigned
   1.113 +  template< unsigned long Value >   // maximum value to require support
   1.114 +  struct uint_value_t 
   1.115 +  {
   1.116 +      typedef typename int_least_helper
   1.117 +        < 
   1.118 +          5 +
   1.119 +          (Value <= integer_traits<unsigned long>::const_max) +
   1.120 +          (Value <= integer_traits<unsigned int>::const_max) +
   1.121 +          (Value <= integer_traits<unsigned short>::const_max) +
   1.122 +          (Value <= integer_traits<unsigned char>::const_max)
   1.123 +        >::least  least;
   1.124 +      typedef typename int_fast_t<least>::fast  fast;
   1.125 +  };
   1.126 +
   1.127 +
   1.128 +} // namespace boost
   1.129 +
   1.130 +#endif  // BOOST_INTEGER_HPP