1 /* boost random/random_number_generator.hpp header file
\r
3 * Copyright Jens Maurer 2000-2001
\r
4 * Distributed under the Boost Software License, Version 1.0. (See
\r
5 * accompanying file LICENSE_1_0.txt or copy at
\r
6 * http://www.boost.org/LICENSE_1_0.txt)
\r
8 * See http://www.boost.org for most recent version including documentation.
\r
10 * $Id: random_number_generator.hpp 26164 2004-11-09 21:22:00Z jmaurer $
\r
13 * 2001-02-18 moved to individual header files
\r
16 #ifndef BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
\r
17 #define BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
\r
19 #include <boost/config.hpp>
\r
20 #include <boost/limits.hpp>
\r
21 #include <boost/static_assert.hpp>
\r
22 #include <boost/random/uniform_int.hpp>
\r
23 #include <boost/random/variate_generator.hpp>
\r
27 // a model for RandomNumberGenerator std:25.2.11 [lib.alg.random.shuffle]
\r
28 template<class UniformRandomNumberGenerator, class IntType = long>
\r
29 class random_number_generator
\r
32 typedef UniformRandomNumberGenerator base_type;
\r
33 typedef IntType argument_type;
\r
34 typedef IntType result_type;
\r
35 random_number_generator(base_type& rng) : _rng(rng)
\r
37 #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
\r
38 BOOST_STATIC_ASSERT(std::numeric_limits<result_type>::is_integer);
\r
41 // compiler-generated copy ctor is fine
\r
42 // assignment is disallowed because there is a reference member
\r
44 result_type operator()(argument_type n)
\r
46 typedef uniform_int<IntType> dist_type;
\r
47 return variate_generator<base_type&, dist_type>(_rng, dist_type(0, n-1))();
\r
54 } // namespace boost
\r
56 #endif // BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
\r