std::unifor...it_generator(3)

πŸ“¦
version 2024.07.05 Β· 3 versions
, in nixpkgs unstable, opensuse-leap 16.0

🌟 NAME 🌟

Okay so bestie, this is the manual page for std::uniform_random_bit_generator β€” section 3 of the C++ Standard Library manual. It's literally the concept that tells you if something is a uniform random bit generator. No cap, it's iconic. πŸ’…


✨ Synopsis ✨

Defined in header <random> (so like, go include it, obviously):

template< class G >

concept uniform_random_bit_generator =
    std::invocable<G&> &&
std::unsigned_integral<std::invoke_result_t<G&>> &&
    requires {
(since C++20)
        { G::min() } -> std::same_as<std::invoke_result_t<G&>>;
        { G::max() } -> std::same_as<std::invoke_result_t<G&>>;
        requires std::bool_constant<(G::min() < G::max())>::value;

    };

So the concept uniform_random_bit_generator<G> is basically saying "G is the type of a uniform random bit generator." And what's that? It's a function object that returns unsigned integer values, where each value in the range of possible results has (ideally) equal probability of being returned. So like, fair and balanced, periodt. 🎲✨

πŸ¦‹ Semantic requirements πŸ¦‹

uniform_random_bit_generator<G> is modeled only if, given any object g of type G:

  • g() is in the range [G::min(), G::max()] β€” no outliers, bestie.
  • g() has amortized constant complexity β€” so it's fast, not doing the most.

πŸ’… Notes πŸ’…

In order to satisfy the requirement std::bool_constant<(G::min() < G::max())>::value, both G::min() and G::max() must be constant expressions, and the result of the comparison must be true. So like, don't sleep on that β€” it's giving compile-time energy. πŸ”₯


That's the whole vibe. This page was brought to you by cppreference.com, dated 2024.06.10 β€” stay slaying, bestie! πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from