convert seconds as double to std::chrono::duration?

Don’t do std::chrono::seconds(timeToSleep). You want something more like:

std::chrono::duration<double>(timeToSleep)

Alternatively, if timeToSleep is not measured in seconds, you can pass a ratio as a template parameter to duration. See here (and the examples there) for more information.

Leave a Comment