|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61950 - in sandbox/SOC/2010/bit_masks: boost/integer boost/integer/details lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-05-13 11:03:30
Author: bbartman
Date: 2010-05-13 11:03:29 EDT (Thu, 13 May 2010)
New Revision: 61950
URL: http://svn.boost.org/trac/boost/changeset/61950
Log:
working on creating high low meta functions
Added:
sandbox/SOC/2010/bit_masks/boost/integer/details/high_low_impl.hpp (contents, props changed)
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/bit_width.hpp | 27 +++++++++++++++++++++++++++
sandbox/SOC/2010/bit_masks/boost/integer/high_low_bits.hpp | 9 ++++++++-
sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 | 3 ++-
sandbox/SOC/2010/bit_masks/lib/integer/test/bit_width_test.cpp | 18 ++++++++++++++++++
4 files changed, 55 insertions(+), 2 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/bit_width.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bit_width.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bit_width.hpp 2010-05-13 11:03:29 EDT (Thu, 13 May 2010)
@@ -0,0 +1,27 @@
+// (C) Copyright Brian Bartman 2010.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#ifndef BOOST_INTEGRAL_BIT_WIDTH_HPP
+#define BOOST_INTEGRAL_BIT_WIDTH_HPP
+#include <boost/type_traits.hpp>
+#include <boost/integer/details/high_low_impl.hpp>
+
+
+namespace boost {
+
+/** bit_width is a meta function which returns the size of bits in size
+ * type T.
+ */
+template <typename T>
+struct bit_width
+ :integral_constant< unsigned int, (sizeof(T) * 8)>
+{
+ typedef bit_width<T> type;
+};
+
+} // namespace boost
+
+#endif
Added: sandbox/SOC/2010/bit_masks/boost/integer/details/high_low_impl.hpp
==============================================================================
Modified: sandbox/SOC/2010/bit_masks/boost/integer/high_low_bits.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/high_low_bits.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/high_low_bits.hpp 2010-05-13 11:03:29 EDT (Thu, 13 May 2010)
@@ -13,13 +13,20 @@
namespace boost {
-template <typename T, T Width>
+
+/** Creates a mask of the supplied width in side type T, from the lower portion
+ * of the integer starting from the right most bit moving towards the left.
+ */
+template <typename T, unsigned int Width>
struct low_bits
:integral_constant<T, ~(~T(0) << Width) >
{
+
typedef low_bits<T,Width> type;
};
+
+
} // namespace boost
#endif
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 2010-05-13 11:03:29 EDT (Thu, 13 May 2010)
@@ -11,7 +11,8 @@
[ run mask_check.cpp ]
[ run high_bit_mask_test.cpp ]
[ run low_bit_mask_test.cpp ]
- [ compile bit_mask_test.cpp ]
+ # [ compile bit_mask_test.cpp ]
+ [ run bit_width_test.cpp ]
;
# run low_bit_mask_test.cpp
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bit_width_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bit_width_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bit_width_test.cpp 2010-05-13 11:03:29 EDT (Thu, 13 May 2010)
@@ -0,0 +1,18 @@
+#include <boost/assert.hpp>
+#include <boost/type_traits.hpp>
+#include <boost/integer/bit_width.hpp>
+
+// tesitng for bit width.
+using namespace boost;
+
+
+
+int main() {
+ {
+ typedef bit_width<char> bw;
+ BOOST_ASSERT(( bw::value == 8 ));
+ BOOST_ASSERT(( is_same<bw::value_type, unsigned int>::value ));
+ BOOST_ASSERT(( is_same<bw::type, bw>::value ));
+ }
+ 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