std::experimental::randint

Header: <experimental/random>

Generates a random integer in the closed interval [a, b].

# Declarations

template< class IntType >
IntType randint( IntType a, IntType b );

(library fundamentals TS v2)

# Parameters

# Return value

A random integer i in the closed interval [a, b], produced using a thread-local instance of std::uniform_int_distribution invoked with the per-thread random number engine.

# Example

#include <experimental/random>
#include <iostream>
 
int main()
{
    int random_number = std::experimental::randint(100, 999);
    std::cout << "random 3-digit number: " << random_number << '\n';
}

# See also