我正在尝试编译取自的代码 std::this_thread::sleep_for()
#include <iostream>
#include <chrono>
#include <thread>
int main()
{
using namespace std::chrono_literals;
std::cout << "Hello waiter" << std::endl; // flush is intentional
auto start = std::chrono::high_resolution_clock::now();
std::this_thread::sleep_for(2s);
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> elapsed = end-start;
std::cout << "Waited " << elapsed.count() << " ms\n";
}
当我尝试编译代码时,我收到以下错误
错误:'std :: this_thread'尚未声明
我的GCC版本是6.3.0。
我怎么编译?任何的想法?