From c56e4674f81197c3dadfbadd87a122bbd4addc41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Karlsson?=
Date: Wed, 19 Jun 2002 20:11:17 +0000
Subject: [PATCH] Update from Daryle
[SVN r14187]
---
doc/static_log2.html | 5 +--
include/boost/integer/static_log2.hpp | 52 ++++++++++++++++++++++++++-
2 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/doc/static_log2.html b/doc/static_log2.html
index d3daab2..6764572 100644
--- a/doc/static_log2.html
+++ b/doc/static_log2.html
@@ -107,11 +107,12 @@ at compile-time) available.
The author of the Boost binary logarithm class template is Daryle Walker.
+href="../../../people/daryle_walker.html">Daryle Walker. Giovanni Bajo
+added support for compilers without partial template specialization.
-Revised October 1, 2001
+Revised May 14, 2002
© Copyright Daryle Walker 2001. Permission to copy, use,
modify, sell and distribute this document is granted provided this
diff --git a/include/boost/integer/static_log2.hpp b/include/boost/integer/static_log2.hpp
index 436250e..fed9d6c 100644
--- a/include/boost/integer/static_log2.hpp
+++ b/include/boost/integer/static_log2.hpp
@@ -12,9 +12,13 @@
#include // self include
-#include // for BOOST_STATIC_CONSTANT
+#include // for BOOST_STATIC_CONSTANT, etc.
#include // for std::numeric_limits
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include // for boost::ct_if<>
+#endif
+
namespace boost
{
@@ -30,9 +34,22 @@ template < unsigned long Val, int Place = 0, int Index
= std::numeric_limits::digits >
struct static_log2_helper_t;
+#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
template < unsigned long Val, int Place >
struct static_log2_helper_t< Val, Place, 1 >;
+#else
+
+template < int Place >
+ struct static_log2_helper_final_step;
+
+template < unsigned long Val, int Place = 0, int Index
+ = std::numeric_limits::digits >
+ struct static_log2_helper_nopts_t;
+
+#endif
+
// Recursively build the logarithm by examining the upper bits
template < unsigned long Val, int Place, int Index >
struct static_log2_helper_t
@@ -50,7 +67,11 @@ private:
: Place );
BOOST_STATIC_CONSTANT( int, new_index = Index - half_place );
+#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef static_log2_helper_t next_step_type;
+#else
+ typedef static_log2_helper_nopts_t next_step_type;
+#endif
public:
BOOST_STATIC_CONSTANT( int, value = next_step_type::value );
@@ -58,6 +79,8 @@ public:
}; // boost::detail::static_log2_helper_t
// Non-recursive case
+#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
template < unsigned long Val, int Place >
struct static_log2_helper_t< Val, Place, 1 >
{
@@ -66,6 +89,33 @@ public:
}; // boost::detail::static_log2_helper_t
+#else
+
+template < int Place >
+struct static_log2_helper_final_step
+{
+public:
+ BOOST_STATIC_CONSTANT( int, value = Place );
+
+}; // boost::detail::static_log2_helper_final_step
+
+template < unsigned long Val, int Place, int Index >
+struct static_log2_helper_nopts_t
+{
+private:
+ typedef static_log2_helper_t recursive_step_type;
+ typedef static_log2_helper_final_step final_step_type;
+
+ typedef typename ct_if<( Index != 1 ), recursive_step_type,
+ final_step_type>::type next_step_type;
+
+public:
+ BOOST_STATIC_CONSTANT( int, value = next_step_type::value );
+
+}; // boost::detail::static_log2_helper_nopts_t
+
+#endif
+
} // namespace detail