Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64319 - in sandbox/SOC/2010/bit_masks: . boost/integer/detail/bft lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-07-24 17:54:47


Author: bbartman
Date: 2010-07-24 17:54:44 EDT (Sat, 24 Jul 2010)
New Revision: 64319
URL: http://svn.boost.org/trac/boost/changeset/64319

Log:
fixed the pointer problem now everything is working again I just need to suppress something under GCC because something is complaining about me storing a full sized int.
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/arg_parse_impl.hpp | 85 ---------
   sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/pointer_packing_policy.hpp | 357 ++++++++++++---------------------------
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/pointer_member_test.cpp | 333 ++++++++++++++++++++++++++----------
   sandbox/SOC/2010/bit_masks/notes.txt | 6
   4 files changed, 353 insertions(+), 428 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/arg_parse_impl.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/arg_parse_impl.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/arg_parse_impl.hpp 2010-07-24 17:54:44 EDT (Sat, 24 Jul 2010)
@@ -410,105 +410,26 @@
             back_storage_space
>::type
>::type size_of_storage;
-/*
-Info to know about the curret state of parsing.
- 1) Is the curret front_storage_space zero?
- This means that there are no leading zeros.
- 2) Is the rear storage space zero.
- there is no trailing zeros.
- 3) number of bits being stored for the pointer.
- calculated as the number of bits in the mask -
- (back_storage_space + front_storage_space)
-
-*/
-
-
- // Logic for determining how to actually store the pointer.
- typedef typename mpl::if_c<front_storage_space::value == 0,
- mpl::false_,mpl::true_>::type uses_front_storage;
-
- typedef typename mpl::if_c<back_storage_space::value == 0,
- mpl::false_,mpl::true_>::type uses_back_storage;
-
- // calculating mask offset, data offset and the offset for the next field.
- typedef typename mpl::if_<
- uses_front_storage,
- // calculate offset
- typename mpl::if_<
- mpl::less_equal<
- Offset,
- front_storage_space
- >,
- mpl::size_t<0>,
- mpl::minus<Offset, front_storage_space>
- >::type,
- Offset
- >::type mask_offset;
-
 
- // calculating the offset of the value bits inside of the masks.
- typedef typename mpl::if_<
- uses_front_storage,
- typename mpl::if_<
- mpl::less_equal<
- Offset,
- front_storage_space
- >,
- front_storage_space,
- typename mpl::minus<Offset, front_storage_space>::type
- >::type,
- Offset
- >::type data_offset;
 
     typedef typename mpl::plus< Offset, size_of_storage>::type offset;
 
     typedef bitfields::pointer< ReturnType, Name, Mask > param;
 
- // if the offset is greater then then number of storage bits
- // the this pointer is not going to be aligned within storage.
- typedef typename mpl::if_<
- mpl::greater<
- Offset,
- front_storage_space
- >,
- typename mpl::if_<
- mpl::and_<
- mpl::not_<
- uses_front_storage
- >,
- integral_constant<
- bool,
- (Offset::value == 32)
- >
- >,
- mpl::true_,
- mpl::false_
- >::type,
- mpl::true_
- >::type is_aligned;
-
- //
- typedef typename mpl::if_<is_aligned,
- bit_shift::none,
- bit_shift::right< mpl::minus<Offset,front_storage_space>::type::value>
- >::type alignment_shift;
-
     typedef StoragePolicy storage_policy;
     typedef typename mpl::push_back<
         FieldVector,
         bitfield_element<
             ReturnType*,
             Name,
- data_offset,
+ Offset,
             size_of_storage,
             Mask,
             pointer_packing_policy<
                 Mask,
                 ReturnType*,
- offset,
- size_of_storage,
- is_aligned,
- alignment_shift
+ Offset,
+ size_of_storage
>
>
>::type field_vector;

Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/pointer_packing_policy.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/pointer_packing_policy.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/pointer_packing_policy.hpp 2010-07-24 17:54:44 EDT (Sat, 24 Jul 2010)
@@ -7,6 +7,8 @@
 #ifndef BOOST_BITFIELD_TUPLE_POINTER_PACKING_POLICY_HPP
 #define BOOST_BITFIELD_TUPLE_POINTER_PACKING_POLICY_HPP
 #include <cstddef>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
 
 namespace boost { namespace detail { namespace bit_shift {
 
@@ -15,338 +17,203 @@
 struct none;
 
 } // end bit_shift
+
 // detial's relating to the set and get functions.
 namespace policy_detail {
 
-/** This is specialization deffered because I can't do it completly until this
- * pointer because I don't have all the infromation so its easiest to do it
- * here.
- */
 template <
     typename Mask,
- typename Offset,
     typename ValueType,
     typename StorageType,
- bool
+ typename Shift
>
 struct apply_impl;
 
+template <
+ typename Mask,
+ typename ValueType,
+ typename StorageType
+>
+struct apply_impl <Mask,ValueType,StorageType,bit_shift::none > {
 
-/** Specialization where for the storage type and the size of the mask being
- * the same.
- */
-template <typename Mask, typename Offset, typename ValueType, typename StorageType>
-struct apply_impl < Mask, Offset, ValueType, StorageType, true > {
-
- typedef Mask get_mask;
- typedef integral_constant<
- typename get_mask::value_type,
- ~get_mask::value
- > set_mask;
- typedef ValueType value_type;
- typedef StorageType storage_type;
-
- static value_type get(storage_type storage ) {
- return value_type(storage & get_mask::value);
- }
-
- static storage_type set(storage_type storage, value_type ptr) {
- return storage_type(
- (storage & set_mask::value)
- |
- (typename get_mask::value_type(ptr) & get_mask::value)
- );
- }
-};
-
-
-/** This specialization is for systems whichs support interal types
- * larger then their pointer type OR in other words the storage type is larger
- * then the type of the mask.
- */
-template <typename Mask, typename Offset, typename ValueType, typename StorageType>
-struct apply_impl < Mask, Offset, ValueType, StorageType, false > {
- typedef ValueType value_type;
- typedef StorageType storage_type;
- typedef Mask mask;
-
- // this is going to be for computers with integral types LARGER then
- // the size of their pointer type.
- typedef mpl::size_t<
- bit_width<storage_type>::value - bit_width<typename mask::value_type>::value
- > shift_amount;
-
- typedef typename mpl::shift_left<
- integral_constant<
- typename make_unsigned<storage_type>::type,
- mask::value
- >,
- shift_amount
- >::type get_mask;
-
- typedef integral_constant<
- typename get_mask::value_type,
- ~get_mask::value
- > set_mask;
-
- static value_type get(storage_type storage) {
- return value_type((storage & get_mask::value) >> shift_amount::value) ;
- }
-
- static storage_type set(storage_type storage, value_type ptr) {
- return storage_type(
- (storage & set_mask::value)
- |
- (typename get_mask::value_type(ptr) & Mask::value) << shift_amount::value
- );
- }
-};
-
+ typedef ValueType value_type;
+ typedef StorageType storage_type;
 
-/** This specialization is for systems whichs support interal types
- * larger then their pointer type OR in other words the storage type is larger
- * then the type of the mask. This specialization is for pointers which are
- * aligned to a 32 bit boundry meaning they can be accessed in the same number
- * of steps as a 32 bit pointer which is stored within int sized type.
- */
-template <typename Mask, typename ValueType>
-struct apply_impl < Mask, mpl::size_t<32>, ValueType, long long, false > {
+ typedef Mask get_mask;
 
- typedef integral_constant<unsigned long long, Mask::value> get_mask;
     typedef integral_constant<
- unsigned long long,
- ~ get_mask::value
+ storage_type,
+ ~storage_type( get_mask::value )
> set_mask;
- typedef ValueType value_type;
- typedef long long storage_type;
 
- static value_type get(storage_type storage ) {
- return value_type(storage & get_mask::value);
- }
 
- static storage_type set(storage_type storage, value_type ptr) {
- return storage_type(
- (storage & set_mask::value)
- |
- (typename get_mask::value_type(ptr) & Mask::value)
- );
- }
-};
-
-/** This specialization is for systems whichs support interal types
- * larger then their pointer type OR in other words the storage type is larger
- * then the type of the mask. This specialization is for pointers which are
- * aligned to a 32 bit boundry meaning they can be accessed in the same number
- * of steps as a 32 bit pointer which is stored within int sized type.
- */
-template <typename Mask, typename ValueType>
-struct apply_impl <
- Mask,
- mpl::size_t<32>,
- ValueType,
- unsigned long long,
- false
-> {
- typedef integral_constant<unsigned long long, Mask::value> get_mask;
- typedef integral_constant<
- unsigned long long,
- ~get_mask::value
- > set_mask;
- typedef ValueType value_type;
- typedef unsigned long long storage_type;
 
     static value_type get(storage_type storage) {
- return value_type(storage & get_mask::value);
+ return value_type( storage & get_mask::value );
     }
 
     static storage_type set(storage_type storage, value_type ptr) {
         return storage_type(
- (storage & set_mask::value)
- |
- (typename get_mask::value_type(ptr) & Mask::value)
+ (set_mask::value & storage)
+ |
+ (get_mask::value & typename get_mask::value_type(ptr))
         );
     }
 };
 
 template <
     typename Mask,
- typename Offset,
     typename ValueType,
     typename StorageType,
- typename MaskShift,
- bool
+ std::size_t Shift
>
-struct apply_shift_impl {
- typedef Mask mask;
- typedef Offset offset;
- typedef ValueType value_type;
- typedef StorageType storage_type;
- typedef MaskShift mask_shift_amount;
-
- typedef typename mpl::shift_right<
- mask,
- mask_shift_amount
- >::type get_mask;
+struct apply_impl <Mask,ValueType,StorageType,bit_shift::right<Shift> > {
+
+ typedef ValueType value_type;
+ typedef StorageType storage_type;
+
+ typedef Mask get_from_ptr_mask;
+ typedef typename mpl::shift_right<
+ integral_constant<
+ storage_type,
+ Mask::value
+ >,
+ mpl::size_t<Shift>
+ >::type get_mask;
 
     typedef integral_constant<
- typename get_mask::value_type,
+ storage_type,
         ~get_mask::value
- > set_mask;
-
+ > set_mask;
+
+
     static value_type get(storage_type storage) {
- return value_type(
- (storage & get_mask::value)
- <<
- mask_shift_amount::value
- );
+ return value_type( (get_mask::value & storage) << Shift);
     }
 
     static storage_type set(storage_type storage, value_type ptr) {
         return storage_type(
- ((typename get_mask::value_type(ptr) & get_mask::value)
- >>
- mask_shift_amount::value)
+ (storage & set_mask::value)
               |
- (set_mask::value & storage)
+ ((storage_type(ptr) & get_from_ptr_mask::value) >> Shift )
         );
     }
 };
 
 template <
     typename Mask,
- typename Offset,
     typename ValueType,
     typename StorageType,
- typename MaskShift
+ std::size_t Shift
>
-struct apply_shift_impl<Mask,Offset,ValueType,StorageType,MaskShift,false>{
- typedef Mask mask;
- typedef Offset offset;
- typedef ValueType value_type;
- typedef StorageType storage_type;
- typedef MaskShift mask_shift_amount;
+struct apply_impl <Mask,ValueType,StorageType,bit_shift::left<Shift> > {
 
- // calculating shift for correctly aligning mask
- // with storage type.
- typedef typename mpl::minus<
- typename mpl::minus<
- bit_width<storage_type>,
- mask_shift_amount
- >::type,
- bit_width<
- typename mask::value_type
- >
- >::type correction_shift_amount;
+ typedef ValueType value_type;
+ typedef StorageType storage_type;
+ typedef Mask get_from_ptr_mask;
+ typedef typename mpl::shift_left<
+ integral_constant<
+ storage_type,
+ Mask::value
+ >,
+ mpl::size_t<Shift>
+ >::type get_mask;
 
- typedef typename mpl::shift_left<
- integral_constant<storage_type, storage_type(mask::value)>,
- correction_shift_amount
- >::type get_mask;
 
     typedef integral_constant<
- typename get_mask::value_type,
- typename get_mask::value_type(~get_mask::value)
+ storage_type,
+ ~get_mask::value
> set_mask;
 
- static value_type get(storage_type storage ) {
- return value_type(
- (storage & get_mask::value)
- >>
- correction_shift_amount::value
- );
+ static value_type get(storage_type storage) {
+ return value_type( (storage & get_mask::value) >> Shift );
     }
 
     static storage_type set(storage_type storage, value_type ptr) {
-
         return storage_type(
- (storage_type(typename mask::value_type(ptr))
- <<
- correction_shift_amount::value)
+ (storage & set_mask::value)
               |
- (set_mask::value & storage)
+ ((storage_type(ptr) & get_from_ptr_mask::value) << Shift )
         );
     }
-
-
 };
 
 
-} // end policy_detail
 
-/** Only specilization exist for no shift and shift right however
- * that doesn't mean that in the future this can't be adapted for preform
- * left shift on the pointer.
- */
-template <
- typename Mask,
- typename ValueType,
- typename Offset,
- typename Width,
- typename IsAligned,
- typename DirectionShifted
->
-struct pointer_packing_policy;
 
-/** Non-shifted policy. */
-template <
+template<
     typename Mask,
     typename ValueType,
     typename Offset,
- typename Width
+ typename Width,
+ typename StorageType
>
-struct pointer_packing_policy<
- Mask,
- ValueType,
- Offset,
- Width,
- mpl::true_,
- bit_shift::none
-> {
- typedef Mask mask;
- typedef ValueType value_type;
+struct deduce_policy {
+
+ // getting front storage.
+ typedef typename pointer_member::count_leading_zeros<
+ Mask>::type front_storage_space;
 
- template <typename StorageType>
- struct apply
- :policy_detail::apply_impl<
- Mask,
- Offset,
- ValueType,
- StorageType,
- sizeof(StorageType) == sizeof(typename mask::value_type)
- > { };
+ typedef typename pointer_member::count_trailing_zeros<
+ Mask>::type back_storage_space;
+
+ // getting the basic information for calculating the shift on
+ // a mask
+ typedef typename mpl::minus<
+ mpl::int_< bit_width<StorageType>::value >,
+ mpl::int_<
+ mpl::plus<
+ Offset,
+ Width,
+ back_storage_space
+ >::type::value
+ >
+ >::type mask_shift_value;
+
+ typedef typename mpl::if_<
+ mpl::less<
+ mask_shift_value,
+ mpl::int_<0>
+ >,
+ // less then.
+ bit_shift::right<
+ mpl::minus<mpl::int_<0>, mask_shift_value >::type::value
+ >,
+ typename mpl::if_<
+ mpl::equal_to< mpl::int_<0>, mask_shift_value>,
+ // equal to so no shift
+ bit_shift::none,
+ // greater then so go right.
+ bit_shift::left< mask_shift_value::value >
+ >::type
+ >::type mask_shift;
+
+ typedef apply_impl<Mask,ValueType,StorageType,mask_shift> type;
 };
 
+} // end policy_detail
 
-/** Specilization for when the pointer is shifted right. */
 template <
     typename Mask,
     typename ValueType,
     typename Offset,
- typename Width,
- std::size_t ShiftAmount
->
-struct pointer_packing_policy<
- Mask,
- ValueType,
- Offset,
- Width,
- mpl::false_,
- bit_shift::right<ShiftAmount>
-> {
+ typename Width
+>
+struct pointer_packing_policy {
     typedef Mask mask;
     typedef ValueType value_type;
     
+
     template <typename StorageType>
     struct apply
- :policy_detail::apply_shift_impl<
+ : policy_detail::deduce_policy<
             Mask,
- Offset,
             ValueType,
- StorageType,
- mpl::size_t<ShiftAmount>,
- sizeof(StorageType) == sizeof(typename Mask::value_type)
- > { };
-
+ Offset,
+ Width,
+ StorageType
+ >::type
+ { };
 };
 
 }} // end boost::detial

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/pointer_member_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/pointer_member_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/pointer_member_test.cpp 2010-07-24 17:54:44 EDT (Sat, 24 Jul 2010)
@@ -15,180 +15,323 @@
 struct rd;
 struct b1;
 struct b2;
+struct i1;
 
-typedef bitfield_tuple< pointer<int, rd> > test_type_1;
-typedef bitfield_tuple< pointer<int, rd>, flag<b1>, flag<b2> > test_type_2;
-// this is first half long long
-typedef bitfield_tuple<
- storage<long long>,
- pointer<int, rd>,
- flag<b1>,
- flag<b2>
-> test_type_3;
 
-#if( _LP64 != 1)
-// This is second half long long
-// note this only works on 32 bit systems Need to remove this from the test
-// in the event that its being test on a 64 bit architecture
-typedef bitfield_tuple<
- storage<long long>,
- member<int, short, 32>,
- pointer<int, rd>,
- flag<b1>,
- flag<b2>
-> test_type_4;
-
-typedef bitfield_tuple<
- storage<unsigned long long>,
- member<int, short, 32>,
- pointer<int, rd>,
- flag<b1>,
- flag<b2>
-> test_type_5;
-#endif
 
-typedef bitfield_tuple<
- storage<unsigned long long>,
- filler<2>,
- pointer<int, rd,
- bits_mask<
- detail::ptr_mask_type,
- 2,
- bit_width<
- detail::ptr_mask_type
- >::value - 4
- >
- >,
- flag<b1>,
- flag<b2>
-> test_type_6;
-
-typedef bitfield_tuple<
- storage<unsigned long long>,
- filler<3>,
- pointer<int, rd,
- bits_mask<
- detail::ptr_mask_type,
- 2,
- bit_width<
- detail::ptr_mask_type
- >::value - 4
- >
- >
-> test_type_7;
+typedef int* my_intptr_t;
+
 int main() {
     {
- test_type_1 t1;
- int i=0;
+ typedef bitfield_tuple< pointer<int, rd> > test_type_1;
+
+ BOOST_TEST((
+ is_same<
+ test_type_1::storage_type,
+ detail::ptr_mask_type
+ >::value
+ ));
+
+ test_type_1 t1;
+ int i=0;
+
+ t1.get<rd>() = &i;
+
+ BOOST_TEST(*t1.get<rd>() == 0);
+
+ i = 5;
+
+ BOOST_TEST(*t1.get<rd>() == 5);
 
- t1.get<rd>() = &i;
- BOOST_TEST(*t1.get<rd>() == 0);
- i = 5;
- BOOST_TEST(*t1.get<rd>() == 5);
     }
 
     // double boolean test.
     {
- test_type_2 t2;
- int i=0;
- t2.get<rd>() = &i;
- BOOST_TEST(*t2.get<rd>() == 0);
- i = 5;
- BOOST_TEST(*t2.get<rd>() == 5);
- BOOST_TEST(t2.get<b1>() == false );
- BOOST_TEST(t2.get<b2>() == false );
- t2.get<b1>() = true;
- t2.get<b2>() = true;
-
- BOOST_TEST(*t2.get<rd>() == 5);
- BOOST_TEST(t2.get<b1>() );
- BOOST_TEST(t2.get<b2>() );
+ typedef bitfield_tuple< pointer<int, rd>, flag<b1>, flag<b2> > test_type_2;
+
+ BOOST_TEST((
+ is_same<
+ test_type_2::storage_type,
+ detail::ptr_mask_type
+ >::value
+ ));
+
+ test_type_2 t2;
+ int i=0;
+
+ t2.get<rd>() = &i;
+
+ BOOST_TEST(*t2.get<rd>() == 0);
+
+ i = 5;
+
+ BOOST_TEST(*t2.get<rd>() == 5);
+ BOOST_TEST(t2.get<b1>() == false );
+ BOOST_TEST(t2.get<b2>() == false );
+
+ t2.get<b1>() = true;
+ t2.get<b2>() = true;
+
+ BOOST_TEST(*t2.get<rd>() == 5);
+ BOOST_TEST(t2.get<b1>() );
+ BOOST_TEST(t2.get<b2>() );
     
     }
+
     // NOTE this test may fail on 64 bit machines but I need to test it
     // either way.
 #if( _LP64 != 1)
     {
-
+ typedef bitfield_tuple<
+ storage<long long>,
+ pointer<int, rd>,
+ flag<b1>,
+ flag<b2>
+ > test_type_3;
+ BOOST_TEST((
+ is_same<
+ test_type_3::storage_type,
+ long long
+ >::value
+ ));
+
         test_type_3 t3;
         int i = 30;
+
+ t3.get<b1>() = true;
+ t3.get<b2>() = true;
         t3.get<rd>() = &i;
+
         BOOST_TEST(*t3.get<rd>() == 30 );
+ BOOST_TEST( t3.get<b1>() == true);
+ BOOST_TEST( t3.get<b2>() == true);
     }
 
     // this test will also fail on 64 bit machines.
     {
+ // This is second half long long
+ // note this only works on 32 bit systems Need to remove this from the test
+ // in the event that its being test on a 64 bit architecture
+ typedef bitfield_tuple<
+ storage<long long>,
+ member<unsigned int, i1, 32>,
+ pointer<int, rd>,
+ flag<b1>,
+ flag<b2>
+ > test_type_4;
+ BOOST_TEST((
+ is_same<
+ test_type_4::storage_type,
+ long long
+ >::value
+ ));
+
         test_type_4 t4;
         int i = 70;
+
+ t4.get<i1>() = 0xffffffff;
+ t4.get<b1>() = true;
+ t4.get<b2>() = true;
         t4.get<rd>() = &i;
+
         BOOST_TEST( *t4.get<rd>() == 70 );
+ BOOST_TEST( t4.get<i1>() == 0xffffffff);
+ std::cout << "Value of i1: " << std::hex << t4.get<i1>() << std::endl;
+ BOOST_TEST( t4.get<b1>() == true);
+ BOOST_TEST( t4.get<b2>() == true);
     }
 
     // this test will also fail on 64 bit machines.
     {
+ typedef bitfield_tuple<
+ storage<unsigned long long>,
+ member<unsigned int, i1, 32>,
+ pointer<int, rd>,
+ flag<b1>,
+ flag<b2>
+ > test_type_5;
+
+ BOOST_TEST((
+ is_same<
+ test_type_5::storage_type,
+ unsigned long long
+ >::value
+ ));
+
         test_type_5 t5;
         int i = 70;
+
+ t5.get<i1>() = 0xffffffff;
+ t5.get<b1>() = true;
+ t5.get<b2>() = true;
         t5.get<rd>() = &i;
+
         BOOST_TEST( *t5.get<rd>() == 70 );
+ BOOST_TEST( t5.get<i1>() == 0xffffffff);
+ std::cout << "Value of i1: " << std::hex << t5.get<i1>() << std::endl;
+ BOOST_TEST( t5.get<b1>() == true);
+ BOOST_TEST( t5.get<b2>() == true);
     }
 #endif
+
     {
+ typedef bitfield_tuple<
+ storage<unsigned long long>,
+ member<unsigned int,i1,2>,
+ pointer<int, rd,
+ bits_mask<
+ detail::ptr_mask_type,
+ 2,
+ bit_width<
+ detail::ptr_mask_type
+ >::value - 4
+ >
+ >,
+ flag<b1>,
+ flag<b2>
+ > test_type_6;
+
+ BOOST_TEST((
+ is_same<
+ test_type_6::storage_type,
+ unsigned long long
+ >::value
+ ));
+
         test_type_6 t6;
         int i = 70;
         
+ // getting first 2 btis of pointer.
         detail::ptr_mask_type ptr = high_bits_mask<
- detail::ptr_mask_type,
- 2
- >::value
- &
- detail::ptr_mask_type(&i);
+ detail::ptr_mask_type,2>::value & detail::ptr_mask_type(&i);
 
         std::cout<< "value of &i: " << std::hex << &i << std::endl;
         std::cout<< "2 bits of &i: " << std::hex << ptr << std::endl;
 
+ t6.get<i1>() = 0xf;
+ t6.get<b1>() = true;
+ t6.get<b2>() = true;
         t6.get<rd>() = &i;
 
         int* temp_ptr = t6.get<rd>();
+
         std::cout<< "Value of temp_ptr: " << std::hex << temp_ptr << std::endl;
+
+ // rebuilding pointer.
         detail::ptr_mask_type temp_int = detail::ptr_mask_type(temp_ptr);
         temp_int |= detail::ptr_mask_type( ptr );
- typedef int* intptr_t;
- temp_ptr = intptr_t(temp_int);
+ temp_ptr = my_intptr_t(temp_int);
+
 
         std::cout<< "Value of temp_int: " << std::hex<< temp_int << std::endl;
         std::cout<< "Value returned from t6.get<rd>(): " << std::hex <<
             temp_ptr << std::endl;
 
         BOOST_TEST( * temp_ptr == 70 );
+ BOOST_TEST( t6.get<i1>() == 3u );
+ BOOST_TEST( t6.get<b1>() == true );
+ BOOST_TEST( t6.get<b2>() == true );
     }
+
     {
+ typedef bitfield_tuple<
+ storage<unsigned long long>,
+ member<unsigned int,i1,3>,
+ pointer<int, rd,
+ bits_mask<
+ detail::ptr_mask_type,
+ 2,
+ bit_width<
+ detail::ptr_mask_type
+ >::value - 4
+ >
+ >,
+ flag<b1>
+ > test_type_7;
+ BOOST_TEST((
+ is_same<
+ test_type_7::storage_type,
+ unsigned long long
+ >::value
+ ));
+
         test_type_7 t7;
         int i = 70;
         
+ // getting first 2 bits of pointer.
         detail::ptr_mask_type ptr = high_bits_mask<
- detail::ptr_mask_type,
- 2
- >::value
- &
- detail::ptr_mask_type(&i);
+ detail::ptr_mask_type,2>::value & detail::ptr_mask_type(&i);
 
         std::cout<< "value of &i: " << std::hex << &i << std::endl;
         std::cout<< "2 bits of &i: " << std::hex << ptr << std::endl;
-
+ t7.get<i1>() = 0x7;
+ t7.get<b1>() = true;
         t7.get<rd>() = &i;
 
         int* temp_ptr = t7.get<rd>();
+
         std::cout<< "Value of temp_ptr: " << std::hex << temp_ptr << std::endl;
+
         detail::ptr_mask_type temp_int = detail::ptr_mask_type(temp_ptr);
         temp_int |= detail::ptr_mask_type( ptr );
- typedef int* intptr_t;
- temp_ptr = intptr_t(temp_int);
+ temp_ptr = my_intptr_t(temp_int);
 
         std::cout<< "Value of temp_int: " << std::hex<< temp_int << std::endl;
- std::cout<< "Value returned from t6.get<rd>(): " << std::hex <<
+ std::cout<< "Value returned from t7.get<rd>(): " << std::hex <<
+ temp_ptr << std::endl;
+
+ BOOST_TEST( *temp_ptr == 70 );
+ BOOST_TEST( t7.get<i1>() == 7u );
+ BOOST_TEST( t7.get<b1>() == true );
+ }
+
+ {
+ typedef bitfield_tuple<
+ pointer<int, rd,
+ bits_mask<
+ detail::ptr_mask_type,
+ 2,
+ bit_width<
+ detail::ptr_mask_type
+ >::value - 4
+ >
+ >,
+ member<unsigned int, i1, 4>
+ > test_type_8;
+ BOOST_TEST((
+ is_same<
+ test_type_8::storage_type,
+ detail::ptr_mask_type
+ >::value
+ ));
+
+ test_type_8 t8;
+ int i = 70;
+
+ // getting first 2 bits of pointer.
+ detail::ptr_mask_type ptr = high_bits_mask<
+ detail::ptr_mask_type,2>::value & detail::ptr_mask_type(&i);
+
+ std::cout<< "value of &i: " << std::hex << &i << std::endl;
+ std::cout<< "2 bits of &i: " << std::hex << ptr << std::endl;
+
+ t8.get<i1>() = 0xf;
+ t8.get<rd>() = &i;
+
+ int* temp_ptr = t8.get<rd>();
+
+ std::cout<< "Value of temp_ptr: " << std::hex << temp_ptr << std::endl;
+
+ detail::ptr_mask_type temp_int = detail::ptr_mask_type(temp_ptr);
+ temp_int |= detail::ptr_mask_type( ptr );
+ temp_ptr = my_intptr_t(temp_int);
+
+ std::cout<< "Value of temp_int: " << std::hex<< temp_int << std::endl;
+ std::cout<< "Value returned from t8.get<rd>(): " << std::hex <<
             temp_ptr << std::endl;
 
         BOOST_TEST( *temp_ptr == 70 );
+ BOOST_TEST( t8.get<i1>() == 0xf);
     }
 
     return boost::report_errors();

Modified: sandbox/SOC/2010/bit_masks/notes.txt
==============================================================================
--- sandbox/SOC/2010/bit_masks/notes.txt (original)
+++ sandbox/SOC/2010/bit_masks/notes.txt 2010-07-24 17:54:44 EDT (Sat, 24 Jul 2010)
@@ -50,12 +50,6 @@
  
 
 14) bitfield_tuple.hpp
- a) Consider renaming disable_if_reference_type_by_name
- to
- disable_if_proxy_ref_type_by_name
- or something like that.
- This would only be for clarification measures as this type doesn't use
- real reference types.
 
 
 Test file review


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