I'm writing a program in C++, and at one part I want the program to sleep for 1 second. I'm using the following expression to be platform independent:
std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(1000));
This line is way too long, so I want to use an alias for it. What is the best method to achieve this?
If you are using >=c++14 there are literal chrono helpers. It is possible to write:
using namespace std::chrono_literals;
std::this_thread::sleep_for(1s);
std::this_thread::sleep_for(1min);