From b9fb804fa498dc27ccbc36cd7f6cfd8c331fa139 Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Sun, 22 Dec 2002 21:27:42 +0000 Subject: [PATCH] fix various platform-specific compile problems [SVN r16681] --- include/boost/random/linear_congruential.hpp | 8 ++++--- .../boost/random/linear_feedback_shift.hpp | 17 +++++++++---- include/boost/random/subtract_with_carry.hpp | 10 ++++---- include/boost/random/uniform_int.hpp | 13 +++++----- include/boost/random/uniform_smallint.hpp | 24 ++++++++++--------- include/boost/random/xor_combine.hpp | 15 ++++++------ 6 files changed, 51 insertions(+), 36 deletions(-) diff --git a/include/boost/random/linear_congruential.hpp b/include/boost/random/linear_congruential.hpp index 7169021..5c55a39 100644 --- a/include/boost/random/linear_congruential.hpp +++ b/include/boost/random/linear_congruential.hpp @@ -53,9 +53,6 @@ public: // constant expressions. Avoid the check for now. // BOOST_STATIC_ASSERT(m == 0 || a < m); // BOOST_STATIC_ASSERT(m == 0 || c < m); -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); -#endif explicit linear_congruential(IntType x0 = 1) : _modulus(modulus), _x(_modulus ? (x0 % _modulus) : x0) @@ -64,6 +61,11 @@ public: // overflow check // disabled because it gives spurious "divide by zero" gcc warnings // assert(m == 0 || (a*(m-1)+c) % m == (c < a ? c-a+m : c-a)); + + // MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); +#endif } template diff --git a/include/boost/random/linear_feedback_shift.hpp b/include/boost/random/linear_feedback_shift.hpp index 644aacb..9e2e89e 100644 --- a/include/boost/random/linear_feedback_shift.hpp +++ b/include/boost/random/linear_feedback_shift.hpp @@ -52,13 +52,14 @@ public: // BOOST_STATIC_ASSERT(0 < 2*q && 2*q < k); // BOOST_STATIC_ASSERT(0 < s && s <= k-q); -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); - BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); -#endif - explicit linear_feedback_shift(UIntType s0 = 341) : wordmask(0) { + // MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); + BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); +#endif + // avoid "left shift count >= with of type" warning for(int i = 0; i < w; ++i) wordmask |= (1u << i); @@ -67,6 +68,12 @@ public: template linear_feedback_shift(It& first, It last) : wordmask(0) { + // MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); + BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); +#endif + // avoid "left shift count >= with of type" warning for(int i = 0; i < w; ++i) wordmask |= (1u << i); diff --git a/include/boost/random/subtract_with_carry.hpp b/include/boost/random/subtract_with_carry.hpp index 2ab5bc0..923614a 100644 --- a/include/boost/random/subtract_with_carry.hpp +++ b/include/boost/random/subtract_with_carry.hpp @@ -50,12 +50,14 @@ public: BOOST_STATIC_CONSTANT(unsigned int, long_lag = r); BOOST_STATIC_CONSTANT(unsigned int, short_lag = s); + subtract_with_carry() { + // MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - BOOST_STATIC_ASSERT(std::numeric_limits::is_signed); - BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); + BOOST_STATIC_ASSERT(std::numeric_limits::is_signed); + BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); #endif - - subtract_with_carry() { seed(); } + seed(); + } explicit subtract_with_carry(uint32_t value) { seed(value); } template explicit subtract_with_carry(Generator & gen) { seed(gen); } diff --git a/include/boost/random/uniform_int.hpp b/include/boost/random/uniform_int.hpp index 8ccbe7c..5dce49b 100644 --- a/include/boost/random/uniform_int.hpp +++ b/include/boost/random/uniform_int.hpp @@ -205,7 +205,7 @@ class uniform_int { private: #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - typedef typename detail::uniform_int::is_integer>::impl::type impl_type; + typedef typename detail::uniform_int::is_integer>::BOOST_NESTED_TEMPLATE impl::type impl_type; #else BOOST_STATIC_CONSTANT(bool, base_float = (boost::is_float::value == false)); typedef typename detail::uniform_int::BOOST_NESTED_TEMPLATE impl::type impl_type; @@ -218,13 +218,14 @@ public: BOOST_STATIC_CONSTANT(bool, has_fixed_range = false); -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); -#endif - explicit uniform_int(base_type & rng, IntType min = 0, IntType max = 9) : impl(rng, min, max) - { } + { +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + // MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope + BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); +#endif + } result_type min() const { return impl.min(); } result_type max() const { return impl.max(); } diff --git a/include/boost/random/uniform_smallint.hpp b/include/boost/random/uniform_smallint.hpp index cf55c2b..7b351ce 100644 --- a/include/boost/random/uniform_smallint.hpp +++ b/include/boost/random/uniform_smallint.hpp @@ -107,14 +107,15 @@ public: typedef UniformRandomNumberGenerator base_type; typedef IntType result_type; -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); - BOOST_STATIC_ASSERT(!std::numeric_limits::is_integer); -#endif - uniform_smallint_float(base_type & rng, IntType min, IntType max) : _rng(rng) { + // MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); + BOOST_STATIC_ASSERT(!std::numeric_limits::is_integer); +#endif + assert(min < max); } @@ -176,7 +177,7 @@ class uniform_smallint { private: #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - typedef typename detail::uniform_smallint::is_integer>::impl::type impl_type; + typedef typename detail::uniform_smallint::is_integer>::BOOST_NESTED_TEMPLATE impl::type impl_type; #else BOOST_STATIC_CONSTANT(bool, base_float = (boost::is_float::value == false)); typedef typename detail::uniform_smallint::BOOST_NESTED_TEMPLATE impl::type impl_type; @@ -188,13 +189,14 @@ public: typedef IntType result_type; BOOST_STATIC_CONSTANT(bool, has_fixed_range = false); -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); -#endif - explicit uniform_smallint(base_type & rng, IntType min = 0, IntType max = 9) : _impl(rng, min, max) - { } + { + // MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); +#endif + } result_type min() const { return _impl.min(); } result_type max() const { return _impl.max(); } diff --git a/include/boost/random/xor_combine.hpp b/include/boost/random/xor_combine.hpp index ac46cea..aba0204 100644 --- a/include/boost/random/xor_combine.hpp +++ b/include/boost/random/xor_combine.hpp @@ -48,13 +48,8 @@ public: BOOST_STATIC_CONSTANT(int, shift1 = s1); BOOST_STATIC_CONSTANT(int, shfit2 = s2); -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); - BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); - BOOST_STATIC_ASSERT(std::numeric_limits::digits >= std::numeric_limits::digits); -#endif - - xor_combine() : _rng1(), _rng2() { } + xor_combine() : _rng1(), _rng2() + { } xor_combine(const base1_type & rng1, const base2_type & rng2) : _rng1(rng1), _rng2(rng2) { } template xor_combine(It& first, It last) @@ -71,6 +66,12 @@ public: result_type operator()() { + // MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); + BOOST_STATIC_ASSERT(std::numeric_limits::is_integer); + BOOST_STATIC_ASSERT(std::numeric_limits::digits >= std::numeric_limits::digits); +#endif return (_rng1() << s1) ^ (_rng2() << s2); }