---
name: "std::tr1::uniform_int"
section: "3cxx"
platform: "linux"
package: "libstdc++6-4.4-doc"
version: "4.4.5-8"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/std::tr1::uniform_int/3cxx"
---

# std::tr1::uniform\_int(3cxx)

Uniform discrete distribution for random numbers. A discrete random distribution on the range $\[min, max\]$ with equal probability throughout the range.

## NAME

std::tr1::uniform\_int -

Uniform discrete distribution for random numbers. A discrete random distribution on the range $\[min, max\]$ with equal probability throughout the range.

## SYNOPSIS

### Public Types

typedef \_IntType **input\_type**\
 typedef \_IntType **result\_type**\

### Public Member Functions

**result\_type** **max** () const \
 **result\_type** **min** () const \
 template\<typename \_UniformRandomNumberGenerator \> **result\_type** **operator()** (\_UniformRandomNumberGenerator &\_\_urng)\
 template\<typename \_UniformRandomNumberGenerator \> **result\_type** **operator()** (\_UniformRandomNumberGenerator &\_\_urng, **result\_type** \_\_n)\
 void **reset** ()\
 **uniform\_int** (\_IntType \_\_min=0, \_IntType \_\_max=9)\

### Friends

template\<typename \_IntType1 , typename \_CharT , typename \_Traits \> **std::basic\_ostream**\< \_CharT, \_Traits \> & **operator\<\<** (**std::basic\_ostream**\< \_CharT, \_Traits \> &\_\_os, const **uniform\_int**\< \_IntType1 \> &\_\_x)\
 template\<typename \_IntType1 , typename \_CharT , typename \_Traits \> **std::basic\_istream**\< \_CharT, \_Traits \> & **operator\>\>** (**std::basic\_istream**\< \_CharT, \_Traits \> &\_\_is, **uniform\_int**\< \_IntType1 \> &\_\_x)\

## Detailed Description

### template\<typename \_IntType = int\> class std::tr1::uniform\_int\< \_IntType \>

Uniform discrete distribution for random numbers. A discrete random distribution on the range $\[min, max\]$ with equal probability throughout the range.

Definition at line 1560 of file tr1\_impl/random.

## Member Typedef Documentation

### template\<typename \_IntType = int\> typedef \_IntType std::tr1::uniform\_int\< \_IntType \>::input\_type The type of the parameters of the distribution.

Definition at line 1566 of file tr1\_impl/random.

### template\<typename \_IntType = int\> typedef \_IntType std::tr1::uniform\_int\< \_IntType \>::result\_type The type of the range of the distribution.

Definition at line 1568 of file tr1\_impl/random.

## Constructor & Destructor Documentation

### template\<typename \_IntType = int\> std::tr1::uniform\_int\< \_IntType \>::uniform\_int (\_IntType \_\_min = `0`, \_IntType \_\_max = `9`)` [inline, explicit]` Constructs a uniform distribution object.

Definition at line 1575 of file tr1\_impl/random.

## Member Function Documentation

### template\<typename \_IntType = int\> result\_type std::tr1::uniform\_int\< \_IntType \>::max () const` [inline]` Gets the inclusive upper bound of the distribution range.

Definition at line 1592 of file tr1\_impl/random.

### template\<typename \_IntType = int\> result\_type std::tr1::uniform\_int\< \_IntType \>::min () const` [inline]` Gets the inclusive lower bound of the distribution range.

Definition at line 1585 of file tr1\_impl/random.

### template\<typename \_IntType = int\> template\<typename \_UniformRandomNumberGenerator \> result\_type std::tr1::uniform\_int\< \_IntType \>::operator() (\_UniformRandomNumberGenerator & \_\_urng)` [inline]` Gets a uniformly distributed random number in the range $(min, max)$.

Definition at line 1609 of file tr1\_impl/random.

### template\<typename \_IntType = int\> template\<typename \_UniformRandomNumberGenerator \> result\_type std::tr1::uniform\_int\< \_IntType \>::operator() (\_UniformRandomNumberGenerator & \_\_urng, result\_type \_\_n)` [inline]` Gets a uniform random number in the range $\[0, n)$.

This function is aimed at use with std::random\_shuffle.

Definition at line 1624 of file tr1\_impl/random.

### template\<typename \_IntType = int\> void std::tr1::uniform\_int\< \_IntType \>::reset ()` [inline]` Resets the distribution state.

Does nothing for the uniform integer distribution.

Definition at line 1601 of file tr1\_impl/random.

## Friends And Related Function Documentation

### template\<typename \_IntType = int\> template\<typename \_IntType1 , typename \_CharT , typename \_Traits \> std::basic\_ostream\<\_CharT, \_Traits\>& operator\<\< (std::basic\_ostream\< \_CharT, \_Traits \> & \_\_os, const uniform\_int\< \_IntType1 \> & \_\_x)` [friend]` Inserts a uniform\_int random number distribution `__x` into the output stream `os`.

**Parameters:**

*\_\_os* An output stream. \
 *\_\_x* A uniform\_int random number distribution.

**Returns:**

The output stream with the state of `__x` inserted or in an error state.

### template\<typename \_IntType = int\> template\<typename \_IntType1 , typename \_CharT , typename \_Traits \> std::basic\_istream\<\_CharT, \_Traits\>& operator\>\> (std::basic\_istream\< \_CharT, \_Traits \> & \_\_is, uniform\_int\< \_IntType1 \> & \_\_x)` [friend]` Extracts a uniform\_int random number distribution `__x` from the input stream `__is`.

**Parameters:**

*\_\_is* An input stream. \
 *\_\_x* A uniform\_int random number generator engine.

**Returns:**

The input stream with `__x` extracted or in an error state.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
