std::bernou...::operator()(3)
π NAME π
okay so bestie, this is the std::bernou...::operator()(3) page, and the manual it lives in is the C++ Standard Libary one (yes, βLibaryβ with one b β thatβs literally the header, not me typoing, iykyk π
). The star of the show is std::bernoulli_distribution::operator() β the NAME section says it twice, which is giving βintroduce yourself twice so they remember youβ energy. Periodt.
π Synopsis π
Two overloads, both since C++11, both cute, both doing the random-number thing:
template< class Generator > (1)
(since C++11)
result_type operator()( Generator& g );
template< class Generator > (2)
(since C++11)
result_type operator()( Generator& g, const param_type& params );
They generate random numbers distributed according to the associated probability function. The entropy is acquired by calling g.operator() β like, thatβs literally where the randomness comes from, no cap. β¨
Version (1) uses the associated parameter set. Version (2) uses params. And important: the associated parameter set is not modified. Leave her alone, sheβs not changing. π«Ά
π Parameters π
gβ a uniform random bit generator object π²paramsβ distribution parameter set to use instead of the associated one
π¦ Type requirements π¦
Generatormust meet the requirements ofUniformRandomBitGenerator. β
β Return value β
The generated random number. Thatβs it, thatβs the gift. π
π₯ Complexity π₯
Amortized constant number of invocations of g.operator(). So, like, on average itβs not doing a whole saga in there. π
Source/version and date, per the footer: http://cppreference.com, 2024.06.10, and the page tag is std::bernou...::operator()(3). Cute little sign-off, mwah ππ
π¦ 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