std::linear...ntial_engine(3)
๐ธ std::linear...ntial_engine(3) ๐ธ
okay bestie, this is the manual page for std::linear...ntial_engine(3) from the C++ Standard Libary โ and yes, thatโs literally how the header spells it, no cap ๐. Weโre folding the manual name in right here so you know what universe weโre in: C++ Standard Library constructor territory, and itโs giving very specific seed energy โจ.
๐ NAME ๐
std::linear_congruential_engine::linear_congruential_engineโ akastd::linear_congruential_engine::linear_congruential_engine. The NAME section really said โsay it twice, itโs iconicโ ๐ .
โจ Synopsis โจ
Hereโs the synopsis exactly as the page lays it out, annotations and all โ do not come for me about the formatting, Iโm just the messenger ๐ซถ:
linear_congruential_engine() : (1)
(since C++11)
linear_congruential_engine(default_seed) {}
explicit linear_congruential_engine( result_type value ); (2)
(since C++11)
template< class SeedSeq > (3)
(since C++11)
explicit linear_congruential_engine( SeedSeq& seq );
linear_congruential_engine( const linear_congruential_engine&
(since C++11)
other ); (4)
(implicitly
declared)
So whatโs the vibe? It constructs the pseudo-random number engine. Thatโs the whole main-character job ๐ซ.
- The default constructor. Thatโs it. Thatโs the tweet โจ.
- Constructs the engine with a seed value
value. The engineโs initial state is determined like this:- If
c % m == 0andvalue % m == 0are both true, the state is1. - Otherwise, the state is
value % m.
- If
- Constructs the engine with a seed sequence
seq. Givenstd::size_t(std::log2(m) / 32) + 1ask, the engineโs initial state is determined like this:- Creates an invented array object
aof lengthk + 3. - Calls
seq.generate(a + 0, a + k + 3). - Let
Sbe ((\sum^{k-1}_{j=0} a_{j+3} \cdot 2^{32j}) \mod m) โ and the page also shows the rendered form(โk-1 j=0 a j+3ยท232j ) mod m. - If both
c % m == 0andS == 0are true, sets the engineโs state to1. Otherwise, sets the engineโs state toS.
- Creates an invented array object
This overload participates in overload resolution only if SeedSeq meets the requirements of SeedSequence ๐.
- The copy constructor. Upon construction,
*this == otheris true. Copy constructor ate, no crumbs ๐ .
๐ Parameters ๐
valueโ seed value to use in the initialization of the internal state.seqโ seed sequence to use in the initialization of the internal state.
๐ฆ Complexity ๐ฆ
1, 2) Constant.
- Same as the complexity of the
seq.generatecall. - Constant.
๐ฉน Defect reports ๐ฉน
The following behavior-changing defect reports were applied retroactively to previously published C++ standards โ yes, they went back and edited the lore ๐ญ:
- DR:
P0935R0 - Applied to: C++11
- Behavior as published: the default constructor was
explicit - Correct behavior: made
implicit
๐ฅ See also ๐ฅ
seedโ sets the current state of the engine(C++11)(public member function).
source/version: cppreference.com ยท date: 2024.06.10 ยท page stamp: std::linear...ntial_engine(3) โ bye bestie, go seed something iconic ๐โจ๐
๐ฆ 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