Ticket #2026: random.patch

File random.patch, 2.9 KB (added by Steven Watanabe, 14 years ago)
  • boost/random/uniform_int.hpp

     
    2525#include <boost/detail/workaround.hpp>
    2626#include <boost/random/uniform_smallint.hpp>
    2727#include <boost/random/detail/signed_unsigned_tools.hpp>
     28#include <boost/type_traits/make_unsigned.hpp>
    2829#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
    2930#include <boost/type_traits/is_float.hpp>
    3031#endif
     
    3839public:
    3940  typedef IntType input_type;
    4041  typedef IntType result_type;
    41   typedef typename random::detail::make_unsigned<result_type>::type range_type;
     42  typedef typename make_unsigned<result_type>::type range_type;
    4243
    4344  explicit uniform_int(IntType min_arg = 0, IntType max_arg = 9)
    4445    : _min(min_arg), _max(max_arg)
     
    6162  {
    6263    typedef typename Engine::result_type base_result;
    6364    // ranges are always unsigned
    64     typedef typename random::detail::make_unsigned<base_result>::type base_unsigned;
     65    typedef typename make_unsigned<base_result>::type base_unsigned;
    6566    const base_result bmin = (eng.min)();
    6667    const base_unsigned brange =
    6768      random::detail::subtract<base_result>()((eng.max)(), (eng.min)());
  • boost/random/detail/signed_unsigned_tools.hpp

     
    1313
    1414#include <boost/limits.hpp>
    1515#include <boost/config.hpp>
     16#include <boost/type_traits/make_unsigned.hpp>
    1617
    1718namespace boost {
    1819namespace random {
    1920namespace detail {
    2021
    21 /*
    22  * Given an (integral) type T, returns the type "unsigned T".
    23  * (type_traits appears to be lacking the feature)
    24  */
    2522
    26 template<class T>
    27 struct make_unsigned { };
    28 
    29 template<>
    30 struct make_unsigned<char>
    31 {
    32   typedef unsigned char type;
    33 };
    34 
    35 template<>
    36 struct make_unsigned<signed char>
    37 {
    38   typedef unsigned char type;
    39 };
    40 
    41 template<>
    42 struct make_unsigned<unsigned char>
    43 {
    44   typedef unsigned char type;
    45 };
    46 
    47 template<>
    48 struct make_unsigned<short>
    49 {
    50   typedef unsigned short type;
    51 };
    52 
    53 template<>
    54 struct make_unsigned<unsigned short>
    55 {
    56   typedef unsigned short type;
    57 };
    58 
    59 template<>
    60 struct make_unsigned<int>
    61 {
    62   typedef unsigned int type;
    63 };
    64 
    65 template<>
    66 struct make_unsigned<unsigned int>
    67 {
    68   typedef unsigned int type;
    69 };
    70 
    71 template<>
    72 struct make_unsigned<long>
    73 {
    74   typedef unsigned long type;
    75 };
    76 
    77 template<>
    78 struct make_unsigned<unsigned long>
    79 {
    80   typedef unsigned long type;
    81 };
    82 
    83 #ifdef BOOST_HAS_LONG_LONG
    84 template<>
    85 struct make_unsigned<long long>
    86 {
    87   typedef unsigned long long type;
    88 };
    89 
    90 template<>
    91 struct make_unsigned<unsigned long long>
    92 {
    93   typedef unsigned long long type;
    94 };
    95 #endif
    96 
    97 
    9823/*
    9924 * Compute x - y, we know that x >= y, return an unsigned value.
    10025 */