//-----------------------------------------------------------------
// 计算 hash 值,返回的 hash 值数据类型是 uint64_t
#include <iostream>
#include <string>
#include <functional>
int main()
{
std::string s = "Stand back! I've got jimmies!";
std::cout << std::hash<std::string>{}(s) << '\n';
}
//-----------------------------------------------------------------------------
// 功能1:给字符串添加双引号和斜杠
// 功能2:剔除字符串中的双引号和斜杠
#include <iostream>
#include <iomanip>
#include <sstream>
int main()
{
std::stringstream ss;
std::string in = "String with spaces, and embedded \"quotes\" too";
std::string out;
// 给字符串添加双引号和斜杠
ss << std::quoted(in);
// 剔除字符串中的双引号和斜杠
ss >> std::quoted(out);
}
//----------------------------------------------------------------------------
// std::setw() 设置缩进字符数量
// std::setfill() 设置缩进字符
std::cout << std::setw(4) << j_object << "\n\n";
std::cout << std::setw(2) << j_array << "\n\n";
std::cout << std::setw(1) << std::setfill('\t') << j_object << "\n\n";
//----------------------------------------------------------------------------
// 获取 CPU 硬核数量
int max_thread_num = std::thread::hardware_concurrency();
原文链接: https://www.cnblogs.com/micemik/p/12254635.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;
也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/326822
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!