Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64803 - in sandbox/SOC/2010/bit_masks: boost/integer boost/integer/detail/bitfield_vector lib/integer/test/bitfield_vector_testing
From: bbartmanboost_at_[hidden]
Date: 2010-08-14 14:04:34


Author: bbartman
Date: 2010-08-14 14:04:28 EDT (Sat, 14 Aug 2010)
New Revision: 64803
URL: http://svn.boost.org/trac/boost/changeset/64803

Log:
forgot to add less then comparability to the bitfield_vector_iterator_base class
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp | 74 +++++++++++++++++++++++++++++++++++++--
   sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/iterator_base.hpp | 30 +++++++++-------
   sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/iterator_base_test.cpp | 17 ++++++++
   3 files changed, 102 insertions(+), 19 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp 2010-08-14 14:04:28 EDT (Sat, 14 Aug 2010)
@@ -21,15 +21,79 @@
 /** Iterators. */
 //@{
 template<typename T, std::size_t Width>
-struct bf_vector_iterator
+class bf_vector_iterator
     :protected detail::bitfield_vector_iterator_base<T,Width>,
     public detail::safe_bool_impl::safe_bool<
         detail::bitfield_vector_iterator_base<T,Width>
>
-{ };
+{
+ typedef detail::bitfield_vector_iterator_base<T,Width> _base;
+ typedef detail::safe_bool_impl::safe_bool< _base > _safe_bool;
+ typedef bf_vector_iterator<T,Width> _self;
+public:
+
+ typedef typename _base::proxy_ref_type proxy_ref_type;
+ typedef typename _base::const_proxy_ref_type const_proxy_ref_type;
+ typedef typename _base::iterator_category iterator_category;
+ typedef typename _base::value_type value_type;
+ typedef typename _base::pointer pointer;
+ typedef typename _base::proxy_ref_type reference;
+ typedef typename _base::difference_type difference_type;
+
+
+ bf_vector_iterator()
+ :_base(),
+ _safe_bool()
+ { }
+
+ bf_vector_iterator(_self const& rhs)
+ :_base( static_cast<_base>(rhs) ),
+ _safe_bool()
+ { }
+
+ explicit bf_vector_iterator(reference const& x)
+ :_base( static_cast<_base>(x) ),
+ _safe_bool()
+ { }
+
+ reference operator*() const {
+ return this->deref();
+ }
+
+ _self& operator++() {
+ this->next();
+ return *this;
+ }
+
+ _self operator++(int) {
+ _self ret(*this);
+ this->next();
+ return ret;
+ }
+
+ _self& operator--() {
+ this->previous();
+ return *this;
+ }
+
+ _self operator--(int) {
+ _self ret(*this);
+ this->previous();
+ return ret;
+ }
+
+ bool operator==(_self const& rhs) const {
+ return this->is_equal(rhs);
+ }
+
+ bool operator!=(_self const& rhs) const {
+ return !this->is_equal(rhs);
+ }
+
+};
 
 template<typename T, std::size_t Width>
-struct const_bf_vector_iterator
+class const_bf_vector_iterator
     :protected detail::bitfield_vector_iterator_base<T,Width>,
     public detail::safe_bool_impl::safe_bool<
         detail::bitfield_vector_iterator_base<T,Width>
@@ -37,7 +101,7 @@
 { };
 
 template<typename T, std::size_t Width>
-struct bf_vector_reverse_iterator
+class bf_vector_reverse_iterator
     :protected detail::bitfield_vector_iterator_base<T,Width>,
     public detail::safe_bool_impl::safe_bool<
         detail::bitfield_vector_iterator_base<T,Width>
@@ -45,7 +109,7 @@
 { };
 
 template<typename T, std::size_t Width>
-struct const_bf_vector_reverse_iterator
+class const_bf_vector_reverse_iterator
     :protected detail::bitfield_vector_iterator_base<T,Width>,
     public detail::safe_bool_impl::safe_bool<
         detail::bitfield_vector_iterator_base<T,Width>

Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/iterator_base.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/iterator_base.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/iterator_base.hpp 2010-08-14 14:04:28 EDT (Sat, 14 Aug 2010)
@@ -53,18 +53,7 @@
     lhs.this_type_does_not_support_comparisons();
     return false;
 }
-
-// Here's how to use safe_bool:
-
-
-// class Testable_without_virtual :
-// public safe_bool <Testable_without_virtual> {
-// public:
-// bool boolean_test() const {
-// Perform Boolean logic here
-// }
-// };
-} // end safe bool impl.
+} // end safe bool impl
 
 /** bitfield_vector_iterator_base
  * This class is used to abstract all of the baisc operations which are
@@ -102,7 +91,7 @@
     typedef std::bidirectional_iterator_tag iterator_category;
     typedef T value_type;
     typedef T* pointer;
- typedef proxy_ref_type reference;
+ // typedef proxy_ref_type reference;
     typedef std::ptrdiff_t difference_type;
     BOOST_STATIC_CONSTANT( std::size_t, width = Width );
     //@}
@@ -194,12 +183,27 @@
     bool has_value() const {
         return _ptr;
     }
+
+ bool is_less(_self const& rhs) const {
+ if(_ptr <= rhs._ptr) {
+ if( _bit_offset < rhs._bit_offset) {
+ return true;
+ }else{
+ return false;
+ }
+ }else{
+ return true;
+ }
+ }
     //@)
     
+
+
     storage_ptr_t _ptr;
     std::size_t _bit_offset;
 };
 
+
 }} // end boost::detail
 
 

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/iterator_base_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/iterator_base_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/iterator_base_test.cpp 2010-08-14 14:04:28 EDT (Sat, 14 Aug 2010)
@@ -63,7 +63,7 @@
     // Testing constructor over a normal "non-const proxy_reference_type"
     {
         storage_t storage[20];
- test_type_1::reference r1(storage,0);
+ test_type_1::proxy_ref_type r1(storage,0);
         test_type_1 t1(r1);
         BOOST_TEST( t1._ptr == storage);
         BOOST_TEST( t1._bit_offset == 0);
@@ -261,6 +261,21 @@
         BOOST_TEST( t1._ptr == storage);
         BOOST_TEST( t1._bit_offset == 0);
     }
+
+ // testing is_less
+ {
+ storage_t storage[20];
+ std::memset(storage,0,20);
+ storage_ptr_t ptr = storage;
+ test_type_1 t1(storage, 0);
+ test_type_1 t2(t1);
+ BOOST_TEST( !t1.is_less(t1) );
+ BOOST_TEST( !t1.is_less(t2) );
+ t1.next();
+ BOOST_TEST( !t1.is_less(t2) );
+ BOOST_TEST( t2.is_less(t1) );
+
+ }
 /*
 
 typedef bitfield_vector_iterator_base<unsigned int, 3> test_type_1;


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