Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62416 - in sandbox/SOC/2010/bits_and_ints/boost/integer: . detail
From: muriloufg_at_[hidden]
Date: 2010-06-03 15:26:20


Author: murilov
Date: 2010-06-03 15:26:19 EDT (Thu, 03 Jun 2010)
New Revision: 62416
URL: http://svn.boost.org/trac/boost/changeset/62416

Log:
Some cosmetic changes
Added:
   sandbox/SOC/2010/bits_and_ints/boost/integer/detail/static_bit_reversal.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/bits_and_ints/boost/integer/bit_reversal.hpp | 2
   sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp | 10 ++++----
   sandbox/SOC/2010/bits_and_ints/boost/integer/sign_extend.hpp | 19 +++++++++--------
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_bit_reversal.hpp | 42 +++++----------------------------------
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp | 14 +++++++-----
   sandbox/SOC/2010/bits_and_ints/boost/integer/utils.hpp | 2
   6 files changed, 31 insertions(+), 58 deletions(-)

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/bit_reversal.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/bit_reversal.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/bit_reversal.hpp 2010-06-03 15:26:19 EDT (Thu, 03 Jun 2010)
@@ -1,4 +1,4 @@
-// Boost integer/detail/bit_reversal.hpp header file ------------------------------//
+// Boost integer/bit_reversal.hpp header file ------------------------------//
 
 // (C) Copyright Murilo Adriano Vasconcelos 2010.
 // Distributed under the Boost Software License, Version 1.0. (See

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp 2010-06-03 15:26:19 EDT (Thu, 03 Jun 2010)
@@ -11,10 +11,10 @@
 #define BOOST_BITS_AND_INTS
 
 // sign_extends and static_sign_extends
-#include "detail/utils.hpp"
-#include "detail/sign_extend.hpp"
-#include "detail/static_sign_extend.hpp"
-#include "detail/bit_reversal.hpp"
-#include "detail/static_bit_reversal.hpp"
+#include <boost/integer/utils.hpp>
+#include <boost/integer/sign_extend.hpp>
+#include <boost/integer/static_sign_extend.hpp>
+#include <boost/integer/bit_reversal.hpp>
+#include <boost/integer/static_bit_reversal.hpp>
 
 #endif
\ No newline at end of file

Added: sandbox/SOC/2010/bits_and_ints/boost/integer/detail/static_bit_reversal.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/detail/static_bit_reversal.hpp 2010-06-03 15:26:19 EDT (Thu, 03 Jun 2010)
@@ -0,0 +1,37 @@
+// Boost integer/detail/static_bit_reversal.hpp header file ------------------------------//
+
+// (C) Copyright Murilo Adriano Vasconcelos 2010.
+// 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
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#ifndef BOOST_DETAIL_STATIC_BIT_REVERSAL_INCLUDED
+#define BOOST_DETAIL_STATIC_BIT_REVERSAL_INCLUDED
+
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/integer/utils.hpp>
+
+namespace boost {
+namespace integer_detail {
+
+// Recursion implementation
+template <typename T, T data, std::size_t shift>
+struct static_bit_reversal_impl :
+ public integral_constant<T,
+ ((is_bit_set<T, data, (sizeof(T) * 8 - shift)>::value << (shift - 1))
+ + static_bit_reversal_impl<T, data, shift - 1>::value)
+ >
+{};
+
+// Base case
+template <typename T, T data>
+struct static_bit_reversal_impl<T, data, 0> :
+ integral_constant<T, T(0)> {};
+
+
+} // integer_detail
+} // boost
+
+#endif
\ No newline at end of file

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/sign_extend.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/sign_extend.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/sign_extend.hpp 2010-06-03 15:26:19 EDT (Thu, 03 Jun 2010)
@@ -1,4 +1,4 @@
-// Boost integer/detail/sign_extend.hpp header file ------------------------------//
+// Boost integer/sign_extend.hpp header file ------------------------------//
 
 // (C) Copyright Murilo Adriano Vasconcelos 2010.
 // Distributed under the Boost Software License, Version 1.0. (See
@@ -10,22 +10,23 @@
 #ifndef BOOST_SIGN_EXTEND_INCLUDED
 #define BOOST_SIGN_EXTEND_INCLUDED
 
-#include <boost/cstdint.hpp> // for intmax_t
-#include <boost/assert.hpp>
+#include <boost/type_traits.hpp> // is_integral
+#include <boost/utility/enable_if.hpp> // enable_if
 
 namespace boost
 {
 
 // Extend data represented in `bits' bits to
-// sizeof(IntegralType) * 8 bits
-template <typename IntegralType>
-inline IntegralType sign_extend(IntegralType data, std::size_t bits)
+// sizeof(Type) * 8 bits
+template <typename Type>
+inline typename enable_if<is_integral<Type>, Type>::type
+sign_extend(Type data, std::size_t bits)
 {
- data = data & ((IntegralType(1) << bits) - 1);
- IntegralType const mask = (IntegralType(1) << (bits - 1));
+ data = data & ((Type(1) << bits) - 1);
+ Type const mask = (Type(1) << (bits - 1));
         return (data ^ mask) - mask;
 }
         
 } // boost
 
-#endif
\ No newline at end of file
+#endif

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_bit_reversal.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_bit_reversal.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_bit_reversal.hpp 2010-06-03 15:26:19 EDT (Thu, 03 Jun 2010)
@@ -1,4 +1,4 @@
-// Boost integer/detail/static_bit_reversal.hpp header file ------------------------------//
+// Boost integer/static_bit_reversal.hpp header file ------------------------------//
 
 // (C) Copyright Murilo Adriano Vasconcelos 2010.
 // Distributed under the Boost Software License, Version 1.0. (See
@@ -12,7 +12,8 @@
 
 #include <boost/utility/enable_if.hpp>
 #include <boost/type_traits.hpp>
-#include "utils.hpp" // is_bit_set<>
+#include <boost/integer/utils.hpp>
+#include <boost/integer/detail/static_bit_reversal.hpp>
 
 /*
  * Reverses the bits in data in compile-time
@@ -25,43 +26,12 @@
 namespace boost
 {
 
-namespace bits_and_ints_private {
-
-// Base container
-template <typename T, T data>
-struct static_bit_reversal_base
-{
- BOOST_STATIC_CONSTANT(T, value = data);
-};
-
-// Recursion implementation
-template <typename T, T data, std::size_t shift>
-struct static_bit_reversal_impl :
- public static_bit_reversal_base<T,
- ((is_bit_set<T, data, (sizeof(T) * 8 - shift)>::value << (shift - 1))
- + static_bit_reversal_impl<T, data, shift - 1>::value)
- >
-{};
-
-// Base case
-template <typename T, T data>
-struct static_bit_reversal_impl<T, data, 0> :
- static_bit_reversal_base<T, T(0)> {};
-
-} // bits_and_ints_private
-
-
-// If T is not an integral type, static_bit_reversal<T, data>::value call
-// will result an error.
-template <typename T, T data, class Enable = void>
-struct static_bit_reversal {};
-
 // If T is an integral type, static_bit_reversal<T, data>::value will
 // be `data' with the bits reversed
-template <typename T, T data>
-struct static_bit_reversal<T, data, typename enable_if<is_integral<T> >::type> {
+template <typename T, T data, class Enable = typename enable_if<is_integral<T> >::type>
+struct static_bit_reversal {
         BOOST_STATIC_CONSTANT(T, value =
- (bits_and_ints_private::static_bit_reversal_impl<T, data, sizeof(T) * 8>::value)
+ (integer_detail::static_bit_reversal_impl<T, data, sizeof(T) * 8>::value)
         );
 };
 

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp 2010-06-03 15:26:19 EDT (Thu, 03 Jun 2010)
@@ -1,4 +1,4 @@
-// Boost integer/detail/static_sign_extend.hpp header file ------------------------------//
+// Boost integer/static_sign_extend.hpp header file ------------------------------//
 
 // (C) Copyright Murilo Adriano Vasconcelos 2010.
 // Distributed under the Boost Software License, Version 1.0. (See
@@ -10,20 +10,22 @@
 #ifndef BOOST_STATIC_SIGN_EXTEND_INCLUDED
 #define BOOST_STATIC_SIGN_EXTEND_INCLUDED
 
-#include <boost/cstdint.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/is_integral.hpp>
 
 namespace boost
 {
 
 // Compile-time version of sign_extend
-template<typename IntegralType, IntegralType raw, std::size_t Bits>
+template<typename Type, Type data, std::size_t Bits,
+ class Enable = typename enable_if<is_integral<Type> >::type>
 struct static_sign_extend
 {
 private:
- BOOST_STATIC_CONSTANT(IntegralType, shift = (IntegralType(1) << (Bits - 1)));
- BOOST_STATIC_CONSTANT(IntegralType, mask = ((IntegralType(1) << Bits) - 1));
+ BOOST_STATIC_CONSTANT(Type, shift = (Type(1) << (Bits - 1)));
+ BOOST_STATIC_CONSTANT(Type, mask = ((Type(1) << Bits) - 1));
 public:
- BOOST_STATIC_CONSTANT(IntegralType, value = ((raw & mask) ^ shift) - shift);
+ BOOST_STATIC_CONSTANT(Type, value = ((data & mask) ^ shift) - shift);
 }; // boost::static_sign_extend
 
 } // boost

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/utils.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/utils.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/utils.hpp 2010-06-03 15:26:19 EDT (Thu, 03 Jun 2010)
@@ -1,4 +1,4 @@
-// Boost integer/detail/utils.hpp header file ------------------------------//
+// Boost integer/utils.hpp header file ------------------------------//
 
 // (C) Copyright Murilo Adriano Vasconcelos 2010.
 // Distributed under the Boost Software License, Version 1.0. (See


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