Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62744 - in sandbox/SOC/2010/bit_masks: boost/integer boost/integer/details lib/integer/test lib/integer/test/bft_testing/compile_fail
From: bbartmanboost_at_[hidden]
Date: 2010-06-10 12:04:53


Author: bbartman
Date: 2010-06-10 12:04:41 EDT (Thu, 10 Jun 2010)
New Revision: 62744
URL: http://svn.boost.org/trac/boost/changeset/62744

Log:
debugged my bitfield_tuples templates and fixed an error
Added:
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/compile_fail/bft_storage_width_acceded.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 176 +++++++++++++++++++++++++++++++++++----
   sandbox/SOC/2010/bit_masks/boost/integer/details/member.hpp | 7 +
   sandbox/SOC/2010/bit_masks/boost/integer/details/storage.hpp | 1
   sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 | 4
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/compile_fail/non_pod_storage_type.cpp | 18 ++++
   5 files changed, 183 insertions(+), 23 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-10 12:04:41 EDT (Thu, 10 Jun 2010)
@@ -17,9 +17,15 @@
 #include <boost/mpl/map.hpp>
 #include <boost/type_traits.hpp>
 #include <boost/static_assert.hpp>
+#include <boost/mpl/plus.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/utility/enable_if.hpp>
 
+
+// TODO: Remove me.
+#include <iostream>
+#include <boost/mpl/empty.hpp>
+
 namespace boost {
 namespace details {
 
@@ -40,6 +46,14 @@
 };
 
 
+template <typename ReturnType, typename Name, typename FieldWidth>
+struct parsible_member_elem_ {
+ typedef ReturnType return_type;
+ typedef Name name_type;
+ typedef FieldWidth field_width;
+ typedef parsible_member_elem_<ReturnType,Name,FieldWidth> type;
+};
+
 
 
 /** This is the empty which prevents the user from supply things which are
@@ -69,13 +83,21 @@
 
     template <typename NextParam>
     struct process {
- typedef typename bft_impl_<
+ typedef bft_impl_<
             NextParam,
             storage_policy,
             field_vector,
             offset
- >::type type;
+ > type;
     };
+
+
+ static void debug_info() {
+ using namespace std;
+ cout << "bft_impl_ <mpl::void_, StoragePolicy, FieldVector, Offset>" << endl;
+ cout << "Offset Value: " << Offset::value << endl;
+ cout << "offset Value: " << offset::value << endl;
+ }
 };
 
 /** Specilization for storage type.
@@ -110,13 +132,20 @@
 
     template <typename NextParam>
     struct process {
- typedef typename bft_impl_<
+ typedef bft_impl_<
             NextParam,
             storage_policy,
             field_vector,
             offset
- >::type type;
+ > type;
     };
+
+ static void debug_info() {
+ using namespace std;
+ cout << "bft_impl_ <storage<StorageType,AllocationPolicy>,StoragePolicy,FieldVector,Offset >" << endl;
+ cout << "Offset Value: " << Offset::value << endl;
+ cout << "offset Value: " << offset::value << endl;
+ }
 };
 
 /** Specilization for member.
@@ -129,13 +158,13 @@
 // TODO: Implement Precondition 1 listed above!
 template < typename StoragePolicy,
             typename FieldVector,
- typename Offset,
+ std::size_t FieldWidth,
             typename ReturnType,
             typename NameType,
- std::size_t FieldWidth
+ typename Offset
>
 struct bft_impl_ <
- member<
+ member <
         ReturnType,
         NameType,
         FieldWidth
@@ -154,22 +183,37 @@
             ReturnType,
             NameType,
             Offset,
- typename mpl::size_t< FieldWidth >
+ mpl::size_t<FieldWidth>
>
>::type field_vector;
- typedef mpl::size_t< Offset::value + FieldWidth > offset;
+
+ typedef mpl::size_t<
+ mpl::plus<
+ Offset,
+ mpl::size_t<FieldWidth>
+ >::value
+ > offset;
 
     typedef bft_impl_<param,storage_policy,field_vector,offset> type;
 
     template <typename NextParam>
     struct process {
- typedef typename bft_impl_<
+ typedef bft_impl_<
             NextParam,
             storage_policy,
             field_vector,
             offset
- >::type type;
+ > type;
     };
+
+ static void debug_info() {
+ using namespace std;
+ cout << "bft_impl_ <member<ReturnType,NameType,FieldWidth>,StoragePolicy,FieldVector,Offset >" << endl;
+ cout << "Offset Value: " << Offset::value << endl;
+ cout << "offset Value: " << offset::value << endl;
+ cout << "FieldWidth Value: " << FieldWidth << endl;
+ cout << "mpl::size_t<FieldWidth> Value: " << mpl::size_t< FieldWidth >::value << endl;
+ }
 };
 
 /** This structure is going to be used when an allocator isn't assked for.
@@ -223,13 +267,54 @@
 // Only used for writing clarity and only used once and then undef'ed when
 // before the end of the details namespace/after the end of the
 // bitfield_tuple_base
-#define BOOST_BFT_ARG_PROCESSING_CLASS \
- details::bft_impl_<T0, \
+
+
+
+/** Used for fixing member arguments by projecting numbers into the type
+ * system.
+ */
+template <typename T>
+struct fix_args;
+
+template <>
+struct fix_args <mpl::void_> {
+ typedef mpl::void_ apply;
+};
+
+template <typename ReturnType, typename NameType, std::size_t FieldWidth>
+struct fix_args <
+ member<
+ ReturnType,
+ NameType,
+ FieldWidth
+ > >
+{
+ typedef parsible_member_elem_<
+ ReturnType,
+ NameType,
+ typename mpl::size_t<FieldWidth>
+ > apply;
+};
+
+template <typename StorageType, typename AllocType>
+struct fix_args <
+ storage<
+ StorageType,
+ AllocType
+ > >
+{
+ typedef storage<StorageType,AllocType> apply;
+};
+
+
+#define BOOST_BFT_ARG_PROCESSING_CLASS \
+ details::bft_impl_<\
+ T0, \
             mpl::void_,\
             mpl::vector<>,\
- mpl::size_t<0>\
+ mpl::size_t<0u>\
>::\
- template process<T1>::type::\
+ template process<T1 >::type::\
         template process<T2>::type::\
         template process<T3>::type::\
         template process<T4>::type::\
@@ -281,8 +366,8 @@
     : BOOST_BFT_ARG_PROCESSING_CLASS
 {
 
- typedef typename bitfield_tuple_base<T0,T1,T2,T3,T4,
- T5,T6,T7,T8,T9>::type processed_args;
+
+ typedef typename BOOST_BFT_ARG_PROCESSING_CLASS processed_args;
 
     // extracting te Arguments from processed_args relating to
     // the storage policy. Also preforming static assertios
@@ -335,9 +420,9 @@
     // 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
+ offset::value
+ <=
+ bit_width< storage_type >::value + 1
     ));
 
     /** Meta-calculations used for enabling and disabling functionality based
@@ -358,6 +443,52 @@
         storage_policy_stack
>::type is_stack_allocated;
 
+#if 1
+ void display_debug_info() {
+ using namespace std;
+
+ typedef typename details::bft_impl_<T0, mpl::void_,mpl::vector<>,mpl::size_t<0u> >::type step_1;
+ cout << step_1::offset::value << endl;
+ step_1::debug_info();
+
+ typedef typename step_1::template process<T1 >::type step_2;
+ // cout << step_2::offset::value << endl;
+ step_2::debug_info();
+
+ typedef typename step_2::template process<T2>::type step_3;
+ // cout << step_3::offset::value << endl;
+ step_3::debug_info();
+
+ typedef typename step_3::template process<T3>::type step_4;
+ // cout << step_4::offset::value << endl;
+ step_4::debug_info();
+
+ typedef typename step_4::template process<T4>::type step_5;
+ // cout << step_5::offset::value << endl;
+ step_5::debug_info();
+
+ typedef typename step_5::template process<T5>::type step_6;
+ // cout << step_6::offset::value << endl;
+ step_6::debug_info();
+
+ typedef typename step_6::template process<T6>::type step_7;
+ // cout << step_7::offset::value << endl;
+ step_7::debug_info();
+
+ typedef typename step_7::template process<T7>::type step_8;
+ // cout << step_8::offset::value << endl;
+ step_8::debug_info();
+
+ typedef typename step_8::template process<T8>::type step_9;
+ // cout << step_9::offset::value << endl;
+ step_9::debug_info();
+
+ typedef typename step_9::template process<T9>::type step_10;
+ // cout << step_10::offset::value << endl;
+ step_10::debug_info();
+
+ }
+#endif
 };
 
 #undef BOOST_BFT_ARG_PROCESSING_CLASS
@@ -439,7 +570,10 @@
          return this->get_data();
     }
     //@}
-
+
+ void debug() {
+ this->display_debug_info();
+ }
     
 };
 

Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/member.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/member.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/member.hpp 2010-06-10 12:04:41 EDT (Thu, 10 Jun 2010)
@@ -9,9 +9,11 @@
 #include <cstddef>
 #include <boost/type_traits.hpp>
 #include <boost/static_assert.hpp>
-
+#include <boost/mpl/size_t.hpp>
 namespace boost {
 
+
+
 /** The purpose of the member struct is to provide a simple way of passing
  * parameters into a bitfield_tuple or bit_mask_tuple. The use of this is
  * specifically to associate a group of parameters to gather within a type
@@ -27,8 +29,11 @@
     typedef ReturnType return_type;
     typedef Name name_type;
     BOOST_STATIC_CONSTANT(std::size_t, field_width = FieldWidth);
+
 };
 
+
+
 } // end boost
 
 #endif

Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/storage.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/storage.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/storage.hpp 2010-06-10 12:04:41 EDT (Thu, 10 Jun 2010)
@@ -48,6 +48,7 @@
     typedef StorageType storage_type;
     typedef storage_policy_stack alloc;
     typedef storage<StorageType, storage_policy_stack> type;
+
 };
 
 } // end boost

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 2010-06-10 12:04:41 EDT (Thu, 10 Jun 2010)
@@ -25,8 +25,10 @@
         [ run bitwise_low_bits_testing.cpp ]
         [ run compound_mask_test.cpp ]
         [ run bit_mask_group_test.cpp ]
- [ run bitfield_tuple_test.cpp ]
         [ compile-fail bft_testing/compile_fail/member_precond_width_zero.cpp ]
         [ compile-fail bft_testing/compile_fail/bft_no_storage_type.cpp ]
+ [ compile-fail bft_testing/compile_fail/non_pod_storage_type.cpp ]
+ [ compile-fail bft_testing/compile_fail/bft_storage_width_acceded.cpp ]
+ [ run bitfield_tuple_test.cpp ]
     ;
 

Added: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/compile_fail/bft_storage_width_acceded.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/compile_fail/bft_storage_width_acceded.cpp 2010-06-10 12:04:41 EDT (Thu, 10 Jun 2010)
@@ -0,0 +1,26 @@
+// Copyright 2010 Brian Bartman.
+// 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)
+
+#include <iostream>
+#include <boost/integer/bitfield_tuple.hpp>
+
+using namespace boost;
+struct red { };
+
+// Fails because the members exced the number of bits inside of
+// the storage type.
+typedef bitfield_tuple<
+ storage<int>,
+ member<int, red, 10u>
+> bft;
+
+
+
+int main() {
+ typedef bft::offset something;
+ std::cout << bft::offset::value << std::endl;
+ bft();
+ return 0;
+}

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/compile_fail/non_pod_storage_type.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/compile_fail/non_pod_storage_type.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/compile_fail/non_pod_storage_type.cpp 2010-06-10 12:04:41 EDT (Thu, 10 Jun 2010)
@@ -0,0 +1,18 @@
+// Copyright 2010 Brian Bartman.
+// 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)
+
+
+#include <boost/integer/bitfield_tuple.hpp>
+
+using namespace boost;
+struct red { };
+// Fails because storage type is not a POD type.
+typedef bitfield_tuple<storage<red>, member<int,red,3> > bft;
+
+
+int main() {
+ bft();
+ 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