|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62034 - in sandbox/SOC/2010/bit_masks/boost/integer: . details
From: bbartmanboost_at_[hidden]
Date: 2010-05-16 12:09:00
Author: bbartman
Date: 2010-05-16 12:09:00 EDT (Sun, 16 May 2010)
New Revision: 62034
URL: http://svn.boost.org/trac/boost/changeset/62034
Log:
working on basic refactorings
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp | 50 +++++++++++++++++++++------------------
sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_impl.hpp | 51 ---------------------------------------
sandbox/SOC/2010/bit_masks/boost/integer/integral_mask.hpp | 24 +++++++++++++++++-
3 files changed, 50 insertions(+), 75 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp 2010-05-16 12:09:00 EDT (Sun, 16 May 2010)
@@ -1,5 +1,3 @@
-// Boost integer/bit_mask.hpp header file
-
// (C) Copyright Brian Bartman 2010.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -9,40 +7,46 @@
#ifndef BOOST_INTEGER_BIT_MASK_HPP
#define BOOST_INTEGER_BIT_MASK_HPP
-// boost dependencies.
-
-
#include <boost/integer/high_low_bits.hpp>
-#include <boost/integer/details/bit_mask_impl.hpp>
+#include <boost/type_traits.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/integer/bit_width.hpp>
+#include <limits>
+
namespace boost {
/** bit_mask.
- * Mask which creates a mask give type, offset and width of the mask
+ * Mask which creates a mask give type, offset and width of the mask.
+ * Preconditions for bit_mask
+ * Pre-Conditions
+ *
+ * 1. The width of the masked section must not be longer then the
+ * mask itself.
+ *
+ * 2. Valid range for mask width is > 0.
+ *
+ * 3. The type which is being masked must satisfy the is_integral type trait.
+ * NOTE: This is documented but not enforeced.
+ *
*/
template <typename T, unsigned int Offset, unsigned int Width = 1 >
struct bit_mask
- :details::bit_mask_preconditions<T, Offset, Width>,
- integral_constant<T, (low_bits<T,Width>::value << Offset) >
+ :integral_constant<T, (low_bits<T,Width>::value << Offset) >
{
- typedef bit_mask<T, Offset, Width> type;
+ // precondition 1.
+ BOOST_STATIC_ASSERT(( (Offset + Width) < ( bit_width<T>::value - 1) ));
+ // precondition 2.
+ BOOST_STATIC_ASSERT(( Width > 0 ));
+
+ // precondition 3.
+ // BOOST_STATIC_ASSERT(( is_integral<T>::value ));
- T operator()() {
- return type::value;
- }
-};
-/** Integral Mask.
- * This integral Mask is defined similar to an integral constant.
- */
-template <typename T, T Value>
-struct integral_mask
- :details::integral_mask_preconditions<T,Value>,
- integral_constant<T, Value>
-{
- typedef integral_mask<T,Value> type;
+ typedef bit_mask<T, Offset, Width> type;
+
T operator()() {
return type::value;
Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_impl.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_impl.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_impl.hpp 2010-05-16 12:09:00 EDT (Sun, 16 May 2010)
@@ -7,58 +7,9 @@
#ifndef BOOST_BIT_MASK_IMPL_HPP
#define BOOST_BIT_MASK_IMPL_HPP
-#include <boost/type_traits.hpp>
-#include <boost/mpl/bitwise.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/integer/bit_width.hpp>
-#include <limits>
-namespace boost { namespace details {
-
-
-
-/** Preconditions for bit_mask impl
- * Pre-Conditions
- *
- * 1. The width of the masked section must not be longer then the
- * mask itself.
- *
- * 2. Valid range for mask width is > 0.
- *
- * 3. The type which is being masked must satisfy the is_integral type trait.
- */
-template <typename T, unsigned int Offset, unsigned int Width>
-struct bit_mask_preconditions {
-
- // precondition 1.
- BOOST_STATIC_ASSERT(( (Offset + Width) < ( bit_width<T>::value - 1) ));
-
- // precondition 2.
- BOOST_STATIC_ASSERT(( Width > 0 ));
-
- // precondition 3.
- BOOST_STATIC_ASSERT(( is_integral<T>::value ));
-};
-
-
-/** The following preconditions apply to the integral_mask type.
- * Preconditions
- *
- * 1. T must be an integral type.
- *
- * 2. Value must be in the domain of the integral type T.
- *
- */
-template <typename T, T Value>
-struct integral_mask_preconditions {
- // precondition 1.
- BOOST_STATIC_ASSERT(( is_integral<T>::value ));
-
- // precondition 2.
- BOOST_STATIC_ASSERT((std::numeric_limits<T>::max >= Value ));
- BOOST_STATIC_ASSERT((std::numeric_limits<T>::min <= Value ));
-};
+namespace boost { namespace details {
} // end of details namespace.
} // end of boost namespace.
Modified: sandbox/SOC/2010/bit_masks/boost/integer/integral_mask.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/integral_mask.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/integral_mask.hpp 2010-05-16 12:09:00 EDT (Sun, 16 May 2010)
@@ -4,20 +4,40 @@
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
+
+
#ifndef BOOST_INTEGRAL_MASK_HPP
#define BOOST_INTEGRAL_MASK_HPP
+#include <boost/integer/high_low_bits.hpp>
+#include <boost/type_traits.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/integer/bit_width.hpp>
+#include <limits>
-namespace boost {
+namespace boost {
/** Integral Mask.
* This integral Mask is defined similar to an integral constant.
+ * The following preconditions apply to the integral_mask type.
+ * Preconditions
+ *
+ * 1. T must be an integral type. NOTE: This is documented, but NOT enforeced.
+ *
+ * 2. Value must be in the domain of the integral type T.
*/
template <typename T, T Value>
struct integral_mask
- :details::integral_mask_preconditions<T,Value>,
+ : // details::integral_mask_preconditions<T,Value>,
integral_constant<T, Value>
{
+ // precondition 1.
+ // BOOST_STATIC_ASSERT(( is_integral<T>::value ));
+
+ // precondition 2.
+ BOOST_STATIC_ASSERT((std::numeric_limits<T>::max >= Value ));
+ BOOST_STATIC_ASSERT((std::numeric_limits<T>::min <= Value ));
+
typedef integral_mask<T,Value> type;
T operator()() {
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