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.

Credits

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