std::unifor...it_generator(3)
π 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
- 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