Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.

Class template uniform_int



// In header: <boost/random/uniform_int.hpp>

template<typename IntType = int> 
class uniform_int {
  // types
  typedef IntType input_type; 
  typedef IntType result_type;

  // construct/copy/destruct
  uniform_int(IntType = 0, IntType = 9);

  // public member functions
  result_type min() const;
  result_type max() const;
  void reset();
  template<typename Engine> result_type operator()(Engine &);
  template<typename Engine> result_type operator()(Engine &, result_type);


The distribution function uniform_int models a random distribution . On each invocation, it returns a random integer value uniformly distributed in the set of integer numbers {min, min+1, min+2, ..., max}.

The template parameter IntType shall denote an integer-like value type.

uniform_int public construct/copy/destruct

  1. uniform_int(IntType min_arg = 0, IntType max_arg = 9);

    Constructs a uniform_int object. min and max are the parameters of the distribution.

    Requires: min <= max

uniform_int public member functions

  1. result_type min() const;

    Returns: The "min" parameter of the distribution

  2. result_type max() const;

    Returns: The "max" parameter of the distribution

  3. void reset();
  4. template<typename Engine> result_type operator()(Engine & eng);
  5. template<typename Engine> result_type operator()(Engine & eng, result_type n);