std::experimental::randint(3)
π std::experimental::randint(3) π
okay so bestie, this is a C++ Standard Library man page, section 3, and the manual name is literally std::experimental::randint(3) β folding that in right here so you know exactly what's up. π«Ά
πΈ NAME πΈ
std::experimental::randintβstd::experimental::randint, no cap. π
β¨ Synopsis β¨
Defined in header <experimental/random>:
template< class IntType > (library fundamentals TS v2)
IntType randint( IntType a, IntType b );
Generates a random integer in the closed interval [a, b]. it's giving random but make it official. π
π Parameters π
a,bβ integer values specifying the range. yes bestie, both of them are integers, and together they set the range. π
π«Ά Return value π«Ά
A random integer i in the closed interval [a, b], produced using a thread-local instance of std::uniform_int_distribution<IntType> invoked with the per-thread random number engine. literally random, but scoped to your thread, iykyk. β¨
π Remarks π
- If
IntTypeis not one ofshort,int,long,long long,unsigned short,unsigned int,unsigned long, orunsigned long long, the program is ill-formed. no cap, those are the only approved types. π« - The behavior is undefined if
a > b. so do NOT letabe bigger thanbβ that's undefined behavior territory, and we do not stan that. π
π Example π
// Run this code β yes, go run it bestie:
#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
π See also π
reseedβ reseeds the per-thread random engine (function). so if you need a fresh vibe, that's your girl. π
mwah π β source/version/date: http://cppreference.com, 2024.06.10, and this iconic page is std::experimental::randint(3). periodt. π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms