Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61943 - in sandbox/SOC/2010/bit_masks/boost/integer: . details
From: bbartmanboost_at_[hidden]
Date: 2010-05-13 09:41:06


Author: bbartman
Date: 2010-05-13 09:41:05 EDT (Thu, 13 May 2010)
New Revision: 61943
URL: http://svn.boost.org/trac/boost/changeset/61943

Log:
working on high low bit metafunctions
Added:
   sandbox/SOC/2010/bit_masks/boost/integer/high_low_bits.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp | 42 ++----------------------------
   sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_impl.hpp | 54 +++++++++++++++++++++++++++++++--------
   2 files changed, 46 insertions(+), 50 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-13 09:41:05 EDT (Thu, 13 May 2010)
@@ -10,7 +10,6 @@
 #define BOOST_INTEGER_BIT_MASK_HPP
 
 // boost dependencies.
-#include <boost/mpl/int.hpp>
 
 
 
@@ -19,48 +18,15 @@
 namespace boost {
 
 
-/** Intention of this mask is to provide a simple mask which can be used
- * to make simplified masks which are used for contigious bits.
- * This needs to evolve into a specialization of the regular
- * bit_mask.
+/** bit_mask.
+ * Mask which creates a mask give type, offset and width of the mask
  */
-template < typename MaskedType,
- typename MaskOffsetInBits,
- typename MaskWidth >
-struct simple_bit_mask;
-
-
-
-// forward declaration of the bit mask structure which will all
-// a recursive definition of how
-template <typename Value, typename SecondValue = mpl::int_<0> >
-struct bit_mask;
-
-
-
-
-// termination specialization this will cause the psudo-recursive definition
-// being evalueated to finish.
-template <int NewMaskValue, int CurrentMaskValue>
-struct bit_mask< mpl::int_< NewMaskValue >, mpl::int_< CurrentMaskValue > >
- :mpl::bitor_<
- mpl::int_<NewMaskValue>,
- mpl::int_< CurrentMaskValue >
- >::type
+template <typename T, typename Offset, typename Width>
+struct bit_maks
 { };
 
 
 
-// this is the recursive step for the bit_mask.
-template <int MaskValue, int CurrentMaskValue>
-struct bit_mask < bit_mask< mpl::int_<MaskValue> >, mpl::int_<CurrentMaskValue> >
- :mpl::bitor_<
- mpl::int_< CurrentMaskValue >,
- bit_mask< mpl::int_< MaskValue > >
- >::type
-{ };
-
-
 } // namespace boost
 
 #endif

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-13 09:41:05 EDT (Thu, 13 May 2010)
@@ -1,5 +1,8 @@
 #ifndef BOOST_BIT_MASK_IMPL_HPP
 #define BOOST_BIT_MASK_IMPL_HPP
+
+#include <boost/mpl/integral_c.hpp>
+#include <boost/type_traits.hpp>
 #include <boost/mpl/bitwise.hpp>
 #include <boost/static_assert.hpp>
 
@@ -7,6 +10,22 @@
 
 
 
+/** Type which is used during specialization to infer that a template patameter
+ * has not been used in the initilization of bit_mask_impl.
+ */
+struct unused_type { };
+
+/** Forward Declaration for the bit_mask_impl.
+ * This is being used for specifying default parameters so they can be used in
+ * specializations to see how may parameters bit_mask_impl was called with.
+ * If I had variadic templates this would be less of an issue.
+ */
+template < typename MaskedType,
+ typename MaskOffsetInBits = unused_type ,
+ typename MaskWidth = unused_type >
+struct bit_mask_impl;
+
+
 
 /** Houses the structure for creating simple masks as well as
  * implements the preconditions for a simple_bit_mask.
@@ -20,12 +39,13 @@
  *
  * 3. Valid range for mask width is > 0.
  *
- *
+ * 4. The type which is being masked must satisfy the is_integral type trait.
  */
 template < typename MaskedType,
             typename MaskOffsetInBits,
             typename MaskWidth >
-struct simple_bit_mask_impl {
+struct bit_mask_impl {
+
 
     // precondition 1.
     BOOST_STATIC_ASSERT(( (MaskOffsetInBits::value + MaskWidth::value)
@@ -35,22 +55,32 @@
 
     // precondition 3.
     BOOST_STATIC_ASSERT(( MaskWidth::value > 0 ));
+
+ // precondition 4.
+ BOOST_STATIC_ASSERT(( is_integral<MaskedType>::value ));
+
 
- // this is supposed to make decalring a static constant easy.
-// BOOST_STATIC_CONSTANT( MaskedType, value = ( ) );
+ // this is supposed to make decalring a static constant easy, I think...
+ // BOOST_STATIC_CONSTANT( MaskedType, value = ( ) );
 
     // type typedef
- typedef simple_bit_mask_impl< MaskedType,
- MaskOffsetInBits,
- MaskWidth
- > type;
-
- typedef MaskedType mask_type;
- typedef MaskOffsetInBits bit_offset;
- typedef MaskWidth mask_width;
+ typedef bit_mask_impl< MaskedType,
+ MaskOffsetInBits,
+ MaskWidth
+ > type;
+
+ typedef MaskedType mask_type;
+ typedef MaskOffsetInBits bit_offset;
+ typedef MaskWidth mask_width;
 };
 
 
+/** bit_mask_impl specialization over an mpl type. */
+template < typename MaskedType, typename IntegralType, IntegralType IntegralValue>
+struct bit_mask_impl< MaskedType, mpl::integral_c<IntegralType, IntegralValue>, unused_type>{
+
+};
+
 } // end of details namespace.
 } // end of boost namespace.
 

Added: sandbox/SOC/2010/bit_masks/boost/integer/high_low_bits.hpp
==============================================================================


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