-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtsg.h
More file actions
22 lines (19 loc) · 667 Bytes
/
Copy pathtsg.h
File metadata and controls
22 lines (19 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef THREAD_SEEDED_GEN_H__
#define THREAD_SEEDED_GEN_H__
#include <thread>
#include <utility>
#include <cstdio>
namespace tsg {
template<typename RNG>
struct ThreadSeededGen: public RNG {
template<typename...Args>
ThreadSeededGen(Args &&...args): RNG(std::forward<Args>(args)...) {
this->seed(std::hash<std::thread::id>{}(std::this_thread::get_id()));
}
template<typename...Args>
decltype(auto) operator()(Args &&...args) {return RNG::operator()(std::forward<Args>(args)...);}
template<typename...Args>
decltype(auto) operator()(Args &&...args) const {return RNG::operator()(std::forward<Args>(args)...);}
};
} // tsg
#endif