mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
fix Sseq SFINAE
This commit is contained in:
parent
e03f53f0d2
commit
a32b1c7c00
7 changed files with 65 additions and 30 deletions
|
@ -14,6 +14,8 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/random/random_result.hpp>
|
||||
#include <sprout/random/linear_congruential.hpp>
|
||||
#include <sprout/random/type_traits.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace random {
|
||||
|
@ -67,11 +69,11 @@ namespace sprout {
|
|||
explicit SPROUT_CONSTEXPR additive_combine_engine(result_type seed)
|
||||
: mlcg1_(seed), mlcg2_(seed)
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CXX14_CONSTEXPR additive_combine_engine(Sseq& seq)
|
||||
: mlcg1_(seq), mlcg2_(seq)
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CONSTEXPR additive_combine_engine(Sseq const& seq)
|
||||
: mlcg1_(seq), mlcg2_(seq)
|
||||
{}
|
||||
|
@ -93,12 +95,12 @@ namespace sprout {
|
|||
mlcg1_.seed(seed);
|
||||
mlcg2_.seed(seed);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) {
|
||||
mlcg1_.seed(seq);
|
||||
mlcg2_.seed(seq);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) {
|
||||
mlcg1_.seed(seq);
|
||||
mlcg2_.seed(seq);
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include <sprout/random/detail/const_mod.hpp>
|
||||
#include <sprout/random/detail/seed_impl.hpp>
|
||||
#include <sprout/random/random_result.hpp>
|
||||
#include <sprout/random/type_traits.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/math/greater_equal.hpp>
|
||||
#include <sprout/assert.hpp>
|
||||
|
||||
|
@ -54,11 +56,11 @@ namespace sprout {
|
|||
static SPROUT_CONSTEXPR result_type init_seed(result_type x0 = default_seed) {
|
||||
return init_seed_1(modulus == 0 ? x0 : x0 % modulus);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
static SPROUT_CXX14_CONSTEXPR result_type init_seed(Sseq& seq) {
|
||||
return init_seed(sprout::random::detail::seed_one_int<result_type, modulus>(seq));
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
static SPROUT_CONSTEXPR result_type init_seed(Sseq const& seq) {
|
||||
return init_seed(sprout::random::detail::seed_one_int<result_type, modulus>(seq));
|
||||
}
|
||||
|
@ -86,11 +88,11 @@ namespace sprout {
|
|||
explicit SPROUT_CONSTEXPR inversive_congruential_engine(result_type x0)
|
||||
: x_(init_seed(x0))
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CXX14_CONSTEXPR inversive_congruential_engine(Sseq& seq)
|
||||
: x_(init_seed(seq))
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CONSTEXPR inversive_congruential_engine(Sseq const& seq)
|
||||
: x_(init_seed(seq))
|
||||
{}
|
||||
|
@ -101,11 +103,11 @@ namespace sprout {
|
|||
SPROUT_CXX14_CONSTEXPR void seed(result_type x0 = default_seed) {
|
||||
x_ = init_seed(x0);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) {
|
||||
x_ = init_seed(seq);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) {
|
||||
x_ = init_seed(seq);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include <sprout/random/detail/const_mod.hpp>
|
||||
#include <sprout/random/detail/seed_impl.hpp>
|
||||
#include <sprout/random/random_result.hpp>
|
||||
#include <sprout/random/type_traits.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/math/greater_equal.hpp>
|
||||
#include <sprout/assert.hpp>
|
||||
|
||||
|
@ -58,11 +60,11 @@ namespace sprout {
|
|||
static SPROUT_CONSTEXPR result_type init_seed(result_type x0 = default_seed) {
|
||||
return init_seed_1(modulus == 0 ? x0 : x0 % modulus);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
static SPROUT_CXX14_CONSTEXPR result_type init_seed(Sseq& seq) {
|
||||
return init_seed(sprout::random::detail::seed_one_int<result_type, modulus>(seq));
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
static SPROUT_CONSTEXPR result_type init_seed(Sseq const& seq) {
|
||||
return init_seed(sprout::random::detail::seed_one_int<result_type, modulus>(seq));
|
||||
}
|
||||
|
@ -89,11 +91,11 @@ namespace sprout {
|
|||
explicit SPROUT_CONSTEXPR linear_congruential_engine(result_type x0)
|
||||
: x_(init_seed(x0))
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CXX14_CONSTEXPR linear_congruential_engine(Sseq& seq)
|
||||
: x_(init_seed(seq))
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CONSTEXPR linear_congruential_engine(Sseq const& seq)
|
||||
: x_(init_seed(seq))
|
||||
{}
|
||||
|
@ -104,11 +106,11 @@ namespace sprout {
|
|||
SPROUT_CXX14_CONSTEXPR void seed(result_type x0 = default_seed) {
|
||||
x_ = init_seed(x0);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) {
|
||||
x_ = init_seed(seq);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) {
|
||||
x_ = init_seed(seq);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <sprout/detail/integer/integer_mask.hpp>
|
||||
#include <sprout/random/detail/seed_impl.hpp>
|
||||
#include <sprout/random/random_result.hpp>
|
||||
#include <sprout/random/type_traits.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace random {
|
||||
|
@ -54,11 +56,11 @@ namespace sprout {
|
|||
static SPROUT_CONSTEXPR result_type init_seed(result_type x0 = default_seed) {
|
||||
return init_seed_1(x0 & wordmask());
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
static SPROUT_CXX14_CONSTEXPR result_type init_seed(Sseq& seq) {
|
||||
return init_seed(sprout::random::detail::seed_one_int<result_type, (result_type(2) << (w - 1))>(seq));
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
static SPROUT_CONSTEXPR result_type init_seed(Sseq const& seq) {
|
||||
return init_seed(sprout::random::detail::seed_one_int<result_type, (result_type(2) << (w - 1))>(seq));
|
||||
}
|
||||
|
@ -85,11 +87,11 @@ namespace sprout {
|
|||
explicit SPROUT_CONSTEXPR linear_feedback_shift_engine(result_type x0)
|
||||
: x_(init_seed(x0))
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CXX14_CONSTEXPR linear_feedback_shift_engine(Sseq& seq)
|
||||
: x_(init_seed(seq))
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CONSTEXPR linear_feedback_shift_engine(Sseq const& seq)
|
||||
: x_(init_seed(seq))
|
||||
{}
|
||||
|
@ -100,11 +102,11 @@ namespace sprout {
|
|||
SPROUT_CXX14_CONSTEXPR void seed(result_type x0 = default_seed) {
|
||||
x_ = init_seed(x0);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) {
|
||||
x_ = init_seed(seq);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) {
|
||||
x_ = init_seed(seq);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include <sprout/random/random_result.hpp>
|
||||
#include <sprout/random/linear_congruential.hpp>
|
||||
#include <sprout/random/detail/signed_unsigned_tools.hpp>
|
||||
#include <sprout/random/type_traits.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/assert.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -142,11 +144,11 @@ namespace sprout {
|
|||
explicit SPROUT_CONSTEXPR shuffle_order_engine(result_type seed)
|
||||
: member_type(init_member(base_type(seed)))
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CXX14_CONSTEXPR shuffle_order_engine(Sseq& seq)
|
||||
: member_type(init_member(base_type(seq)))
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CONSTEXPR shuffle_order_engine(Sseq const& seq)
|
||||
: member_type(init_member(base_type(seq)))
|
||||
{}
|
||||
|
@ -163,11 +165,11 @@ namespace sprout {
|
|||
SPROUT_CXX14_CONSTEXPR void seed(result_type seed) {
|
||||
member_type::operator=(init_member(base_type(seed)));
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) {
|
||||
member_type::operator=(init_member(base_type(seq)));
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) {
|
||||
member_type::operator=(init_member(base_type(seq)));
|
||||
}
|
||||
|
|
23
sprout/random/type_traits.hpp
Normal file
23
sprout/random/type_traits.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_RANDOM_TYPE_TRAITS_HPP
|
||||
#define SPROUT_RANDOM_TYPE_TRAITS_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_xxx.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace random {
|
||||
//
|
||||
// is_seed_seq
|
||||
//
|
||||
SPROUT_HAS_XXX_TYPE_DEF(is_seed_seq, result_type);
|
||||
} // namespace random
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANDOM_TYPE_TRAITS_HPP
|
|
@ -12,6 +12,8 @@
|
|||
#include <istream>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/random/random_result.hpp>
|
||||
#include <sprout/random/type_traits.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -57,11 +59,11 @@ namespace sprout {
|
|||
explicit SPROUT_CONSTEXPR xor_combine_engine(result_type seed)
|
||||
: rng1_(seed), rng2_(seed)
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CXX14_CONSTEXPR xor_combine_engine(Sseq& seq)
|
||||
: rng1_(seq), rng2_(seq)
|
||||
{}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
explicit SPROUT_CONSTEXPR xor_combine_engine(Sseq const& seq)
|
||||
: rng1_(seq), rng2_(seq)
|
||||
{}
|
||||
|
@ -83,12 +85,12 @@ namespace sprout {
|
|||
rng1_.seed(seed);
|
||||
rng2_.seed(seed);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) {
|
||||
rng1_.seed(seq);
|
||||
rng2_.seed(seq);
|
||||
}
|
||||
template<typename Sseq>
|
||||
template<typename Sseq, typename sprout::enabler_if<sprout::random::is_seed_seq<Sseq>::value>::type = sprout::enabler>
|
||||
SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) {
|
||||
rng1_.seed(seq);
|
||||
rng2_.seed(seq);
|
||||
|
|
Loading…
Reference in a new issue