123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #ifndef BOOST_RANDOM_UNIFORM_INT_HPP
- #define BOOST_RANDOM_UNIFORM_INT_HPP
- #include <boost/assert.hpp>
- #include <boost/random/uniform_int_distribution.hpp>
- namespace boost {
- template<class IntType = int>
- class uniform_int : public random::uniform_int_distribution<IntType>
- {
- typedef random::uniform_int_distribution<IntType> base_type;
- public:
- class param_type : public base_type::param_type
- {
- public:
- typedef uniform_int distribution_type;
-
- explicit param_type(IntType min_arg = 0, IntType max_arg = 9)
- : base_type::param_type(min_arg, max_arg)
- {}
- };
-
- explicit uniform_int(IntType min_arg = 0, IntType max_arg = 9)
- : base_type(min_arg, max_arg)
- {}
-
- explicit uniform_int(const param_type& parm)
- : base_type(parm)
- {}
-
- param_type param() const { return param_type(this->a(), this->b()); }
-
- void param(const param_type& parm) { this->base_type::param(parm); }
-
- template<class Engine>
- IntType operator()(Engine& eng) const
- {
- return static_cast<const base_type&>(*this)(eng);
- }
- template<class Engine>
- IntType operator()(Engine& eng, const param_type& parm) const
- {
- return static_cast<const base_type&>(*this)(eng, parm);
- }
- template<class Engine>
- IntType operator()(Engine& eng, IntType n) const
- {
- BOOST_ASSERT(n > 0);
- return static_cast<const base_type&>(*this)(eng, param_type(0, n - 1));
- }
- };
- }
- #endif
|