diff --git a/sprout/random/additive_combine.hpp b/sprout/random/additive_combine.hpp index 7040c542..7c355491 100644 --- a/sprout/random/additive_combine.hpp +++ b/sprout/random/additive_combine.hpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include namespace sprout { namespace random { @@ -67,11 +69,11 @@ namespace sprout { explicit SPROUT_CONSTEXPR additive_combine_engine(result_type seed) : mlcg1_(seed), mlcg2_(seed) {} - template + template::value>::type = sprout::enabler> explicit SPROUT_CXX14_CONSTEXPR additive_combine_engine(Sseq& seq) : mlcg1_(seq), mlcg2_(seq) {} - template + template::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 + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) { mlcg1_.seed(seq); mlcg2_.seed(seq); } - template + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) { mlcg1_.seed(seq); mlcg2_.seed(seq); diff --git a/sprout/random/inversive_congruential.hpp b/sprout/random/inversive_congruential.hpp index 92c9a05e..22326643 100644 --- a/sprout/random/inversive_congruential.hpp +++ b/sprout/random/inversive_congruential.hpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include @@ -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 + template::value>::type = sprout::enabler> static SPROUT_CXX14_CONSTEXPR result_type init_seed(Sseq& seq) { return init_seed(sprout::random::detail::seed_one_int(seq)); } - template + template::value>::type = sprout::enabler> static SPROUT_CONSTEXPR result_type init_seed(Sseq const& seq) { return init_seed(sprout::random::detail::seed_one_int(seq)); } @@ -86,11 +88,11 @@ namespace sprout { explicit SPROUT_CONSTEXPR inversive_congruential_engine(result_type x0) : x_(init_seed(x0)) {} - template + template::value>::type = sprout::enabler> explicit SPROUT_CXX14_CONSTEXPR inversive_congruential_engine(Sseq& seq) : x_(init_seed(seq)) {} - template + template::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 + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) { x_ = init_seed(seq); } - template + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) { x_ = init_seed(seq); } diff --git a/sprout/random/linear_congruential.hpp b/sprout/random/linear_congruential.hpp index ce364dc8..432c55ed 100644 --- a/sprout/random/linear_congruential.hpp +++ b/sprout/random/linear_congruential.hpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include @@ -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 + template::value>::type = sprout::enabler> static SPROUT_CXX14_CONSTEXPR result_type init_seed(Sseq& seq) { return init_seed(sprout::random::detail::seed_one_int(seq)); } - template + template::value>::type = sprout::enabler> static SPROUT_CONSTEXPR result_type init_seed(Sseq const& seq) { return init_seed(sprout::random::detail::seed_one_int(seq)); } @@ -89,11 +91,11 @@ namespace sprout { explicit SPROUT_CONSTEXPR linear_congruential_engine(result_type x0) : x_(init_seed(x0)) {} - template + template::value>::type = sprout::enabler> explicit SPROUT_CXX14_CONSTEXPR linear_congruential_engine(Sseq& seq) : x_(init_seed(seq)) {} - template + template::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 + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) { x_ = init_seed(seq); } - template + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) { x_ = init_seed(seq); } diff --git a/sprout/random/linear_feedback_shift.hpp b/sprout/random/linear_feedback_shift.hpp index a607e1b1..d6be35a1 100644 --- a/sprout/random/linear_feedback_shift.hpp +++ b/sprout/random/linear_feedback_shift.hpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include 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 + template::value>::type = sprout::enabler> static SPROUT_CXX14_CONSTEXPR result_type init_seed(Sseq& seq) { return init_seed(sprout::random::detail::seed_one_int(seq)); } - template + template::value>::type = sprout::enabler> static SPROUT_CONSTEXPR result_type init_seed(Sseq const& seq) { return init_seed(sprout::random::detail::seed_one_int(seq)); } @@ -85,11 +87,11 @@ namespace sprout { explicit SPROUT_CONSTEXPR linear_feedback_shift_engine(result_type x0) : x_(init_seed(x0)) {} - template + template::value>::type = sprout::enabler> explicit SPROUT_CXX14_CONSTEXPR linear_feedback_shift_engine(Sseq& seq) : x_(init_seed(seq)) {} - template + template::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 + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) { x_ = init_seed(seq); } - template + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) { x_ = init_seed(seq); } diff --git a/sprout/random/shuffle_order.hpp b/sprout/random/shuffle_order.hpp index c0446338..0a4c02fa 100644 --- a/sprout/random/shuffle_order.hpp +++ b/sprout/random/shuffle_order.hpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include 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 + template::value>::type = sprout::enabler> explicit SPROUT_CXX14_CONSTEXPR shuffle_order_engine(Sseq& seq) : member_type(init_member(base_type(seq))) {} - template + template::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 + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) { member_type::operator=(init_member(base_type(seq))); } - template + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) { member_type::operator=(init_member(base_type(seq))); } diff --git a/sprout/random/type_traits.hpp b/sprout/random/type_traits.hpp new file mode 100644 index 00000000..d06cc043 --- /dev/null +++ b/sprout/random/type_traits.hpp @@ -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 +#include + +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 diff --git a/sprout/random/xor_combine.hpp b/sprout/random/xor_combine.hpp index d863302a..fb9b520f 100644 --- a/sprout/random/xor_combine.hpp +++ b/sprout/random/xor_combine.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #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 + template::value>::type = sprout::enabler> explicit SPROUT_CXX14_CONSTEXPR xor_combine_engine(Sseq& seq) : rng1_(seq), rng2_(seq) {} - template + template::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 + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq& seq) { rng1_.seed(seq); rng2_.seed(seq); } - template + template::value>::type = sprout::enabler> SPROUT_CXX14_CONSTEXPR void seed(Sseq const& seq) { rng1_.seed(seq); rng2_.seed(seq);