mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +00:00
add C++14 constexpr version: random generator
This commit is contained in:
parent
2c9f0647f4
commit
230630b45b
6 changed files with 44 additions and 2 deletions
|
@ -82,6 +82,14 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
|
||||
return base1_type::modulus - 1;
|
||||
}
|
||||
SPROUT_CXX14_CONSTEXPR result_type operator()() {
|
||||
result_type val1 = static_cast<result_type>(mlcg1_());
|
||||
result_type val2 = static_cast<result_type>(mlcg2_());
|
||||
return val2 < val1
|
||||
? val1 - val2
|
||||
: val1 - val2 + base1_type::modulus - 1
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<additive_combine_engine> const operator()() const {
|
||||
return generate(mlcg1_(), mlcg2_());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue