为什么错误:"locate_zone"不是"std::chrono"的成员



代码:

//test.cpp
#include<chrono>
#include<string>
using namespace std;
int main(){
string str("Europe/Oslo");
std::chrono::locate_zone(str);
}

编译:

/tools/gcc/6.3.0/bin/g++ --std=c++11 test.cpp

输出:

test.cpp: In function ‘int main()’:

test.cpp:6:3:错误:"locate_zone"不是"std::chrono"的成员 std::chrono::locate_zone(str(; ^~~

您今天可以使用 Howard Hinnant 的免费开源时区库来试验这个 C++20 功能。

您需要将命名空间从std::chrono更改为date

#include "date/tz.h"
#include<chrono>
#include<string>
using namespace std;
int main(){
string str("Europe/Oslo");
date::locate_zone(str);
}

需要一些安装。

可以提供帮助。

最新更新