linux系统gettime获取的时间.
int clock_gettime(clockid_t clk_id,struct timespec *tp);
//CLOCK_REALTIME:系统相对时间,从UTC 1970-1-1 0:0:0开始计时,更改系统时间会更改获取的值;
//CLOCK_MONOTONIC:系统绝对时间/单调时间,为系统重启到现在的时间,更改系统时间对它没有影响;
//CLOCK_PROCESS_CPUTIME_ID:本进程到当前代码系统CPU花费的时间;
//CLOCK_THREAD_CPUTIME_ID:本线程到当前代码系统CPU花费的时间;
struct timespec ts {};
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
(ts.tv_sec*1000) + (ts.tv_nsec/1000000);
C++ 去掉字符串中的空白:
string.erase(std::remove_if(string.begin(), string.end(), [](unsigned char x){return std::isspace(x)};), string.end());
C++ 字符串中分割:
std::vector<std::string> Splitstring(const std::string& in, const std::string& delim)
{
std::regex re{delim};
std::vector<std::string>ret(
std::sregex_token_iterator(in.begin(), in.end(), re, -1),
std::sregex_token_iterator());
return ret;
}