123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- #ifndef BOOST_RANDOM_RANDOM_GENERATOR_HPP
- #define BOOST_RANDOM_RANDOM_GENERATOR_HPP
- #include <boost/random/detail/ptr_helper.hpp>
- #include <boost/random/detail/disable_warnings.hpp>
- namespace boost {
- namespace random {
- template<class Engine, class Distribution>
- class variate_generator
- {
- private:
- typedef boost::random::detail::ptr_helper<Engine> helper_type;
- public:
- typedef typename helper_type::value_type engine_value_type;
- typedef Engine engine_type;
- typedef Distribution distribution_type;
- typedef typename Distribution::result_type result_type;
-
- variate_generator(Engine e, Distribution d)
- : _eng(e), _dist(d) { }
-
- result_type operator()() { return _dist(engine()); }
-
- template<class T>
- result_type operator()(const T& value) { return _dist(engine(), value); }
-
- engine_value_type& engine() { return helper_type::ref(_eng); }
-
- const engine_value_type& engine() const { return helper_type::ref(_eng); }
-
- distribution_type& distribution() { return _dist; }
-
- const distribution_type& distribution() const { return _dist; }
-
- result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (distribution().min)(); }
-
- result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (distribution().max)(); }
- private:
- Engine _eng;
- distribution_type _dist;
- };
- }
- using random::variate_generator;
- }
- #include <boost/random/detail/enable_warnings.hpp>
- #endif
|