Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. template <class Duration>
  2. auto random_duration(Duration low, Duration high) noexcept -> Duration {
  3. static auto rd = std::random_device();
  4. static auto re = std::default_random_engine(rd());
  5. auto dist = std::uniform_real_distribution<double>(0, 1);
  6. const auto off = std::chrono::duration<Duration>(dist(re) * (high - low));
  7. return low + off;
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement