forked from boostorg/integer
added Borland workaround
[SVN r22770]
This commit is contained in:
committed by
Glen Fernandes
parent
ff18de3b35
commit
70c7ae271c
@ -19,6 +19,7 @@
|
|||||||
#define BOOST_INTEGER_LOG2_HPP_GP_20030301
|
#define BOOST_INTEGER_LOG2_HPP_GP_20030301
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <climits> // actually used for Borland only
|
||||||
#include "boost/limits.hpp"
|
#include "boost/limits.hpp"
|
||||||
#include "boost/config.hpp"
|
#include "boost/config.hpp"
|
||||||
|
|
||||||
@ -67,6 +68,22 @@ namespace boost {
|
|||||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// this template is here just for Borland :(
|
||||||
|
// we could simply rely on numeric_limits but sometimes
|
||||||
|
// Borland tries to use numeric_limits<const T>, because
|
||||||
|
// of its usual const-related problems in argument deduction
|
||||||
|
// - gps
|
||||||
|
template <typename T>
|
||||||
|
struct width {
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
BOOST_STATIC_CONSTANT(int, value = sizeof(T) * CHAR_BIT);
|
||||||
|
#else
|
||||||
|
BOOST_STATIC_CONSTANT(int, value = (std::numeric_limits<T>::digits));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
|
|
||||||
|
|
||||||
@ -80,8 +97,8 @@ namespace boost {
|
|||||||
assert(x > 0);
|
assert(x > 0);
|
||||||
|
|
||||||
const int n = detail::max_pow2_less<
|
const int n = detail::max_pow2_less<
|
||||||
std::numeric_limits<T> :: digits, 4
|
detail::width<T> :: value, 4
|
||||||
> :: value;
|
> :: value;
|
||||||
|
|
||||||
return detail::integer_log2_impl(x, n);
|
return detail::integer_log2_impl(x, n);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user