STD::UNIFORM_INT_DISTRIBUTION(3)
β¨ NAME β¨
std::uniform_int_distribution< _IntType > β ok bestie, this is the Uniform discrete distribution for random numbers π
It's a discrete random distribution on the range $[min, max]$ with equal probability throughout the range. Every value gets the same love, no favorites. periodt.
πΈ SYNOPSIS πΈ
#include <random>
π Classes π
struct param_type
π¦ Public Types π¦
typedef _IntType result_type
π Public Member Functions π
uniform_int_distribution ()β Constructs a uniform distribution object.uniform_int_distribution (_IntType __a, _IntType __b=__gnu_cxx::__int_traits< _IntType >::__max)β Constructs a uniform distribution object.uniform_int_distribution (const param_type &__p)template<typename _ForwardIterator, typename _UniformRandomBitGenerator> void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomBitGenerator &__urng)template<typename _ForwardIterator, typename _UniformRandomBitGenerator> void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomBitGenerator &__urng, const param_type &__p)template<typename _UniformRandomBitGenerator> void __generate (result_type *__f, result_type *__t, _UniformRandomBitGenerator &__urng, const param_type &__p)result_type a () constresult_type b () constresult_type max () constβ Returns the inclusive upper bound of the distribution range.result_type min () constβ Returns the inclusive lower bound of the distribution range.template<typename _UniformRandomBitGenerator> result_type operator() (_UniformRandomBitGenerator &__urng)β Generating functions.template<typename _UniformRandomBitGenerator> result_type operator() (_UniformRandomBitGenerator &__urng, const param_type &__p)param_type param () constβ Returns the parameter set of the distribution.void param (const param_type &__param)β Sets the parameter set of the distribution.void reset ()β Resets the distribution state.
π Friends π
bool operator== (const uniform_int_distribution &__d1, const uniform_int_distribution &__d2)β Return true if two uniform integer distributions have the same parameters.
π₯ Detailed Description π₯
template<typename _IntType = int>
class std::uniform_int_distribution< _IntType >
"Uniform discrete distribution for random numbers. A discrete random distribution on the range $[min, max]$ with equal probability throughout the range.
Since: C++11
So yeah, it's been iconic since C++11 and it's not going anywhere π
π§ Member Typedef Documentation π§
template<typename _IntType = int> typedef _IntType std::uniform_int_distribution< _IntType >::result_type
The type of the range of the distribution. That's the whole vibe of it β it's the type your random numbers come out as β¨
π Constructor & Destructor Documentation π
template<typename _IntType = int> std::uniform_int_distribution< _IntType >::uniform_int_distribution () [inline]
Constructs a uniform distribution object. Default girlie, does exactly what it says on the tin.
template<typename _IntType = int> std::uniform_int_distribution< _IntType >::uniform_int_distribution (_IntType __a, _IntType __b = __gnu_cxx::__int_traits<_IntType>::__max) [inline], [explicit]
Constructs a uniform distribution object. This one takes your bounds, and heads up β __b defaults to __gnu_cxx::__int_traits<_IntType>::__max π«Ά
π Member Function Documentation π
template<typename _IntType = int> result_type std::uniform_int_distribution< _IntType >::max () const [inline]
Returns the inclusive upper bound of the distribution range. Inclusive, bestie, meaning that top value is in the club, not standing outside π
template<typename _IntType = int> result_type std::uniform_int_distribution< _IntType >::min () const [inline]
Returns the inclusive lower bound of the distribution range. Also inclusive, also invited to the party.
template<typename _IntType = int> template<typename _UniformRandomBitGenerator> result_type std::uniform_int_distribution< _IntType >::operator() (_UniformRandomBitGenerator & __urng) [inline]
Generating functions. This is the one you actually call to get a number, no cap.
Referenced by operator()().
template<typename _IntType = int> param_type std::uniform_int_distribution< _IntType >::param () const [inline]
Returns the parameter set of the distribution.
Referenced by std::operator>>().
template<typename _IntType = int> void std::uniform_int_distribution< _IntType >::param (const param_type & __param) [inline]
Sets the parameter set of the distribution.
Parameters
__paramβ The new parameter set of the distribution.
template<typename _IntType = int> void std::uniform_int_distribution< _IntType >::reset () [inline]
Resets the distribution state. And honestly? Does nothing for the uniform integer distribution. It's just out here living its best life, reset does literally nothing for this one π iconic behaviour honestly.
π«Ά Friends And Related Symbol Documentation π«Ά
template<typename _IntType = int> bool operator== (const uniform_int_distribution< _IntType > & __d1, const uniform_int_distribution< _IntType > & __d2) [friend]
Return true if two uniform integer distributions have the same parameters. Friendship check: passed β
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
And that's the whole page, bestie π this little beauty is libstdc++'s, and it lives under the header std::unifo... _IntType >(3) β Library Functions Manual energy all the way down. go forth and generate uniformly πβ¨π¦
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- centos-stream 10: gcc-toolset-15-libstdc++-docs 15.2.1-8.1.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- centos-stream 10: gcc-toolset-16-libstdc++-docs 16.2.1-1.3.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- centos-stream 10: libstdc++-docs 14.4.1-4.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 43: libstdc++-docs 15.2.1-2.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 43: libstdc++-docs 15.3.1-1.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms