随笔分类 - C++
摘要:1、宏定义 #define EnumToStr(val) #val 2、使用 enum { Enum1 = 0, ENUM2 }; std::cout<<EnumToStr(Enum1);
阅读全文
摘要:https://zhuanlan.zhihu.com/p/58166572
阅读全文
摘要:1、现象 t还是空指针 2、解决 参考:https://blog.csdn.net/LYAJJ/article/details/110263038
阅读全文
摘要:https://www.cnblogs.com/lidabo/p/7783359.html
阅读全文
摘要:https://blog.csdn.net/starlee/article/details/1430387
阅读全文
摘要:1、下载sqlite3 地址:https://www.sqlite.org/download.html 2、将文件放到linux里 3、解压 tar -zvxf sqlite-autoconf-3360000.tar.gz 4、进入文件夹,分别执行 ./configure make sudo mak
阅读全文
摘要:1、概念 template<typename _Tp> constexpr typename std::remove_reference<_Tp>::type&& move(_Tp&& __t) noexcept { return static_cast<typename std::remove_r
阅读全文
摘要:1、作用 用于代表后续函数、变量、表达式是常量的 2、修饰变量 constexpr 修饰变量,从而使该变量获得在编译阶段即可计算出结果的能力。 #include <iostream> using namespace std; int main() { constexpr int num = 1 +
阅读全文
摘要:1、下载jsoncpp源码 https://github.com/open-source-parsers/jsoncpp 要注意版本 2、解压 3、使用python生成直接使用的源码 使用python执行脚本 4、生成dist文件夹 这就是可直接使用的源码 5、使用Qt新建工程,加入文件夹路径 6、
阅读全文
摘要:1、左值和右值的概念 左值是可以放在赋值号左边可以被赋值的值;左值必须要在内存中有实体; 右值当在赋值号右边取出值赋给其他变量的值;右值可以在内存也可以在CPU寄存器。【右值可以理解为临时变量】 一个对象被用作右值时,使用的是它的内容(值),被当作左值时,使用的是它的地址。 2、引用 引用是C++语
阅读全文
摘要:一、概念 原型: template<typename _Tp> constexpr _Tp&& forward(typename std::remove_reference<_Tp>::type& __t) noexcept { return static_cast<_Tp&&>(__t); } t
阅读全文
摘要:一、move的概念 1、在学习move之前需要知道左值、右值、左值引用、右值引用的概念,见:https://www.cnblogs.com/judes/p/15159463.html 学习之后需要知道一个重点: 移动构造不进行深拷贝,直接使用右值的资源。【move是用来服务于此重点的】 2、概念 m
阅读全文
摘要:一、使用C++11 封装类 // Connect.hpp #ifndef _CONNECT_H #define _CONNECT_H #include <vector> #include <memory> #include <functional> #define emit #define slot
阅读全文
摘要:1、静态函数 std::string Config::getCurTimeStr() { std::string ret; time_t timep; struct tm *p; time(&timep); p = localtime(&timep); printf("\n", 1900 + p->
阅读全文
摘要:代码: #include <io.h> std::vector<std::string> StoreActionServer::getFolderList(const std::string &path) { std::vector<std::string> folderList; //文件句柄 l
阅读全文
摘要:代码: static std::string trim(std::string s) { std::string ret = ""; if(s.empty()){ return ret; } std::cout<<s.find("\t")<<1111; for(size_t i=0; i<s.siz
阅读全文
摘要:1、头文件 #include <unistd.h> 2、使用 sleep(1); //1秒 usleep(100); //微秒
阅读全文
摘要:C: #include <string.h> 提供字符串操作函数 C++: #include <string> 提供一个字符串类,string
阅读全文
摘要:1、string转char* ①、string.c_str()返回一个以'\0'结尾的字符数组; ②、string.data()仅返回字符串内容,而不含有结束符'\0'。 2、char数组转string char ch[]="hello world!"; string str(ch);或者 stri
阅读全文