2
0
mirror of https://github.com/boostorg/random.git synced 2026-02-26 17:02:15 +00:00

Random: Merge constexpr integer_log2_impl.

[SVN r73268]
This commit is contained in:
Daniel James
2011-07-21 07:49:59 +00:00
parent fd4efbb298
commit 2575617250

View File

@@ -22,9 +22,7 @@ namespace boost {
namespace random {
namespace detail {
// Daniel James: Disabled use of constexpr because integer_log2_impl is not a
// valid constexpr.
#if 0 && !defined(BOOST_NO_CONSTEXPR)
#if !defined(BOOST_NO_CONSTEXPR)
#define BOOST_RANDOM_DETAIL_CONSTEXPR constexpr
#elif defined(BOOST_MSVC)
#define BOOST_RANDOM_DETAIL_CONSTEXPR __forceinline
@@ -38,10 +36,11 @@ template<int Shift>
struct integer_log2_impl
{
template<class T>
BOOST_RANDOM_DETAIL_CONSTEXPR static int apply(T t, int accum)
BOOST_RANDOM_DETAIL_CONSTEXPR static int apply(T t, int accum,
int update = 0)
{
int update = ((t >> Shift) != 0) * Shift;
return integer_log2_impl<Shift / 2>::apply(t >> update, accum + update);
return update = ((t >> Shift) != 0) * Shift,
integer_log2_impl<Shift / 2>::apply(t >> update, accum + update);
}
};