std:: seed_seq
From cppreference.net
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) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Saturation arithmetic (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Factor operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Interpolations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Generic numeric operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| C-style checked integer arithmetic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Pseudo-random number generation
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::seed_seq
| Member functions | ||||
|
헤더에 정의됨
<random>
|
||
|
class
seed_seq
;
|
(C++11부터) | |
std::seed_seq
는 정수형 데이터 시퀀스를 입력받아 이를 기반으로 요청된 개수의 32비트 부호 없는 정수 값을 생성합니다. 입력된 값들이 서로 가깝더라도 생성된 값들은 전체 32비트 범위에 걸쳐 균등하게 분포됩니다.
적은 시드 또는 불균일하게 분포된 초기 시드 시퀀스가 주어졌을 때, 많은 수의 난수 엔진을 시드하거나 많은 엔트로피를 필요로 하는 생성기를 시드하는 방법을 제공합니다.
std::seed_seq
는
SeedSequence
요구 사항을 충족합니다.
목차 |
중첩 타입
| 유형 | 정의 |
result_type
|
std::uint_least32_t |
데이터 멤버
| 멤버 | 설명 |
std::
vector
<
result_type
>
v
|
기반 시드 시퀀스
( 설명 전용 멤버 객체* ) |
멤버 함수
std::seed_seq
객체를 생성하고 시드 설정
(public member function) |
|
|
operator=
[deleted]
|
std::seed_seq
는 할당 불가능
(public member function) |
|
편향이 제거된 균일 분포 32비트 값 계산
(public member function) |
|
|
저장된 32비트 값의 개수 획득
(public member function) |
|
|
저장된 모든 32비트 값 복사
(public member function) |
예제
이 코드 실행
#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'; }
가능한 출력:
4204997637 4246533866 1856049002 1129615051 690460811 1075771511 46783058 3904109078 1534123438 1495905678