---
name: "std::uniform_int_distribution"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::uniform_int_distribution/3cxx"
---

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

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

## NAME

std::uniform\_int\_distribution\< \_IntType \> - Uniform discrete distribution for random numbers. A discrete random distribution on the range $\[min, max\]$ with equal probability throughout the range.

## SYNOPSIS

`#include <random>`

### Classes

struct **param\_type**\

### Public Types

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

### Public Member Functions

**uniform\_int\_distribution** ()\
 Constructs a uniform distribution object.  **uniform\_int\_distribution** (\_IntType \_\_a, \_IntType \_\_b=**\_\_gnu\_cxx::\_\_int\_traits**\< \_IntType \>::\_\_max)\
 Constructs a uniform distribution object.  **uniform\_int\_distribution** (const **param\_type** &\_\_p)\
 template\<**typename** **\_ForwardIterator** , **typename** **\_UniformRandomBitGenerator** \> **void** **\_\_generate** (**\_ForwardIterator** \_\_f, **\_ForwardIterator** \_\_t, **\_UniformRandomBitGenerator** &**\_\_urng**)\
 template\<**typename** **\_ForwardIterator** , **typename** **\_UniformRandomBitGenerator** \> **void** **\_\_generate** (**\_ForwardIterator** \_\_f, **\_ForwardIterator** \_\_t, **\_UniformRandomBitGenerator** &**\_\_urng**, const **param\_type** &\_\_p)\
 template\<**typename** **\_UniformRandomBitGenerator** \> **void** **\_\_generate** (**result\_type** \*\_\_f, **result\_type** \*\_\_t, **\_UniformRandomBitGenerator** &**\_\_urng**, const **param\_type** &\_\_p)\
 **result\_type** **a** () const\
 **result\_type** **b** () const\
 **result\_type** **max** () const\
 Returns the inclusive upper bound of the distribution range.  **result\_type** **min** () const\
 Returns the inclusive lower bound of the distribution range.  template\<**typename** **\_UniformRandomBitGenerator** \> **result\_type** **operator()** (**\_UniformRandomBitGenerator** &**\_\_urng**)\
 Generating functions.  template\<**typename** **\_UniformRandomBitGenerator** \> **result\_type** **operator()** (**\_UniformRandomBitGenerator** &**\_\_urng**, const **param\_type** &\_\_p)\
 **param\_type** **param** () const\
 Returns the parameter set of the distribution.  **void** **param** (const **param\_type** &**\_\_param**)\
 Sets the parameter set of the distribution.  **void** **reset** ()\
 Resets the distribution state.

### Friends

bool **operator==** (const **uniform\_int\_distribution** &**\_\_d1**, const **uniform\_int\_distribution** &**\_\_d2**)\
 Return true if two uniform integer distributions have the same parameters.

## Detailed Description

### template\<typename \_IntType = int\>

class std::uniform\_int\_distribution\< \_IntType \>"Uniform discrete distribution for random numbers. A discrete random distribution on the range $\[min, max\]$ with equal probability throughout the range.

## Member Typedef Documentation

### template\<typename \_IntType = int\> typedef \_IntType std::uniform\_int\_distribution\< \_IntType \>::result\_type

The type of the range of the distribution.

## Constructor & Destructor Documentation

### template\<typename \_IntType = int\> std::uniform\_int\_distribution\< \_IntType \>::uniform\_int\_distribution ()` [inline]`

Constructs a uniform distribution object.

### template\<typename \_IntType = int\> std::uniform\_int\_distribution\< \_IntType \>::uniform\_int\_distribution (\_IntType \_\_a, \_IntType \_\_b = \_\_gnu\_cxx::\_\_int\_traits`<_IntType>::__max`)` [inline]`, ` [explicit]`

Constructs a uniform distribution object.

## Member Function Documentation

### template\<typename \_IntType = int\> result\_type std::uniform\_int\_distribution\< \_IntType \>::max () const` [inline]`

Returns the inclusive upper bound of the distribution range.

### template\<typename \_IntType = int\> result\_type std::uniform\_int\_distribution\< \_IntType \>::min () const` [inline]`

Returns the inclusive lower bound of the distribution range.

### template\<typename \_IntType = int\> template\<typename \_UniformRandomBitGenerator \> result\_type std::uniform\_int\_distribution\< \_IntType \>::operator() (\_UniformRandomBitGenerator & \_\_urng)` [inline]`

Generating functions.

References **std::uniform\_int\_distribution\< \_IntType \>::operator()()**.

Referenced by **std::uniform\_int\_distribution\< \_IntType \>::operator()()**.

### template\<typename \_IntType = int\> param\_type std::uniform\_int\_distribution\< \_IntType \>::param () const` [inline]`

Returns the parameter set of the distribution.

### template\<typename \_IntType = int\> void std::uniform\_int\_distribution\< \_IntType \>::param (const param\_type & \_\_param)` [inline]`

Sets the parameter set of the distribution.

**Parameters**

*\_\_param* The new parameter set of the distribution.

### template\<typename \_IntType = int\> void std::uniform\_int\_distribution\< \_IntType \>::reset ()` [inline]`

Resets the distribution state. Does nothing for the uniform integer distribution.

## Friends And Related Symbol Documentation

### template\<typename \_IntType = int\> bool operator== (const uniform\_int\_distribution\< \_IntType \> & \_\_d1, const uniform\_int\_distribution\< \_IntType \> & \_\_d2)` [friend]`

Return true if two uniform integer distributions have the same parameters.

## Author

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