'Best way to alias expression

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?



Solution 1:[1]

As others have suggested, if you want an “alias” for that action, you can write a function for it. using and std::chrono’s helpers can go a long way, though:

using std::chrono::seconds;
using std::this_thread::sleep_for;
?
sleep_for(seconds(1));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1