Boost C++ Libraries

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

This is an old version of boost. Click here for the latest version's documentation home page.
PrevUpHomeNext

Class template uniform_int

boost::uniform_int

Synopsis

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

template<typename IntType = int> 
class uniform_int {
public:
  // 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);
};

Description

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);

PrevUpHomeNext