Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class Duration>
- auto random_duration(Duration low, Duration high) noexcept -> Duration {
- static auto rd = std::random_device();
- static auto re = std::default_random_engine(rd());
- auto dist = std::uniform_real_distribution<double>(0, 1);
- const auto off = std::chrono::duration<Duration>(dist(re) * (high - low));
- return low + off;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement