std::seed_seq
From cppreference.com
C++
Numerics library
Common mathematical functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Mathematical special functions (C++17) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Mathematical constants (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Basic linear algebra algorithms (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Data-parallel types (SIMD) (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Floating-point environment (C++11) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Complex numbers | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Numeric array (valarray ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Pseudo-random number generation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Bit manipulation (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Factor operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Interpolations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Saturation arithmetic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Generic numeric operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Pseudo-random number generation
|
|
std::seed_seq
Member functions | ||||
Defined in header <random>
|
||
class seed_seq; |
(since C++11) | |
std::seed_seq
It provides a way to seed a large number of random number engines or to seed a generator that requires a lot of entropy, given a small seed or a poorly distributed initial seed sequence.
std::seed_seq
meets the requirements of SeedSequence
Nested types
Type | Definition |
result_type
|
std::uint_least32_t |
Data members
Member | Description |
std::vector<result_type>
v
|
the underlying seed sequence (exposition-only member object* |
Member functions
constructs and seeds the std::seed_seq object (public member function) |
|
operator= [deleted] |
std::seed_seq is not assignable (public member function) |
calculates the bias-eliminated, evenly distributed 32-bit values (public member function) |
|
obtains the number of stored 32-bit values (public member function) |
|
copies all stored 32-bit values (public member function) |
Example
Run this code
#include <cstdint> #include <iostream> #include <random> int main() { std::seed_seq seq{1, 2, 3, 4, 5}; std::vector<std::uint32_t> seeds(10); seq.generate(seeds.begin(), seeds.end()); for (std::uint32_t n : seeds) std::cout << n << '\n'; }
Possible output:
4204997637 4246533866 1856049002 1129615051 690460811 1075771511 46783058 3904109078 1534123438 1495905678