#include <unordered_set>
#include <stdio.h>
int hcount=0;
struct A{
int i=0;
A(){}
A(const A&a) :i(a.i){}
A(int const & i):i(i) {
printf("A ctor i=%d\n", i);
}
A&operator=(A &&a){
this->i= a.i;
return (*this);
}
bool operator==(A const &rhs) const {
printf("A optor== i=%d\n", this->i);
return rhs.i == this->i;
}
};
namespace std{
template<>
struct hash<A> {
hash() {
hcount=0;
}
hash(int t) {
hcount=t;
}
std::size_t operator()(A const &a) const {
++hcount;
printf("hash: hcount=%d a.i=%d\n", hcount, a.i);
return a.i;
};
};
}
int …Run Code Online (Sandbox Code Playgroud) 我尝试nanosleep()使用 C++14编译以下调用代码,但失败并出现错误:
'nanosleep' 未在此范围内声明
nanosleep(&ts, NULL);
'nanosleep' was not declared in this scope
nanosleep(&ts, NULL);
与-DNDEBUG -O3 -DNDEBUG -o -c nanosleep-test.cpp -std=c++14 -fPIC -Wall -Wpedantic -Werror. 删除-std=c++14,我编译了它。那么说 C++14 删除了nanosleep()是否正确?