Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63046 - in sandbox/SOC/2010/bit_masks: boost/integer/details boost/integer/details/bft/ext lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-06-17 13:08:10


Author: bbartman
Date: 2010-06-17 13:08:08 EDT (Thu, 17 Jun 2010)
New Revision: 63046
URL: http://svn.boost.org/trac/boost/changeset/63046

Log:
complete implementation and unit testing for bitfield_tuple's fusion iterator
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/details/bft/ext/bitfield_iterator.hpp | 48 +++++++++++++++++++++++++++-----
   sandbox/SOC/2010/bit_masks/boost/integer/details/fusion_ext_includes.hpp | 5 +++
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fusion_integration_testing.cpp | 59 +++++++++++++++++++++++++++++++++++++++
   3 files changed, 103 insertions(+), 9 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/bft/ext/bitfield_iterator.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/bft/ext/bitfield_iterator.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/bft/ext/bitfield_iterator.hpp 2010-06-17 13:08:08 EDT (Thu, 17 Jun 2010)
@@ -99,8 +99,20 @@
     /** Fusion Extension: prior */
     template<typename Iter>
     struct prior {
- typedef typename details::IMPLEMENT_ME type;
- static type call(Iter& iter);
+ typedef bitfield_tuple_iterator<
+ typename Iter::bitfield_tuple_type,
+ Iter::index::value - 1
+ > type;
+
+ // const prior operation
+ static type call(Iter const& iter) {
+ return type( iter._data );
+ }
+
+ // non-const prior operation.
+ static type call(Iter& iter) {
+ return type( iter._data );
+ }
     };
 
     /** Fusion Extension: distance */
@@ -108,27 +120,47 @@
     struct distance {
         // The distance between iterators of type It1 and It2 as
         // an MPL Integral Constant
- typedef typename details::IMPLEMENT_ME type;
- static type call(Iter1& it1,Iter2& it2);
+ typedef typename mpl::minus<
+ typename Iter1::index,
+ typename Iter2::index
+ > type;
+
+ // const distance
+ static type call(Iter1 const&, Iter2 const&) {
+ return type();
+ }
         };
 
     /** Fusion Extension: key_of */
     template <typename Iter>
     struct key_of {
- typedef typename details::IMPLEMENT_ME type;
+ typedef typename mpl::at<
+ typename Iter::bitfield_tuple_type::members,
+ typename Iter::index
+ >::type::name_type type;
     };
 
     /** Fusion Extension: value_of_data */
     template <typename Iter>
     struct value_of_data {
- typedef typename details::IMPLEMENT_ME type;
+ typedef typename value_of<Iter>::type type;
     };
 
     /** Fusion Extension: deref_data */
     template <typename Iter>
     struct deref_data {
- typedef typename details::IMPLEMENT_ME type;
- static type call(Iter& it);
+ // the type returned by dereferencing the iterator.
+ typedef typename value_of<Iter>::type type;
+
+ // const dereference operation.
+ static type call(Iter const& iter) {
+ return type( iter._data.data() );
+ }
+
+ // non-const dereference operation.
+ static type call(Iter& iter) {
+ return type( iter._data.data() );
+ }
     };
 
 };

Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/fusion_ext_includes.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/fusion_ext_includes.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/fusion_ext_includes.hpp 2010-06-17 13:08:08 EDT (Thu, 17 Jun 2010)
@@ -8,4 +8,9 @@
 #include <boost/fusion/iterator/value_of.hpp>
 #include <boost/fusion/iterator/deref.hpp>
 #include <boost/fusion/iterator/next.hpp>
+#include <boost/fusion/iterator/prior.hpp>
+#include <boost/fusion/iterator/distance.hpp>
+#include <boost/fusion/iterator/key_of.hpp>
+#include <boost/fusion/iterator/value_of_data.hpp>
+#include <boost/fusion/iterator/deref_data.hpp>
 #endif

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fusion_integration_testing.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fusion_integration_testing.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fusion_integration_testing.cpp 2010-06-17 13:08:08 EDT (Thu, 17 Jun 2010)
@@ -58,10 +58,67 @@
         test_tuple temp;
         temp.get<green>() = 3;
         Iter it(temp);
- BOOST_ASSERT(( fusion::deref(fusion::next(it)) == 3 ));
+ BOOST_ASSERT(( fusion::deref(fusion::next(it)) == 3 ));
     }
 
+ // prior
+ {
+ typedef bitfield_tuple_iterator<test_tuple,0> Iter;
+ test_tuple temp;
+ temp.get<red>() = 2;
+ temp.get<green>() = 3;
+ Iter it(temp);
+ BOOST_ASSERT(( fusion::deref(fusion::prior(fusion::next(it))) == 2 ));
+ }
+
+ // distance tesing
+ {
+ typedef bitfield_tuple_iterator<test_tuple,0> Iter1;
+ typedef bitfield_tuple_iterator<test_tuple,1> Iter2;
+ test_tuple temp;
+ temp.get<red>() = 2;
+ temp.get<green>() = 3;
+ Iter1 it1(temp);
+ Iter2 it2(temp);
+ BOOST_ASSERT(( fusion::distance(it2,it1) == 1 ));
+ }
+
+ // key_of testing
+ {
+ typedef bitfield_tuple_iterator<test_tuple,1> Iter;
+ test_tuple temp;
+ BOOST_MPL_ASSERT((
+ is_same<
+ fusion::result_of::key_of<
+ Iter
+ >::type,
+ green
+ >
+ ));
+ }
+
+ // value_of_data testing
+ {
 
+ typedef bitfield_tuple_iterator<test_tuple,1> Iter;
+ typedef fusion::result_of::value_of_data<
+ Iter
+ >::type value_of_data_t;
+
+ test_tuple temp;
+ BOOST_MPL_ASSERT((is_same<value_of_data_t::return_type,unsigned char>));
+ }
+
+ // deref_data testing
+ {
+ typedef bitfield_tuple_iterator<test_tuple,1> Iter;
+ typedef fusion::result_of::deref_data<
+ Iter
+ >::type deref_data_t;
+
+ // test_tuple temp;
+ // BOOST_MPL_ASSERT((is_same<deref_data_t::return_type,unsigned char>));
+ }
     /*
     bmg_t bmg;
 


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