代码:
//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's free, open source, time zone library 来体验这个 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);
}
关于c++ - 为什么错误: ‘locate_zone’ is not a member of ‘std::chrono’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50204405/