Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62055 - in sandbox/SOC/2010/bit_masks: boost/integer/details lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-05-17 08:31:01


Author: bbartman
Date: 2010-05-17 08:31:00 EDT (Mon, 17 May 2010)
New Revision: 62055
URL: http://svn.boost.org/trac/boost/changeset/62055

Log:
completed testing on bit_map support functions these will be included in the bit_mask header file
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_function_support.hpp | 32 ++++++++++++++++----------------
   sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_operator_test.cpp | 31 ++++++++++++++++++++++++-------
   2 files changed, 40 insertions(+), 23 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_function_support.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_function_support.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_function_support.hpp 2010-05-17 08:31:00 EDT (Mon, 17 May 2010)
@@ -17,34 +17,34 @@
 // Overloads for bitwise and
 template <typename T, unsigned int Offset, unsigned int Width>
 inline T operator&(T t, bit_mask<T,Offset,Width> ) {
- return t & bit_mask<T,Offset,Width>::value;
+ return t & bit_mask<T, Offset, Width>::value;
 }
 
-template <typename Mask, typename T>
-inline T operator&(Mask m, T t) {
- return Mask::value & t;
+template <typename T, unsigned int Offset, unsigned int Width>
+inline T operator&(bit_mask<T,Offset,Width>, T t) {
+ return bit_mask<T,Offset,Width>::value & t;
 }
 
 // Overloads for bitwise or
-template <typename T, typename Mask >
-inline T operator|(T t, Mask m) {
- return t | Mask::value;
+template <typename T, unsigned int Offset, unsigned int Width>
+inline T operator|(T t, bit_mask<T,Offset,Width>) {
+ return t | bit_mask<T,Offset,Width>::value;
 }
 
-template <typename Mask, typename T>
-inline T operator|(Mask, T t) {
- return Mask::value | t;
+template <typename T, unsigned int Offset, unsigned int Width>
+inline T operator|(bit_mask<T,Offset,Width>, T t) {
+ return bit_mask<T,Offset,Width>::value | t;
 }
 
 // Overloads for bitwise xor
-template <typename T, typename Mask>
-inline T operator^(T t, Mask) {
- return t ^ Mask::value;
+template <typename T, unsigned int Offset, unsigned int Width>
+inline T operator^(T t, bit_mask<T,Offset,Width>) {
+ return t ^ bit_mask<T,Offset,Width>::value;
 }
 
-template <typename T, typename Mask>
-inline T operator^(Mask, T t) {
- return Mask::value ^ t;
+template <typename T, unsigned int Offset, unsigned int Width>
+inline T operator^(bit_mask<T,Offset,Width>, T t) {
+ return bit_mask<T,Offset,Width>::value ^ t;
 }
 
 } // end of boost namespace.

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_operator_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_operator_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_operator_test.cpp 2010-05-17 08:31:00 EDT (Mon, 17 May 2010)
@@ -10,15 +10,33 @@
 #include <boost/integer/bit_mask.hpp>
 #include <boost/integer/details/bit_mask_function_support.hpp>
 
-void ignore_unused(...) { }
 
 // Testing for operator overloads.
 using namespace boost;
 
 template <typename T>
 void test_function() {
- T bitwise_and = T(0) & bit_mask<T, 1>()();
- ignore_unused( bitwise_and );
+
+ // operator &(T, bit_mask)
+ T bit_result = T(0) & bit_mask<T, 1>();
+
+ // operator &(bit_mask, T)
+ bit_result = bit_mask<T, 1>() & T(0);
+
+ // operator |(T, bit_mask)
+ bit_result = T(0) | bit_mask<T,1>();
+
+ // operator |(bit_mask, T)
+ bit_result = T(0) | bit_mask<T,1>();
+
+ // operator |(T, bit_mask)
+ bit_result = bit_mask<T,1>() | T(0);
+
+ // operator ^(bit_mask, T)
+ bit_result = T(0) ^ bit_mask<T,1>();
+
+ // operator ^(T, bit_mask)
+ bit_result = bit_mask<T,1>() ^ T(0);
 }
 
 
@@ -32,9 +50,8 @@
 
 int main() {
     mpl::for_each< test_types >( type_tester() );
- // mpl::for_each< test_types_2 >( type_tester() );
- // mpl::for_each< test_types_3 >( type_tester() );
- char bitwise_and = char(0) & bit_mask<char, 1>();
- ignore_unused( bitwise_and );
+ mpl::for_each< test_types_2 >( type_tester() );
+ mpl::for_each< test_types_3 >( type_tester() );
+
     return 0;
 }


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