zoukankan      html  css  js  c++  java
  • 基础知识之C++篇

    //-----------------------------------------------------------------
    // 计算 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) << ' ';
    }
     
    //-----------------------------------------------------------------------------
    // 功能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 << " ";
    std::cout << std::setw(2<< j_array << " ";
    std::cout << std::setw(1<< std::setfill(' '<< j_object << " ";
     
    //----------------------------------------------------------------------------
    // 获取 CPU 硬核数量
    int max_thread_num = std::thread::hardware_concurrency();

  • 相关阅读:
    http缓存机制与原理
    BFC与浮动
    05ICMP协议与ARP协议(IP协议中重要协议)
    04IP编址(网络层)
    03以太网帧结构(链路层 IEEE802.3)
    02传输介质简介
    shell 脚本 2
    shell 脚本 1
    shell 中时间 表达
    sed 行编辑器
  • 原文地址:https://www.cnblogs.com/micemik/p/12254635.html
Copyright © 2011-2022 走看看