|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64659 - in sandbox/SOC/2010/bit_masks: . boost/integer/detail/bitfield_vector lib/integer/test/bitfield_vector_testing
From: bbartmanboost_at_[hidden]
Date: 2010-08-07 10:11:35
Author: bbartman
Date: 2010-08-07 10:11:34 EDT (Sat, 07 Aug 2010)
New Revision: 64659
URL: http://svn.boost.org/trac/boost/changeset/64659
Log:
working on testing the set generation which is used for generating all possible offsets of a perticular width and storing them within an mpl::set
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/mask_creator.hpp | 98 ++++++++++++++++++++++++++++-----------
sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/mask_creator_test.cpp | 36 ++++++++++++++
sandbox/SOC/2010/bit_masks/notes.txt | 31 ++++++++++++
3 files changed, 137 insertions(+), 28 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/mask_creator.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/mask_creator.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/mask_creator.hpp 2010-08-07 10:11:34 EDT (Sat, 07 Aug 2010)
@@ -14,26 +14,11 @@
#include <boost/static_assert.hpp>
#include <boost/mpl/size_t.hpp>
#include <boost/mpl/greater.hpp>
+#include <boost/mpl/insert.hpp>
#include <cstddef>
namespace boost { namespace detail {
-
-
-/*
-template <std::size_t Width>
-inline std::size_t get_mask_array_size(std::size_t offset) {
- BOOST_ASSERT(( offset < 8));
- std::size_t total_bits = Width + offset;
- std::size_t ret = 0;
- ret = total_bits / 8;
- if(total_bits % 8) {
- ret += 1;
- }
- return ret;
-}
-*/
-
/** This calculates the size of the array needed to hold the entire mask
* based on an Offset and a Width.
*/
@@ -41,31 +26,88 @@
struct mask_size {
BOOST_STATIC_ASSERT( Offset::value < 8 );
- typedef typename mpl::plus<Offset,Width>::type total_bits;
- typedef typename mpl::divides<total_bits,mpl::size_t<8> >::type ret;
typedef typename mpl::if_<
mpl::greater<
- typename mpl::modulus< total_bits, mpl::size_t<8> >::type,
+ typename mpl::modulus<
+ typename mpl::plus<
+ Offset,
+ Width
+ >::type,
+ mpl::size_t<8>
+ >::type,
mpl::size_t<0>
>,
- typename mpl::plus<ret, mpl::size_t<1> >::type,
- ret
+ typename mpl::plus<
+ typename mpl::divides<
+ typename mpl::plus<
+ Offset,
+ Width
+ >::type,
+ mpl::size_t<8>
+ >::type,
+ mpl::size_t<1>
+ >::type,
+ typename mpl::divides<
+ typename mpl::plus<
+ Offset,
+ Width
+ >::type,
+ mpl::size_t<8>
+ >::type
>::type type;
};
-/*
+/** This is responsible for storing information about a perticular
+ * mask but not the mask it self.
+ */
template <std::size_t Offset, std::size_t Width>
struct mask_info {
BOOST_STATIC_CONSTANT(std::size_t, offset = Offset);
BOOST_STATIC_CONSTANT(std::size_t, width = Width );
-
+ BOOST_STATIC_CONSTANT(std::size_t, size =
+ (mask_size<
+ mpl::size_t<Offset>,
+ mpl::size_t<Width>
+ >::type::value)
+ );
+};
+
+
+
+/** Helper meta-function which is used to determine valid offsets for a
+ * perticular width.
+ */
+template <
+ std::size_t Width,
+ std::size_t Index = 0,
+ typename Set = mpl::set<>,
+ bool = true
+ >
+struct valid_offset_helper;
+
+template <std::size_t Width, std::size_t Index, typename Set>
+struct valid_offset_helper<Width,Index,Set,true>
+ :valid_offset_helper<
+ Width,
+ Index + 1,
+ typename mpl::insert<Set,bool,mpl::size_t<((Index * Width) % 8)> >::type,
+ bool(Index < 8)
+ >
+{ };
+
+
+template <std::size_t Width, std::size_t Index, typename Set>
+struct valid_offset_helper< Width, Index, Set, false > {
+ typedef Set type;
};
-*/
-/** This is the main interface class which will be responsible for
- * returning a reference to static mask data member which can be used
- * by the reference type within bitfield_vector.
+
+/** This class is responsible for determining all valid offsets of a perticular
+ * width and them storing them within a set.
*/
-// template <std::size_t Width>
+template <std::size_t Width>
+struct determine_vaild_offsets {
+ typedef typename valid_offset_helper<Width>::type type;
+};
}} // end booss::detail
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/mask_creator_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/mask_creator_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/mask_creator_test.cpp 2010-08-07 10:11:34 EDT (Sat, 07 Aug 2010)
@@ -6,6 +6,16 @@
#include <boost/integer/detail/bitfield_vector/mask_creator.hpp>
#include <boost/detail/lightweight_test.hpp>
+#include <boost/mpl/for_each.hpp>
+#include <iostream>
+#include <boost/mpl/has_key.hpp>
+
+struct print_set {
+ template<typename T>
+ void operator()(T x) {
+ std::cout<< x << " ";
+ }
+};
using namespace boost::detail;
int main() {
@@ -29,5 +39,31 @@
>::type test_3;
BOOST_TEST( test_3::value == 7 );
}
+
+ // testing mask info type.
+ {
+ using namespace boost;
+ typedef determine_vaild_offsets<3>::type t1;
+ BOOST_TEST(( mpl::has_key<t1,mpl::size_t<0> >::type::value ));
+ BOOST_TEST(( mpl::has_key<t1,mpl::size_t<1> >::type::value ));
+ BOOST_TEST(( mpl::has_key<t1,mpl::size_t<2> >::type::value ));
+ BOOST_TEST(( mpl::has_key<t1,mpl::size_t<3> >::type::value ));
+ BOOST_TEST(( mpl::has_key<t1,mpl::size_t<4> >::type::value ));
+ BOOST_TEST(( mpl::has_key<t1,mpl::size_t<5> >::type::value ));
+ BOOST_TEST(( mpl::has_key<t1,mpl::size_t<6> >::type::value ));
+ BOOST_TEST(( mpl::has_key<t1,mpl::size_t<7> >::type::value ));
+
+ typedef determine_vaild_offsets<4>::type t2;
+ BOOST_TEST(( mpl::has_key<t2,mpl::size_t<0> >::type::value ));
+ BOOST_TEST(( !mpl::has_key<t2,mpl::size_t<1> >::type::value ));
+ BOOST_TEST(( !mpl::has_key<t2,mpl::size_t<2> >::type::value ));
+ BOOST_TEST(( !mpl::has_key<t2,mpl::size_t<3> >::type::value ));
+ BOOST_TEST(( mpl::has_key<t2,mpl::size_t<4> >::type::value ));
+ BOOST_TEST(( !mpl::has_key<t2,mpl::size_t<5> >::type::value ));
+ BOOST_TEST(( !mpl::has_key<t2,mpl::size_t<6> >::type::value ));
+ BOOST_TEST(( !mpl::has_key<t2,mpl::size_t<7> >::type::value ));
+
+
+ }
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-08-07 10:11:34 EDT (Sat, 07 Aug 2010)
@@ -1,3 +1,34 @@
+
+--------------------------------------------------------------------------------
+ bitfield_vector
+--------------------------------------------------------------------------------
+list of header files
+1) bitfield_vector.hpp
+2) mask_creator.hpp
+3) bitfeild_vector_base.hpp
+4) bitfield_vector_member_impl.hpp
+
+
+
+list of test files.
+1) bitfield_vector_test.cpp ]
+2) bitfield_vector_base_test.cpp ]
+3) proxy_reference_test.cpp ]
+4) member_impl_test.cpp ]
+5) mask_creator_test.cpp ]
+
+
+--------------------------------------------------------------------------------
+ Tests to add
+--------------------------------------------------------------------------------
+1) Compile failure test for mask_size meta function.
+--------------------------------------------------------------------------------
+
+
+
+--------------------------------------------------------------------------------
+ bitfield_tuple
+--------------------------------------------------------------------------------
TODO From Email Responses
--------------------------------------------------------------------------------
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