Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62687 - in sandbox/SOC/2010/bit_masks: boost/integer lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-06-09 16:10:16


Author: bbartman
Date: 2010-06-09 16:10:16 EDT (Wed, 09 Jun 2010)
New Revision: 62687
URL: http://svn.boost.org/trac/boost/changeset/62687

Log:
added preconditions into bitfield_tupe and figured out how to used find_if to locate a type with the correct name
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 45 +++++++++++++++++++++++++++++++++++++--
   sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_tuple_test.cpp | 21 ++++++++++++++++++
   2 files changed, 63 insertions(+), 3 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp 2010-06-09 16:10:16 EDT (Wed, 09 Jun 2010)
@@ -7,7 +7,9 @@
 #ifndef BOOST_BITFIELD_TUPLE_HPP
 #define BOOST_BITFIELD_TUPLE_HPP
 #include <boost/integer/details/storage.hpp>
+
 #include <boost/integer/details/member.hpp>
+#include <boost/integer/bit_width.hpp>
 #include <cstddef>
 #include <boost/mpl/void.hpp>
 #include <boost/mpl/vector.hpp>
@@ -175,6 +177,17 @@
     };
 };
 
+
+/** This structure does all of the assertions related to constraints
+ * which must be enforced after all of the arguments have been delt with.
+ * This class is a planned refactoring for later on.
+ */
+template <typename Impl>
+struct bft_base {
+
+};
+
+
 } // end details
 
 
@@ -189,8 +202,8 @@
             typename T8 = mpl::void_,
             typename T9 = mpl::void_
>
-struct bitfield_tuple
-{
+struct bitfield_tuple {
+
     typedef typename details::bft_impl_<T0,
             mpl::void_,
             mpl::vector<>,
@@ -206,7 +219,33 @@
         template process<T8>::type::
         template process<T9>::type processed_args;
 
-
+ // extracting te Arguments from processed_args relating to
+ // the storage policy. Also preforming static assertios
+ // where they can be done.
+ typedef typename processed_args::storage_policy storage_policy;
+
+ // Precondition:
+ // A storage policy must be supplied.
+ BOOST_STATIC_ASSERT((
+ !is_same<
+ storage_policy,
+ typename mpl::void_
+ >::value
+ ));
+
+ typedef typename storage_policy::storage_type storage_type;
+
+ // precondition: the storage type must be a pod type (for now).
+ // NOTE: this may become a documented requirement only.
+ BOOST_STATIC_ASSERT(( is_pod<storage_type>::value ));
+
+ // Precondition: the offet at the end of everything must be the
+ // the same as or less then the bit_width of the storage type.
+ BOOST_STATIC_ASSERT((
+ bit_width< storage_type >::value
+ >=
+ processed_args::offset::value
+ ));
 };
 
 

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_tuple_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_tuple_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_tuple_test.cpp 2010-06-09 16:10:16 EDT (Wed, 09 Jun 2010)
@@ -6,12 +6,19 @@
 #include <boost/integer/bitfield_tuple.hpp>
 #include "test_type_list.hpp"
 #include <boost/mpl/front.hpp>
+#include <boost/mpl/find_if.hpp>
 
 void ignore(...) {}
 
 struct red { };
 struct green { };
 struct blue { };
+
+template <typename T, typename U>
+struct match_name
+ :is_same<typename T::name_type, U>::type
+{ };
+
 int main() {
     // lets make some errors : )
     // bitfield_tuple < storage<int>, member<int,red,6> > temp;
@@ -109,6 +116,20 @@
>
     ));
 
+ typedef mpl::vector<
+ details::bitfield_element_<
+ int,
+ red,
+ mpl::size_t<0>,
+ mpl::size_t<3>
+ >
+ > temp_vect;
+
+ // tesitng so I can learn to use mpl::find_if
+ typedef mpl::find_if<temp_vect, match_name<mpl::_1, red> >::type temp_located;
+
+
+
     }
     return 0;
 }


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