1 /* boost random/random_number_generator.hpp header file
3 * Copyright Jens Maurer 2000-2001
4 * Distributed under the Boost Software License, Version 1.0. (See
5 * accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
8 * See http://www.boost.org for most recent version including documentation.
10 * $Id: random_number_generator.hpp 71018 2011-04-05 21:27:52Z steven_watanabe $
13 * 2001-02-18 moved to individual header files
16 #ifndef BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
17 #define BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
19 #include <boost/assert.hpp>
20 #include <boost/random/uniform_int_distribution.hpp>
22 #include <boost/random/detail/disable_warnings.hpp>
28 * Instantiations of class template random_number_generator model a
29 * RandomNumberGenerator (std:25.2.11 [lib.alg.random.shuffle]). On
30 * each invocation, it returns a uniformly distributed integer in
33 * The template parameter IntType shall denote some integer-like value type.
35 template<class URNG, class IntType = long>
36 class random_number_generator
39 typedef URNG base_type;
40 typedef IntType argument_type;
41 typedef IntType result_type;
43 * Constructs a random_number_generator functor with the given
44 * \uniform_random_number_generator as the underlying source of
47 random_number_generator(base_type& rng) : _rng(rng) {}
49 // compiler-generated copy ctor is fine
50 // assignment is disallowed because there is a reference member
53 * Returns a value in the range [0, n)
55 result_type operator()(argument_type n)
58 return uniform_int_distribution<IntType>(0, n-1)(_rng);
67 using random::random_number_generator;
71 #include <boost/random/detail/enable_warnings.hpp>
73 #endif // BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP