$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r63968 - sandbox/SOC/2010/bits_and_ints/boost/integer
From: muriloufg_at_[hidden]
Date: 2010-07-13 12:50:20
Author: murilov
Date: 2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
New Revision: 63968
URL: http://svn.boost.org/trac/boost/changeset/63968
Log:
Removed enable_if<>'s from static metafunctions and replaced with BOOST_STATIC_ASSERT()
Text files modified: 
   sandbox/SOC/2010/bits_and_ints/boost/integer/same_sign.hpp                   |     7 ++++---                                 
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_bit_reversal.hpp         |    17 +++++++++++------                       
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_clear_least_bit_set.hpp  |    20 +++++++++++++-------                    
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_count_trailing_zeros.hpp |     9 +++++----                               
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_isign.hpp                |    24 ++++++++++--------------                
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_pop_count.hpp            |    10 ++++++----                              
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_safe_avg.hpp             |    24 ++++++++++--------------                
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_same_sign.hpp            |    15 ++++++++++-----                         
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign.hpp                 |    25 +++++++++++--------------               
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp          |    18 ++++++++++++------                      
   10 files changed, 92 insertions(+), 77 deletions(-)
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/same_sign.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/same_sign.hpp	(original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/same_sign.hpp	2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
@@ -7,8 +7,8 @@
 
 //  See http://www.boost.org for updates, documentation, and revision history. 
 
+#include <boost/static_assert.hpp>
 #include <boost/type_traits/is_integral.hpp>
-#include <boost/utility/enable_if.hpp>
 
 namespace boost {
 
@@ -22,9 +22,10 @@
  */
         
 template <typename T>
-inline typename enable_if<is_integral<T>, bool>::type
-same_sign(T first, T second)
+bool same_sign(T first, T second)
 {
+	BOOST_STATIC_ASSERT((is_integral<T>::value));
+	
         T temp = first ^ second;
         temp = temp >> ((sizeof(T) * 8) - 1);
         temp = temp & T(1);
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_bit_reversal.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_bit_reversal.hpp	(original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_bit_reversal.hpp	2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
@@ -10,10 +10,11 @@
 #ifndef BOOST_STATIC_BIT_REVERSAL_INCLUDED
 #define BOOST_STATIC_BIT_REVERSAL_INCLUDED
 
-#include <boost/utility/enable_if.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/mpl/integral_c.hpp>
 #include <boost/type_traits/is_integral.hpp>
+#include <boost/integer/is_integral_constant.hpp>
 #include <boost/integer/detail/static_bit_reversal.hpp>
-#include <boost/mpl/integral_c.hpp>
 
 /* 
  *	Reverses the bits in data in compile-time
@@ -37,15 +38,19 @@
         typename IC::value_type,
         IC::value, sizeof(typename IC::value_type) * 8
 >
-{}; // struct bit_reversal
+{
+	BOOST_STATIC_ASSERT((is_integral_constant<IC>::value));
+}; // struct bit_reversal
 
 } // namespace mpl
         
 //	If T is an integral type, static_bit_reversal<T, data>::value will
 //		be `data' with the bits reversed
-template <typename T, T data, class Enable = typename enable_if< is_integral<T> >::type>
-struct static_bit_reversal : mpl::bit_reversal< mpl::integral_c<T, data> >
-{}; // struct static_bit_reversal<>
+template <typename T, T Value>
+struct static_bit_reversal : mpl::bit_reversal< mpl::integral_c<T, Value> >
+{
+	BOOST_STATIC_ASSERT((is_integral<T>::value));
+}; // struct static_bit_reversal<>
 
 } // namespace boost
 
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_clear_least_bit_set.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_clear_least_bit_set.hpp	(original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_clear_least_bit_set.hpp	2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
@@ -10,8 +10,9 @@
 #ifndef BOOST_STATIC_CLEAR_LEAST_BIT_SET
 #define BOOST_STATIC_CLEAR_LEAST_BIT_SET
 
+#include <boost/static_assert.hpp>
 #include <boost/mpl/integral_c.hpp>
-#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/is_integral.hpp>
 #include <boost/integer/is_integral_constant.hpp>
 
 /*
@@ -36,10 +37,12 @@
 /*
  *	Requires IC to be a mpl::integral_c<> type
  */
-template <typename IC, 
-	class Enable = typename enable_if< is_integral_constant<IC> >::type>
-struct clear_least_bit_set : integral_c<typename IC::value_type, (IC::value & (IC::value - 1))>
-{};
+template <typename IC>
+struct clear_least_bit_set : 
+	integral_c<typename IC::value_type, (IC::value & (IC::value - 1))>
+{
+	BOOST_STATIC_ASSERT((is_integral_constant<IC>::value));
+};
         
 }
 
@@ -47,8 +50,11 @@
  *	Requires T to be an integral type
  */
 template <typename T, T Value>
-struct static_clear_least_bit_set : mpl::clear_least_bit_set< mpl::integral_c<T, Value> >
-{};
+struct static_clear_least_bit_set : 
+	mpl::clear_least_bit_set< mpl::integral_c<T, Value> >
+{
+	BOOST_STATIC_ASSERT((is_integral<T>::value));
+};
 
 }
 
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_count_trailing_zeros.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_count_trailing_zeros.hpp	(original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_count_trailing_zeros.hpp	2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
@@ -11,8 +11,8 @@
 #define BOOST_STATIC_COUNT_TRAILING_ZEROS_INCLUDED
 
 #include <boost/cstdint.hpp>
+#include <boost/static_assert.hpp>
 #include <boost/mpl/integral_c.hpp>
-#include <boost/utility/enable_if.hpp>
 #include <boost/integer/static_pop_count.hpp>
 #include <boost/integer/is_integral_constant.hpp>
 
@@ -39,10 +39,11 @@
 /*
  *	MPL integral_c<> compatible version
  */
-template <typename IC, 
-	class Enable = typename enable_if< is_integral_constant<IC> >::type>
+template <typename IC>
 struct count_trailing_zeros : pop_count< integral_c<uintmax_t, ~IC::value & (IC::value - 1)> > 
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral_constant<IC>::value));
+};
 
 }
 
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_isign.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_isign.hpp	(original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_isign.hpp	2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
@@ -10,9 +10,8 @@
 #ifndef BOOST_STATIC_ISIGN_INCLUDED
 #define BOOST_STATIC_ISIGN_INCLUDED
 
-#include <boost/mpl/and.hpp>
+#include <boost/static_assert.hpp>
 #include <boost/mpl/integral_c.hpp>
-#include <boost/utility/enable_if.hpp>
 #include <boost/type_traits/is_integral.hpp>
 #include <boost/integer/is_integral_constant.hpp>
 
@@ -28,32 +27,29 @@
 /*
  *	This metafunction requires IC1 and IC2 to be mpl::integral_c<> types
  */
-template <typename IC1, typename IC2, 
-	class Enable = typename enable_if< 
-		and_<
-			is_integral_constant<IC1>,
-			is_integral_constant<IC2>
-		>
-	>::type
->
+template <typename IC1, typename IC2>
 struct isign : integral_c<typename IC1::value_type, 
         ((IC1::value ^ ((IC1::value ^ IC2::value) >> (sizeof(typename IC1::value_type) * 8 - 1)))
                 - ((IC1::value ^ IC2::value) >> (sizeof(typename IC1::value_type) * 8 - 1)))
 >
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral_constant<IC1>::value));
+	BOOST_STATIC_ASSERT((is_integral_constant<IC2>::value));
+};
 
 } // mpl
 
 /*
  *	This metafunction requires T to be an integral type
  */
-template <typename T, T Value1, T Value2, 
-	class Enable = typename enable_if< is_integral<T> >::type>
+template <typename T, T Value1, T Value2>
 struct static_isign : mpl::isign< 
         mpl::integral_c<T, Value1>, 
         mpl::integral_c<T, Value2>
 >
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral<T>::value));
+};
         
 } // boost
 
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_pop_count.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_pop_count.hpp	(original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_pop_count.hpp	2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
@@ -10,9 +10,9 @@
 #ifndef BOOST_STATIC_POP_COUNT
 #define BOOST_STATIC_POP_COUNT
 
-#include <boost/mpl/integral_c.hpp>
 #include <boost/config/suffix.hpp>
-#include <boost/utility/enable_if.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/mpl/integral_c.hpp>
 #include <boost/integer/is_integral_constant.hpp>
 
 namespace boost {
@@ -59,9 +59,11 @@
         
 namespace mpl {
         
-template <typename IC, class Enable = typename enable_if< is_integral_constant<IC> >::type>
+template <typename IC>
 struct pop_count : integral_c<int, static_pop_count<IC::value>::value>
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral_constant<IC>::value));
+};
         
 }
         
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_safe_avg.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_safe_avg.hpp	(original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_safe_avg.hpp	2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
@@ -10,9 +10,8 @@
 #ifndef BOOST_STATIC_SAFE_AVG_INCLUDED
 #define BOOST_STATIC_SAFE_AVG_INCLUDED
 
-#include <boost/mpl/and.hpp>
+#include <boost/static_assert.hpp>
 #include <boost/mpl/integral_c.hpp>
-#include <boost/utility/enable_if.hpp>
 #include <boost/type_traits/is_integral.hpp>
 #include <boost/integer/is_integral_constant.hpp>
 
@@ -29,29 +28,26 @@
         
 namespace mpl {
 
-template <typename IC1, typename IC2, 
-	class Enable = typename enable_if< 
-		and_< 
-			is_integral_constant<IC1>, 
-			is_integral_constant<IC2> 
-		> 
-	>::type
->
+template <typename IC1, typename IC2>
 struct safe_avg : integral_c<
         typename IC1::value_type, 
         ((IC1::value & IC2::value) + ((IC1::value ^ IC2::value) >> 1))
 >
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral_constant<IC1>::value));
+	BOOST_STATIC_ASSERT((is_integral_constant<IC2>::value));
+};
 
 }
 
-template <typename T, T Value1, T Value2, 
-	class Enable = typename enable_if< is_integral<T> >::type>
+template <typename T, T Value1, T Value2>
 struct static_safe_avg : mpl::safe_avg< 
         mpl::integral_c<T, Value1>, 
         mpl::integral_c<T, Value2> 
 >
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral<T>::value));
+};
 
 } // boost
 
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_same_sign.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_same_sign.hpp	(original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_same_sign.hpp	2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
@@ -10,10 +10,10 @@
 #ifndef BOOST_STATIC_SAME_SIGN_INCLUDED
 #define BOOST_STATIC_SAME_SIGN_INCLUDED
 
-#include <boost/mpl/integral_c.hpp>
 #include <boost/mpl/bool.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/static_assert.hpp>
 #include <boost/type_traits/is_integral.hpp>
-#include <boost/utility/enable_if.hpp>
 #include <boost/integer/static_sign.hpp>
 
 namespace boost {
@@ -39,7 +39,10 @@
 struct same_sign : bool_<
         sign<IC1>::value == sign<IC2>::value
 >
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral_constant<IC1>::value));
+	BOOST_STATIC_ASSERT((is_integral_constant<IC2>::value));
+};
         
 }
 
@@ -48,9 +51,11 @@
  *		- false: if the signs of FIRST and SECOND are different
  *		- true: if the signs are equal
  */
-template <typename T, T first, T second, class Enable = typename enable_if<is_integral<T> >::type>
+template <typename T, T first, T second>
 struct static_same_sign : mpl::same_sign< mpl::integral_c<T, first>, mpl::integral_c<T, second> >
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral<T>::value));
+};
 
 }
 
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign.hpp	(original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign.hpp	2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
@@ -11,12 +11,13 @@
 #ifndef BOOST_STATIC_SIGN_INCLUDED
 #define BOOST_STATIC_SIGN_INCLUDED
 
-#include <boost/utility/enable_if.hpp>
-#include <boost/integer/is_integral_constant.hpp>
 #include <boost/mpl/if.hpp>
+#include <boost/static_assert.hpp>
 #include <boost/mpl/integral_c.hpp>
+#include <boost/type_traits/is_integral.hpp>
 #include <boost/type_traits/is_unsigned.hpp>
 #include <boost/type_traits/make_signed.hpp>
+#include <boost/integer/is_integral_constant.hpp>
 
 namespace boost {
 
@@ -26,11 +27,7 @@
         
 namespace mpl {
 
-template <typename IC
-	, class Enable = typename enable_if<
-		is_integral_constant<IC> 
-	>::type
->
+template <typename IC>
 struct sign : 
         integral_c<
                 typename make_signed<
@@ -38,17 +35,17 @@
 		>::type,
                 (IC::value == 0 ? 0 : (IC::value > 0 ? 1 : -1))
 	>
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral_constant<IC>::value));
+};
 
 }
 
-template <typename T, T Value
-    , class Enable = typename enable_if<
-        is_integral<T> 
-    >::type
->
+template <typename T, T Value>
 struct static_sign : mpl::sign<mpl::integral_c<T, Value> >
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral<T>::value));
+};
 
 } // boost
 
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp	(original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp	2010-07-13 12:50:18 EDT (Tue, 13 Jul 2010)
@@ -10,9 +10,10 @@
 #ifndef BOOST_STATIC_SIGN_EXTEND_INCLUDED
 #define BOOST_STATIC_SIGN_EXTEND_INCLUDED
 
-#include <boost/utility/enable_if.hpp>
-#include <boost/type_traits/is_integral.hpp>
+#include <boost/static_assert.hpp>
 #include <boost/mpl/integral_c.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/integer/is_integral_constant.hpp>
 
 /* 
  *	Extend `data' represented in `Bits' bits to sizeof(T) * 8
@@ -49,15 +50,20 @@
         ^ (typename IC::value_type(1) << (Bits - 1))) 
         - (typename IC::value_type(1) << (Bits - 1)))
 >
-{};
+{
+	BOOST_STATIC_ASSERT((is_integral_constant<IC>::value));
+	BOOST_STATIC_ASSERT((Bits > 0 && Bits < (sizeof(typename IC::value_type) * 8)));
+};
 
 }
 
 // Compile-time version of sign_extend
-template<typename T, T data, std::size_t Bits, 
-	class Enable = typename enable_if< is_integral<T> >::type>
+template<typename T, T data, std::size_t Bits>
 struct static_sign_extend : mpl::sign_extend<mpl::integral_c<T, data>, Bits>
-{}; // boost::static_sign_extend
+{
+	BOOST_STATIC_ASSERT((is_integral<T>::value));
+	BOOST_STATIC_ASSERT((Bits > 0 && Bits < (sizeof(T) * 8)));
+}; // boost::static_sign_extend
 
 } // boost