2
0
mirror of https://github.com/boostorg/random.git synced 2026-01-19 04:22:17 +00:00

Use a proper constexpr for integer_log2.

[SVN r76032]
This commit is contained in:
Daniel James
2011-12-18 11:16:47 +00:00
parent 18b844a2ff
commit 16f5afdb15

View File

@@ -35,13 +35,26 @@ namespace detail {
template<int Shift>
struct integer_log2_impl
{
#if defined(BOOST_NO_CONSTEXPR)
template<class T>
BOOST_RANDOM_DETAIL_CONSTEXPR static int apply(T t, int accum,
int update = 0)
BOOST_RANDOM_DETAIL_CONSTEXPR static int apply(T t, int accum)
{
return update = ((t >> Shift) != 0) * Shift,
integer_log2_impl<Shift / 2>::apply(t >> update, accum + update);
int update = ((t >> Shift) != 0) * Shift;
return integer_log2_impl<Shift / 2>::apply(t >> update, accum + update);
}
#else
template<class T>
BOOST_RANDOM_DETAIL_CONSTEXPR static int apply2(T t, int accum, int update)
{
return integer_log2_impl<Shift / 2>::apply(t >> update, accum + update);
}
template<class T>
BOOST_RANDOM_DETAIL_CONSTEXPR static int apply(T t, int accum)
{
return apply2(t, accum, ((t >> Shift) != 0) * Shift);
}
#endif
};
template<>