|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62600 - in sandbox/SOC/2010/bit_masks: boost/integer lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-06-08 17:18:47
Author: bbartman
Date: 2010-06-08 17:18:43 EDT (Tue, 08 Jun 2010)
New Revision: 62600
URL: http://svn.boost.org/trac/boost/changeset/62600
Log:
still working on getting bit_field_tupe working the way I want it to be
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 62 +++++++++++++++++++++++++------------
sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_tuple_test.cpp | 66 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 106 insertions(+), 22 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-08 17:18:43 EDT (Tue, 08 Jun 2010)
@@ -22,6 +22,10 @@
namespace details {
+
+
+
+
/** This is the type which sits inside the mpl vector type.
* This has all information for constructing a bitfield.
*/
@@ -32,12 +36,27 @@
>
struct bitfield_element_ {
typedef ReturnType return_type;
- typedef NameType name;
+ typedef NameType name_type;
BOOST_STATIC_CONSTANT( std::size_t, offset = Offset );
- BOOST_STATIC_CONSTANT( std::size_t, width = FieldWidth );
- typedef bitfield_element_<return_type, name, offset, width> type;
+ BOOST_STATIC_CONSTANT( std::size_t, field_width = FieldWidth );
+ typedef bitfield_element_<return_type, name_type, offset, field_width> type;
};
+/** Default case for managing template parameters. */
+template <typename Param, typename FieldVector, std::size_t Offset>
+struct bft_impl_ {
+ typedef Param param;
+ typedef FieldVector field_vector;
+ BOOST_STATIC_CONSTANT( std::size_t, offset = Offset );
+
+ typedef bft_impl_<param,field_vector,offset> type;
+
+ template <typename NextParam>
+ struct process {
+ typedef typename bft_impl_<NextParam, field_vector, Offset>::type type;
+ };
+};
+#if 0
/** Template Parameter descriptions and behaviors.
* Storage - Is the storage type. The behavior for this is going to be
* static assertion if set_storage is called and storage_type is something
@@ -68,6 +87,7 @@
next_offset
> type;
+ typedef bitfield_tuple_info_<storage_policy,field_vector,next_offset> _self;
/** Internal meta functions which are used to abstract overly complex
* operations which would normally be done via rebinding but that it
* a massive pain. This is simplier to deal with from a usability
@@ -86,32 +106,34 @@
struct set_storage {
// BOOST_STATIC_ASSERT(( !is_same< storage_policy, mpl::void_ >::value ));
- typedef bitfield_tuple_info_ <
+ typedef typename bitfield_tuple_info_ <
NewStorageType,
field_vector,
next_offset
- > type;
+ >::type type;
};
/** Used to add a single structure into the field_vector. */
template <typename TypeToAdd>
struct add_field {
- typedef bitfield_tuple_info_ <
- storage_policy,
+ typedef typename bitfield_element_<
+ typename TypeToAdd::return_type,
+ typename TypeToAdd::name_type,
+ next_offset,
+ TypeToAdd::field_width
+ >::type bft_element;
+
+ typedef typename mpl::push_back <
+ typename _self::field_vector::type,
+ bft_element
+ >::type new_field_vector;
- // adding parameter into the element type.
- typename mpl::push_back <
- field_vector,
- typename bitfield_element_ <
- typename TypeToAdd::return_type,
- typename TypeToAdd::name,
- next_offset,
- TypeToAdd::field_width
- >::type
- >::type,
+ typedef typename bitfield_tuple_info_ <
+ storage_policy,
+ typename new_field_vector::type,
NextOffset + TypeToAdd::field_width
- > type;
+ >::type type;
};
//@}
};
@@ -206,7 +228,7 @@
>::type allocation_policy;
*/
};
-
+#endif
} // end details
@@ -222,7 +244,7 @@
typename T9 = mpl::void_
>
class bitfield_tuple
- :public details::bft_impl_<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>
+ // : // public details::bft_impl_<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>
{
};
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-08 17:18:43 EDT (Tue, 08 Jun 2010)
@@ -7,7 +7,9 @@
#include "test_type_list.hpp"
void ignore(...) {}
-struct red;
+struct red { };
+struct green { };
+struct blue { };
int main() {
// lets make some errors : )
// bitfield_tuple < storage<int>, member<int,red,6> > temp;
@@ -16,8 +18,68 @@
typedef storage<int, std::allocator<int> > test1;
test1 s;
ignore( s );
+
+ // make sure that the storage policy is the correct policy.
+ BOOST_ASSERT((
+ is_same<
+ test1::alloc,
+ std::allocator<int>
+ >::value
+ ));
+
+ BOOST_ASSERT((
+ is_same<
+ test1::storage_type,
+ int
+ >::value
+ ));
+ typedef storage<int, std::allocator<char> > test2;
+ BOOST_ASSERT((
+ is_same<
+ test2::alloc,
+ std::allocator<int>
+ >::value
+ ));
+
+ BOOST_ASSERT((
+ is_same<
+ int,
+ test2::storage_type
+ >::value
+ ));
+
+ typedef storage<char> test3;
+ BOOST_ASSERT((
+ is_same<
+ test3::alloc,
+ storage_policy_stack
+ >::value
+ ));
+
+ BOOST_ASSERT((
+ is_same<
+ test3::storage_type,
+ char
+ >::value
+ ));
+ }
+ // testing member type
+ {
+ typedef member<int, blue, 6 > member_test_1;
+ BOOST_ASSERT(( is_same<member_test_1::return_type, int>::value ));
+ BOOST_ASSERT(( is_same<member_test_1::name_type, blue>::value ));
+ BOOST_ASSERT(( member_test_1::field_width == 6 ));
+ }
+ // testing bitfield_element_
+ {
+ // bitfield_element_
+ typedef details::bitfield_element_<int,red,5,4> bft_element_test_1;
+ BOOST_ASSERT(( is_same<bft_element_test_1::return_type, int>::value ));
+ BOOST_ASSERT(( is_same<bft_element_test_1::name_type, red>::value ));
+ BOOST_ASSERT(( bft_element_test_1::offset == 5 ));
+ BOOST_ASSERT(( bft_element_test_1::field_width == 4 ));
+
}
-
#if 0
details::bft_impl_< storage<int, storage_policy_stack>,
member<int, red, 6u>,
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