c++ - C++中有通用的 sleep 和通用的暂停命令吗?

标签 c++ linux windows macos

我正在寻找一个通用的 sleep 命令以及一个通用的 C++ 暂停命令。它需要适用于 Windows、MAC 和 Linux 计算机。如果有人知道任何出色的可移植性命令,请告诉我。

最佳答案

C++ 11 有

std::this_thread::sleep_for(std::chrono::milliseconds(1000));

C++14有

using namespace std::literals;
std::this_thread::sleep_for(1000ms);

正如@Creris 提到的,Boost 是否涵盖了 Win32 和具有 pthread 的平台上的 C++03

boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));

关于c++ - C++中有通用的 sleep 和通用的暂停命令吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26493333/

相关文章:

linux - libapache2-mod-mono 在 apt-get 安装期间不会配置

linux - 在 shell 中使用 "for"迭代文件中的行从不匹配目标

windows - win32 PE 加密器 = 防病毒误报

windows - 如何 : Multiple versions of msvcrt9 as private SxS assemblies?

linux - Ksh 脚本 : How to remain in ssh and continue the script

python - 检查 *some* 用户是否存在于 Linux 或 Windows 中的可移植方法?

c++ - Visual Studio 2013 : fatal error C1083: Cannot open include file: 'winsock2.h' : No such file or directory

c++ - 用静态库替换dll

c++ - 在位图上并发腐 eclipse 或膨胀

c++ - 在 .h 文件外编写输出运算符重载的实现