Reputation: 183
Let's say I have a variable int x = 2000
and I want to make a thread sleep for 'x milliseconds'. How do I combine the chrono literal ms
with x
?
I tried stuff like this:
std::this_thread::sleep_for((x)ms);
std::this_thread::sleep_for(xms);
Thank you for your time!
Upvotes: 2
Views: 1701
Reputation: 183
Thanks to @DeiDei:
std::this_thread::sleep_for(std::chrono::milliseconds(x))
fixed my problem!
Upvotes: 5