1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

workaround for no c++11 numeric_limits

This commit is contained in:
bolero-MURAKAMI 2013-08-07 00:15:09 +09:00
parent ce16e24637
commit 7a1974742a
110 changed files with 727 additions and 436 deletions

View file

@ -3,11 +3,11 @@
#include <cstddef>
#include <cstdint>
#include <limits>
#include <ios>
#include <istream>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/limits.hpp>
#include <sprout/array/array.hpp>
#include <sprout/operation/fixed/set.hpp>
#include <sprout/math/compare.hpp>
@ -38,8 +38,8 @@ namespace sprout {
: private sprout::random::detail::shuffle_order_engine_member<UniformRandomNumberGenerator, k>
{
static_assert(
std::numeric_limits<typename UniformRandomNumberGenerator::result_type>::is_integer,
"std::numeric_limits<typename UniformRandomNumberGenerator::result_type>::is_integer"
sprout::numeric_limits<typename UniformRandomNumberGenerator::result_type>::is_integer,
"sprout::numeric_limits<typename UniformRandomNumberGenerator::result_type>::is_integer"
);
static_assert(k > 0, "k > 0");
private:
@ -113,8 +113,8 @@ namespace sprout {
return generate_1(
rng_(),
k == 1 ? BaseUnsigned(0)
: sprout::math::less(brange, std::numeric_limits<BaseUnsigned>::max() / k) ? BaseUnsigned(k * off / (brange + 1))
: sprout::math::less(brange, std::numeric_limits<std::uintmax_t>::max() / k)
: sprout::math::less(brange, sprout::numeric_limits<BaseUnsigned>::max() / k) ? BaseUnsigned(k * off / (brange + 1))
: sprout::math::less(brange, sprout::numeric_limits<std::uintmax_t>::max() / k)
? static_cast<BaseUnsigned>(static_cast<std::uintmax_t>(off) * k / (static_cast<std::uintmax_t>(brange) + 1))
//: static_cast<BaseUnsigned>(sprout::random::detail::muldiv(off, k, static_cast<std::uintmax_t>(brange) + 1)) // ???
: (SPROUT_ASSERT_MSG(0, "Sorry, not implemented."), sprout::random::random_result<shuffle_order_engine>())