diff --git a/sprout/random/linear_congruential.hpp b/sprout/random/linear_congruential.hpp index ac41ba0f..b2838744 100644 --- a/sprout/random/linear_congruential.hpp +++ b/sprout/random/linear_congruential.hpp @@ -65,7 +65,8 @@ namespace sprout { } public: SPROUT_CONSTEXPR linear_congruential_engine() - : x_(init_seed(default_seed)) + //: x_(init_seed(default_seed)) // ??? + : x_(init_seed(1)) // ??? {} SPROUT_CONSTEXPR explicit linear_congruential_engine(IntType const& x0) : x_(init_seed(x0)) diff --git a/sprout/random/random_iterator.hpp b/sprout/random/random_iterator.hpp index 18b80f22..0969dfe9 100644 --- a/sprout/random/random_iterator.hpp +++ b/sprout/random/random_iterator.hpp @@ -46,6 +46,7 @@ namespace sprout { random_result_type random_; difference_type count_; public: + //random_iterator() = default; // ??? SPROUT_CONSTEXPR random_iterator() : random_() , count_() @@ -118,7 +119,7 @@ namespace sprout { SPROUT_CONSTEXPR reference operator*() const { return count_ != 0 ? random_.result() - : throw "assert(count_ != 0)" + : (throw "assert(count_ != 0)", random_.result()) ; } SPROUT_CONSTEXPR pointer operator->() const { @@ -165,6 +166,7 @@ namespace sprout { random_result_type random_; difference_type count_; public: + //random_iterator() = default; // ??? SPROUT_CONSTEXPR random_iterator() : random_() , count_() @@ -230,7 +232,7 @@ namespace sprout { SPROUT_CONSTEXPR reference operator*() const { return count_ != 0 ? random_.result() - : throw "assert(count_ != 0)" + : (throw "assert(count_ != 0)", random_.result()) ; } SPROUT_CONSTEXPR pointer operator->() const { @@ -263,18 +265,62 @@ namespace sprout { } // - // next + // begin // template - SPROUT_CONSTEXPR sprout::random::random_iterator next( - sprout::random::random_iterator const& it + SPROUT_CONSTEXPR typename std::enable_if< + !std::is_integral::value, + sprout::random::random_iterator + >::type begin( + Engine const& engine, + Distribution const& distribution, + typename sprout::random::random_iterator::difference_type count = -1 ) { - return it(); + return sprout::random::random_iterator(engine, distribution, count); + } + template + SPROUT_CONSTEXPR sprout::random::random_iterator begin( + Engine const& engine, + typename sprout::random::random_iterator::difference_type count = -1 + ) + { + return sprout::random::random_iterator(engine, count); + } + + // + // end + // + template + SPROUT_CONSTEXPR sprout::random::random_iterator end( + Engine const& engine, + Distribution const& distribution + ) + { + return sprout::random::random_iterator(); + } + template + SPROUT_CONSTEXPR sprout::random::random_iterator end( + Engine const& engine + ) + { + return sprout::random::random_iterator(); } } // namespace random + // + // next + // + template + SPROUT_CONSTEXPR sprout::random::random_iterator next( + sprout::random::random_iterator const& it + ) + { + return it(); + } + using sprout::random::random_iterator; } // namespace sprout #endif // #ifndef SPROUT_RANDOM_RANDOM_ITERATOR_HPP + diff --git a/sprout/random/random_result.hpp b/sprout/random/random_result.hpp index ddd4ea9c..6e70298b 100644 --- a/sprout/random/random_result.hpp +++ b/sprout/random/random_result.hpp @@ -53,6 +53,12 @@ namespace sprout { engine_type engine_; distribution_type distribution_; public: + //random_result() = default; // ??? + SPROUT_CONSTEXPR random_result() + : result_() + , engine_() + , distribution_() + {} SPROUT_CONSTEXPR random_result( result_type result, engine_type const& engine, @@ -159,6 +165,11 @@ namespace sprout { result_type result_; engine_type engine_; public: + //random_result() = default; // ??? + SPROUT_CONSTEXPR random_result() + : result_() + , engine_() + {} SPROUT_CONSTEXPR random_result( result_type result, engine_type const& engine @@ -232,19 +243,19 @@ namespace sprout { { lhs.swap(rhs); } - - // - // next - // - template - SPROUT_CONSTEXPR sprout::random::random_result next( - sprout::random::random_result const& it - ) - { - return it(); - } } // namespace random + // + // next + // + template + SPROUT_CONSTEXPR sprout::random::random_result next( + sprout::random::random_result const& it + ) + { + return it(); + } + using sprout::random::random_result; } // namespace sprout diff --git a/sprout/random/uniform_smallint.hpp b/sprout/random/uniform_smallint.hpp index 92e6ea51..41f866df 100644 --- a/sprout/random/uniform_smallint.hpp +++ b/sprout/random/uniform_smallint.hpp @@ -37,7 +37,11 @@ namespace sprout { IntType min_; IntType max_; public: - SPROUT_CONSTEXPR param_type(IntType min_arg = 0, IntType max_arg = 9) + SPROUT_CONSTEXPR param_type() + : min_(0) + , max_(9) + {} + SPROUT_CONSTEXPR explicit param_type(IntType min_arg, IntType max_arg = 9) : min_(arg_check(min_arg, max_arg)) , max_(max_arg) {} @@ -180,11 +184,17 @@ namespace sprout { ); } public: - SPROUT_CONSTEXPR explicit uniform_smallint(IntType min_arg = 0, IntType max_arg = 9) - : min_(min_arg), max_(max_arg) + SPROUT_CONSTEXPR uniform_smallint() + : min_(0) + , max_(9) + {} + SPROUT_CONSTEXPR explicit uniform_smallint(IntType min_arg, IntType max_arg = 9) + : min_(min_arg) + , max_(max_arg) {} explicit uniform_smallint(param_type const& parm) - : min_(parm.a()), max_(parm.b()) + : min_(parm.a()) + , max_(parm.b()) {} SPROUT_CONSTEXPR result_type a() const { return min_;