I do not understand how you are supposed to scale a std::chrono::duration
. What is the correct way to scale a duration by a floating point number?
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;
}