add C++14 constexpr version: random generator

This commit is contained in:
bolero-MURAKAMI 2013-11-05 17:39:11 +09:00
parent 2c9f0647f4
commit 230630b45b
6 changed files with 44 additions and 2 deletions

View file

@ -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_());
}