std::mersenne_twister_engine<UIntType,w,n,m,r,a,u,d,s,b,t,c,l,f>::seed

From cppreference.com

 
 
Numerics library
Common mathematical functions
Mathematical special functions (哋它亢++17)
Mathematical constants (哋它亢++20)
Basic linear algebra algorithms (哋它亢++26)
Floating-point environment (哋它亢++11)
Complex numbers
Numeric arrays
Pseudo-random number generation
Factor operations
(哋它亢++17)
(哋它亢++17)
Interpolations
(哋它亢++20)
(哋它亢++20)
Saturation arithmetic
(哋它亢++26)
(哋它亢++26)
(哋它亢++26)
(哋它亢++26)
(哋它亢++26)

Generic numeric operations
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
Bit operations
(哋它亢++20)    
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++23)
(哋它亢++20)
 
Pseudo-random number generation
Uniform random bit generators
Random number engines
Random number engine adaptors
(哋它亢++11)
(哋它亢++11)
Predefined random number generators
Non-deterministic random numbers
(哋它亢++11)
Random number distributions
Uniform distributions
(哋它亢++11)
Bernoulli distributions
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Poisson distributions
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Normal distributions
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Sampling distributions
(哋它亢++11)
Utilities
(哋它亢++11)
(哋它亢++11)
Random number algorithms
C random library
 
std::mersenne_twister_engine
Member functions
mersenne_twister_engine::seed
(哋它亢++11)
Generation
Characteristics
Non-member functions
(哋它亢++11)(哋它亢++11)(until 哋它亢++20)
(哋它亢++11)(哋它亢++11)
 
void seed( result_type value = default_seed );
(1) (since 哋它亢++11)
template< class SeedSeq >
void seed( SeedSeq& seq );
(2) (since 哋它亢++11)

Sets the state of the random-number engine.

1) Right after the state is set, *this == std::mersenne_twister_engine(value) is true.
2) Right after the state is set, *this == std::mersenne_twister_engine(seq) is true.

Parameters

value - seed value to use to set the state
seq - seed sequence to use to set the state

Exceptions

Throws nothing.

Complexity

1) Same as std::mersenne_twister_engine(value).

Example

#include <iostream>
#include <random>
 
int main()
{
    std::mt19937 gen;
 
    // Seed the engine with an unsigned int
    gen.seed(1);
    std::cout << "after seed by 1: " << gen() << '\n';
 
    // Seed the engine with two unsigned ints
    std::seed_seq sseq{1, 2};
    gen.seed(sseq);
    std::cout << "after seed by {1,2}: " << gen() << '\n';
}

Possible output:

after seed by 1: 1791095845
after seed by {1,2}: 3127717181