std::unifor...::operator()(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸŽ€ std::unifor...::operator() πŸŽ€

okay bestie, welcome to the C++ Standard Libary manual page for std::uniform_int_distribution::operator() β€” yes, the header is all truncated like std::unifor...::operator()(3), but the full name is right down below. It’s giving β€œI’m a template operator and I know it” energy πŸ’…βœ¨


🌸 NAME 🌸

std::uniform_int_distribution::operator() β€” std::uniform_int_distribution::operator().

Yes, that’s the name repeated. Iconic. We move. πŸ’–

✨ Synopsis ✨

Two template flavors, both (since C++11) β€” here’s the exact synopsis, bestie:

          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 );

So what do these do? They generate random numbers that are distributed according to the associated probability function. The entropy is acquired by calling g.operator(). Version (1) uses the associated parameter set; version (2) uses params. The associated parameter set is not modified β€” important vibe check, no sneaky edits. 🫢

πŸ¦‹ Parameters πŸ¦‹

  • g β€” a uniform random bit generator object.
  • params β€” distribution parameter set to use instead of the associated one. Slay.

πŸ‘‘ Type requirements πŸ‘‘

  • Generator must meet the requirements of UniformRandomBitGenerator. That’s the whole requirement, bestie β€” no cap. ✨

πŸ“ Return value πŸ“

The generated random number. Periodt. πŸ’–

🌈 Complexity 🌈

Amortized constant number of invocations of g.operator(). So it’s chillin’ at amortized constant β€” literally what the page says. πŸ’…


source/version: cppreference.com Β· date: 2024.06.10 β€” bye bestie, go generate something cute πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from