Project revived from Feb2017
[EroSomnia.git] / deps / boost_1_63_0 / boost / random / uniform_int.hpp
blob4362652593ded9858618a6ad1e1384041c954674
1 /* boost random/uniform_int.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$
12 * Revision history
13 * 2001-04-08 added min<max assertion (N. Becker)
14 * 2001-02-18 moved to individual header files
17 #ifndef BOOST_RANDOM_UNIFORM_INT_HPP
18 #define BOOST_RANDOM_UNIFORM_INT_HPP
20 #include <boost/assert.hpp>
21 #include <boost/random/uniform_int_distribution.hpp>
23 namespace boost {
25 /**
26 * The distribution function uniform_int models a \random_distribution.
27 * On each invocation, it returns a random integer value uniformly
28 * distributed in the set of integer numbers {min, min+1, min+2, ..., max}.
30 * The template parameter IntType shall denote an integer-like value type.
32 * This class is deprecated. Please use @c uniform_int_distribution in
33 * new code.
35 template<class IntType = int>
36 class uniform_int : public random::uniform_int_distribution<IntType>
38 typedef random::uniform_int_distribution<IntType> base_type;
39 public:
41 class param_type : public base_type::param_type
43 public:
44 typedef uniform_int distribution_type;
45 /**
46 * Constructs the parameters of a uniform_int distribution.
48 * Requires: min <= max
50 explicit param_type(IntType min_arg = 0, IntType max_arg = 9)
51 : base_type::param_type(min_arg, max_arg)
55 /**
56 * Constructs a uniform_int object. @c min and @c max are
57 * the parameters of the distribution.
59 * Requires: min <= max
61 explicit uniform_int(IntType min_arg = 0, IntType max_arg = 9)
62 : base_type(min_arg, max_arg)
65 /** Constructs a uniform_int distribution from its parameters. */
66 explicit uniform_int(const param_type& parm)
67 : base_type(parm)
70 /** Returns the parameters of the distribution */
71 param_type param() const { return param_type(this->a(), this->b()); }
72 /** Sets the parameters of the distribution. */
73 void param(const param_type& parm) { this->base_type::param(parm); }
75 // Codergear seems to have trouble with a using declaration here
77 template<class Engine>
78 IntType operator()(Engine& eng) const
80 return static_cast<const base_type&>(*this)(eng);
83 template<class Engine>
84 IntType operator()(Engine& eng, const param_type& parm) const
86 return static_cast<const base_type&>(*this)(eng, parm);
89 template<class Engine>
90 IntType operator()(Engine& eng, IntType n) const
92 BOOST_ASSERT(n > 0);
93 return static_cast<const base_type&>(*this)(eng, param_type(0, n - 1));
97 } // namespace boost
99 #endif // BOOST_RANDOM_UNIFORM_INT_HPP