aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/src/mpt/random/seed.hpp
blob: e6ca4bd5e4d632603b9973aa3ac744a5d6b0e25d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* SPDX-License-Identifier: BSL-1.0 OR BSD-3-Clause */

#ifndef MPT_RANDOM_SEED_HPP
#define MPT_RANDOM_SEED_HPP



#include "mpt/base/namespace.hpp"

#include <array>
#include <random>

#include <cstddef>


namespace mpt {
inline namespace MPT_INLINE_NS {



template <std::size_t N>
class seed_seq_values {
private:
	std::array<unsigned int, N> seeds;

public:
	template <typename Trd>
	explicit seed_seq_values(Trd & rd) {
		std::uniform_int_distribution<unsigned int> random_int{};
		for (std::size_t i = 0; i < N; ++i) {
			seeds[i] = random_int(rd);
		}
	}
	const unsigned int * begin() const {
		return seeds.data();
	}
	const unsigned int * end() const {
		return seeds.data() + N;
	}
};



} // namespace MPT_INLINE_NS
} // namespace mpt



#endif // MPT_RANDOM_SEED_HPP