Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63823 - in sandbox/SOC/2010/bit_masks: boost/integer lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-07-10 15:18:51


Author: bbartman
Date: 2010-07-10 15:18:50 EDT (Sat, 10 Jul 2010)
New Revision: 63823
URL: http://svn.boost.org/trac/boost/changeset/63823

Log:
updated code and applied patch for msvc 9. still working on getting bitfield_tuple working on msvc
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/high_bits_mask.hpp | 26 ++++++++++++++++++++++++--
   sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp | 9 +++++++--
   2 files changed, 31 insertions(+), 4 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/high_bits_mask.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/high_bits_mask.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/high_bits_mask.hpp 2010-07-10 15:18:50 EDT (Sat, 10 Jul 2010)
@@ -8,14 +8,30 @@
 #ifndef BOOST_HIGH_BITS_MASK_HPP
 #define BOOST_HIGH_BITS_MASK_HPP
 
-// #include <boost/type_traits.hpp>
+#include <boost/config.hpp>
 #include <boost/integer/details/high_low_impl.hpp>
 #include <boost/integer/integral_mask.hpp>
 #include <boost/type_traits/integral_constant.hpp>
 #include <boost/type_traits/make_unsigned.hpp>
+#include <boost/mpl/bitwise.hpp>
+#include <boost/mpl/size_t.hpp>
 
 namespace boost {
 
+#ifdef BOOST_MSVC
+
+
+namespace detail {
+ template<typename T, unsigned int Width>
+ struct evaluate_for_msvc_08 {
+ typedef typename make_unsigned<T>::type unsigned_type;
+ BOOST_STATIC_CONSTANT(T, val = (~(mpl::shift_right< mpl::size_t< ~(T(0)) >, mpl::size_t<Width> >::type::value) ));
+ typedef integral_constant<T, val> type;
+ };
+}
+// integral_mask<T, ~ mpl::size_t<(mpl::shift_left< mpl::size_t< ~(T(0)) >, mpl::size_t<Width> >::type::value )>::value >
+
+#endif
 
 /** Creates a mask of the supplied width in side type T, from the lower portion
  * of the integer starting from the left most bit moving towards the right.
@@ -23,7 +39,13 @@
 template <typename T, unsigned int Width>
 struct high_bits_mask
     :details::high_bits_preconditions<T,Width>,
- integral_mask<T, ~( ~ (typename make_unsigned<T>::type(0)) >> Width) >
+
+#ifdef BOOST_MSVC
+ detail::evaluate_for_msvc_08<T,Width>::type
+#else
+ // GNU likes this version.
+ integral_mask<T, (~( ~ (typename make_unsigned<T>::type(0)) >> Width)) >
+#endif
 {
     typedef high_bits_mask<T,Width> type;
 

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp 2010-07-10 15:18:50 EDT (Sat, 10 Jul 2010)
@@ -25,9 +25,14 @@
 
     cout << "Starting test. Test Type = " << typeid(T).name() << endl;
     // making sure that the value type is transfered correctly.
- BOOST_TEST((is_same< typename high_bits_mask<T, 3>::value_type, T >::value));
+ BOOST_TEST((is_same< typename high_bits_mask<T, 3>::value_type, T >::value));
+
+ if(!is_same<char,T>::value ) {
+ cout << "Mask Value: " << hex << boost::high_bits_mask<T,1>::value << endl;
+ cout << "Test Value: " << hex << static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 1)) << endl;
+ }
     BOOST_TEST(( boost::high_bits_mask<T,1>::value ==
- static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 1)) ));
+ static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 1)) ));
     BOOST_TEST(( boost::high_bits_mask<T,2>::value ==
         static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 2)) ));
     BOOST_TEST(( boost::high_bits_mask<T,3>::value ==


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