$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r82883 - trunk/boost/gil
From: chhenning_at_[hidden]
Date: 2013-02-14 11:09:44
Author: chhenning
Date: 2013-02-14 11:09:43 EST (Thu, 14 Feb 2013)
New Revision: 82883
URL: http://svn.boost.org/trac/boost/changeset/82883
Log:
packed_channel_value is now using low_bits_mask_t to reduce code.
Text files modified: 
   trunk/boost/gil/channel.hpp |    16 +++++++---------                        
   1 files changed, 7 insertions(+), 9 deletions(-)
Modified: trunk/boost/gil/channel.hpp
==============================================================================
--- trunk/boost/gil/channel.hpp	(original)
+++ trunk/boost/gil/channel.hpp	2013-02-14 11:09:43 EST (Thu, 14 Feb 2013)
@@ -27,6 +27,7 @@
 #include <limits>
 #include <cassert>
 #include <boost/cstdint.hpp>
+#include <boost/integer/integer_mask.hpp>
 #include <boost/type_traits/remove_cv.hpp>
 #include "gil_config.hpp"
 #include "utilities.hpp"
@@ -244,9 +245,6 @@
 template <int NumBits>
 class packed_channel_value {
 
-    typedef  typename detail::num_value_fn< NumBits >::type num_value_t;
-    static const num_value_t num_values = static_cast< num_value_t >( 1 ) << NumBits ;
-   
 public:
     typedef typename detail::min_fast_uint<NumBits>::type integer_t;
 
@@ -257,17 +255,17 @@
     typedef value_type*            pointer;
     typedef const value_type*      const_pointer;
 
-    static value_type min_value() { return value_type(0); }
-    static value_type max_value() { return value_type(num_values-1); }
+    static value_type min_value() { return 0; }
+    static value_type max_value() { return low_bits_mask_t< NumBits >::sig_bits; }
+
     BOOST_STATIC_CONSTANT(bool, is_mutable=true);
 
     packed_channel_value() {}
-    packed_channel_value(integer_t v) { _value = static_cast< integer_t >( v % num_values ); }
-    packed_channel_value(const packed_channel_value& v) : _value(v._value) {}
-    template <typename Scalar> packed_channel_value(Scalar v) { _value = static_cast< integer_t >( v ) % num_values; }
 
-    static unsigned int num_bits() { return NumBits; }
+    packed_channel_value(integer_t v) { _value = static_cast< integer_t >( v & low_bits_mask_t<NumBits>::sig_bits_fast ); }
+    template <typename Scalar> packed_channel_value(Scalar v) { _value = packed_channel_value( static_cast< integer_t >( v ) ); }
 
+    static unsigned int num_bits() { return NumBits; }
 
     operator integer_t() const { return _value; }
 private: