Wildmeshing Toolkit
Loading...
Searching...
No Matches
random_seed.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <random>
4
5namespace wmtk::utils {
6
8{
9public:
11 {
12 static RandomSeedSingleton _instance;
13 return _instance;
14 }
15
16 inline void set_seed(uint64_t val) { m_gen.seed(val); std::srand(val); }
17 inline unsigned int get_seed() { return m_gen(); }
18
19private:
21 {
22 std::random_device rd;
23 set_seed(rd());
24 }
25
26 std::mt19937 m_gen;
27};
28
29
30inline unsigned int get_random_seed()
31{
32 return RandomSeedSingleton::instance().get_seed();
33}
34
35inline void set_random_seed(uint64_t val)
36{
37 RandomSeedSingleton::instance().set_seed(val);
38}
39
40} // namespace wmtk::utils
static RandomSeedSingleton & instance()
unsigned int get_random_seed()
void set_random_seed(uint64_t val)