|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76032 - trunk/boost/random/detail
From: dnljms_at_[hidden]
Date: 2011-12-18 06:16:48
Author: danieljames
Date: 2011-12-18 06:16:47 EST (Sun, 18 Dec 2011)
New Revision: 76032
URL: http://svn.boost.org/trac/boost/changeset/76032
Log:
Use a proper constexpr for integer_log2.
Text files modified:
trunk/boost/random/detail/integer_log2.hpp | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
Modified: trunk/boost/random/detail/integer_log2.hpp
==============================================================================
--- trunk/boost/random/detail/integer_log2.hpp (original)
+++ trunk/boost/random/detail/integer_log2.hpp 2011-12-18 06:16:47 EST (Sun, 18 Dec 2011)
@@ -35,13 +35,26 @@
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)
+ {
+ 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 update = ((t >> Shift) != 0) * Shift,
- integer_log2_impl<Shift / 2>::apply(t >> update, accum + update);
+ return apply2(t, accum, ((t >> Shift) != 0) * Shift);
}
+#endif
};
template<>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk