Technical Specification | ||||
Filesystem library(filesystem TS) | ||||
Library fundamentals(library fundamentals TS) | ||||
Library fundamentals 2(library fundamentals TS v2) | ||||
Library fundamentals 3(library fundamentals TS v3) | ||||
Extensions for parallelism(parallelism TS) | ||||
Extensions for parallelism 2(parallelism TS v2) | ||||
Extensions for concurrency(concurrency TS) | ||||
Extensions for concurrency 2(concurrency TS v2) | ||||
Concepts(concepts TS) | ||||
Ranges(ranges TS) | ||||
Reflection(reflection TS) | ||||
Mathematical special functions(special functions TR) | ||||
Experimental Non-TS | ||||
Pattern Matching | ||||
Linear Algebra | ||||
std::execution | ||||
Contracts | ||||
2D Graphics |
experimental::randint | ||||
Defined in header <experimental/random> | ||
template<class IntType> IntType randint( IntType a, IntType b); | (library fundamentals TS v2) | |
Generates a random integer in the closed interval[a, b]
.
Contents |
a, b | - | integer values specifying the range |
A random integeri in the closed interval[a, b]
, produced using a thread-local instance ofstd::uniform_int_distribution<IntType> invoked with theper-thread random number engine.
IfIntType
is not one ofshort,int,long,longlong,unsignedshort,unsignedint,unsignedlong, orunsignedlonglong, the program is ill-formed.
The behavior is undefined ifa> b.
#include <experimental/random>#include <iostream> int main(){int random_number= std::experimental::randint(100,999);std::cout<<"random 3-digit number: "<< random_number<<'\n';}
Possible output:
random 3-digit number: 273
reseeds the per-thread random engine (function)[edit] |