std::unifor...distribution(3)

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

πŸ’– std::unifor...distribution(3) πŸ’–

okay so bestie, welcome to the C++ Standard Libary manual page for std::unifor...distribution(3) β€” and yes, we're keeping that exact spelling, periodt. This page is all about the std::uniform_real_distribution::uniform_real_distribution constructor, and it's giving "let me construct a new distribution object for u" energy. πŸ’…βœ¨


🌸 NAME 🌸

std::uniform_real_distribution::uniform_real_distribution β€” std::uniform_real_distribution::uniform_real_distribution

That's the constructor name, repeated exactly like the original, no cap. 🫢


πŸ¦‹ Synopsis πŸ¦‹

lowkey the whole synopsis is right here, bestie β€” copy it exactly, don't touch the RealType:

          uniform_real_distribution() : uniform_real_distribution(0.0) { }
       (1) (since C++11)
          explicit uniform_real_distribution( RealType a, RealType b = 1.0
       (2) (since C++11)
          );
          explicit uniform_real_distribution( const param_type& params );
       (3) (since C++11)

Constructs a new distribution object.

  1. Uses a and b as the distribution parameters.
  2. Uses params as the distribution parameters.

✨ Parameters ✨

  • a β€” the a distribution parameter (minimum value).
  • b β€” the b distribution parameter (maximum value).
  • params β€” the distribution parameter set.

🫢 Notes 🫢

Requires that a ≀ b and b - a ≀ std::numeric_limits<RealType>::max().

bestie, if a == b, subsequent calls to the operator() overload that does not accept a param_type object will cause undefined behavior. That's not a vibe check you wanna fail. πŸ’€

To create a distribution over the closed interval [a,b], std::nextafter(b, std::numeric_limits<RealType>::max()) may be used as the second parameter.

πŸŽ€ Defect reports πŸŽ€

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

The columns are DR, Applied to, Behavior as published, and Correct behavior:

  • P0935R0 β€” applied to C++11; behavior as published: default constructor was explicit; correct behavior: made implicit.

source/version: http://cppreference.com Β· date: 2024.06.10 Β· page: std::unifor...distribution(3) β€” mwah, slay, bye bestie πŸ’‹πŸŽ€βœ¨

πŸ“¦ where this page comes from