Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-06-21 12:07:45


Author: steven_watanabe
Date: 2008-06-21 12:07:44 EDT (Sat, 21 Jun 2008)
New Revision: 46580
URL: http://svn.boost.org/trac/boost/changeset/46580

Log:
Replace random's make_unsigned with the type_traits version. Fixes #2026
Text files modified:
   trunk/boost/random/detail/signed_unsigned_tools.hpp | 77 ---------------------------------------
   trunk/boost/random/uniform_int.hpp | 5 +-
   2 files changed, 4 insertions(+), 78 deletions(-)

Modified: trunk/boost/random/detail/signed_unsigned_tools.hpp
==============================================================================
--- trunk/boost/random/detail/signed_unsigned_tools.hpp (original)
+++ trunk/boost/random/detail/signed_unsigned_tools.hpp 2008-06-21 12:07:44 EDT (Sat, 21 Jun 2008)
@@ -13,87 +13,12 @@
 
 #include <boost/limits.hpp>
 #include <boost/config.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
 
 namespace boost {
 namespace random {
 namespace detail {
 
-/*
- * Given an (integral) type T, returns the type "unsigned T".
- * (type_traits appears to be lacking the feature)
- */
-
-template<class T>
-struct make_unsigned { };
-
-template<>
-struct make_unsigned<char>
-{
- typedef unsigned char type;
-};
-
-template<>
-struct make_unsigned<signed char>
-{
- typedef unsigned char type;
-};
-
-template<>
-struct make_unsigned<unsigned char>
-{
- typedef unsigned char type;
-};
-
-template<>
-struct make_unsigned<short>
-{
- typedef unsigned short type;
-};
-
-template<>
-struct make_unsigned<unsigned short>
-{
- typedef unsigned short type;
-};
-
-template<>
-struct make_unsigned<int>
-{
- typedef unsigned int type;
-};
-
-template<>
-struct make_unsigned<unsigned int>
-{
- typedef unsigned int type;
-};
-
-template<>
-struct make_unsigned<long>
-{
- typedef unsigned long type;
-};
-
-template<>
-struct make_unsigned<unsigned long>
-{
- typedef unsigned long type;
-};
-
-#ifdef BOOST_HAS_LONG_LONG
-template<>
-struct make_unsigned<long long>
-{
- typedef unsigned long long type;
-};
-
-template<>
-struct make_unsigned<unsigned long long>
-{
- typedef unsigned long long type;
-};
-#endif
-
 
 /*
  * Compute x - y, we know that x >= y, return an unsigned value.

Modified: trunk/boost/random/uniform_int.hpp
==============================================================================
--- trunk/boost/random/uniform_int.hpp (original)
+++ trunk/boost/random/uniform_int.hpp 2008-06-21 12:07:44 EDT (Sat, 21 Jun 2008)
@@ -25,6 +25,7 @@
 #include <boost/detail/workaround.hpp>
 #include <boost/random/uniform_smallint.hpp>
 #include <boost/random/detail/signed_unsigned_tools.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
 #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
 #include <boost/type_traits/is_float.hpp>
 #endif
@@ -38,7 +39,7 @@
 public:
   typedef IntType input_type;
   typedef IntType result_type;
- typedef typename random::detail::make_unsigned<result_type>::type range_type;
+ typedef typename make_unsigned<result_type>::type range_type;
 
   explicit uniform_int(IntType min_arg = 0, IntType max_arg = 9)
     : _min(min_arg), _max(max_arg)
@@ -61,7 +62,7 @@
   {
     typedef typename Engine::result_type base_result;
     // ranges are always unsigned
- typedef typename random::detail::make_unsigned<base_result>::type base_unsigned;
+ typedef typename make_unsigned<base_result>::type base_unsigned;
     const base_result bmin = (eng.min)();
     const base_unsigned brange =
       random::detail::subtract<base_result>()((eng.max)(), (eng.min)());


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk