Warning, file /include/boost/random/random_number_generator.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
0017 #define BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
0018
0019 #include <boost/assert.hpp>
0020 #include <boost/random/uniform_int_distribution.hpp>
0021
0022 #include <boost/random/detail/disable_warnings.hpp>
0023
0024 namespace boost {
0025 namespace random {
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 template<class URNG, class IntType = long>
0036 class random_number_generator
0037 {
0038 public:
0039 typedef URNG base_type;
0040 typedef IntType argument_type;
0041 typedef IntType result_type;
0042
0043
0044
0045
0046
0047 random_number_generator(base_type& rng) : _rng(rng) {}
0048
0049
0050
0051
0052
0053
0054
0055 result_type operator()(argument_type n)
0056 {
0057 BOOST_ASSERT(n > 0);
0058 return uniform_int_distribution<IntType>(0, n-1)(_rng);
0059 }
0060
0061 private:
0062 base_type& _rng;
0063 };
0064
0065 }
0066
0067 using random::random_number_generator;
0068
0069 }
0070
0071 #include <boost/random/detail/enable_warnings.hpp>
0072
0073 #endif