随笔分类 -  C++

1 2 3 4 5 ··· 11 下一页
摘要:说明 jcon-cpp 是一个用于 C++ 的 JSON-RPC 库,它允许开发者通过 JSON-RPC 协议进行进程间通信(IPC)。JSON-RPC 是一种轻量级的远程过程调用协议,基于 JSON 格式数据进行通信。基于MIT协议,最新代码基于Qt6实现。可通过Tcp和WebSocket实现RP 阅读全文
posted @ 2025-01-10 17:59 朱小勇 阅读(124) 评论(0) 推荐(0)
摘要:C++20引入了模块(Modules)的概念,这是一项重要的语言特性,旨在改进C++的编译速度和构建过程。模块提供了一种新的组织代码的方式,可以替代传统的头文件包含和预处理器。 使用模块可以带来以下几个好处: 更快的编译速度:传统的头文件包含方式在编译过程中需要进行大量的文件打开和文本处理操作,而模 阅读全文
posted @ 2024-11-12 09:39 朱小勇 阅读(128) 评论(0) 推荐(0)
摘要:1.代码 SetCursorPos(0, 0);//设置鼠标位置 INPUT input = {0}; input.type = INPUT_MOUSE; input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP; SendInput( 阅读全文
posted @ 2024-09-25 15:04 朱小勇 阅读(153) 评论(0) 推荐(0)
摘要:1.代码 #include <windows.h> #include <iostream> bool IsFileInUse(const std::wstring& filePath) { HANDLE hFile = CreateFileW( filePath.c_str(), GENERIC_R 阅读全文
posted @ 2024-09-09 22:49 朱小勇 阅读(155) 评论(0) 推荐(0)
摘要:1.现象 工程引入了工程外的C++类,编译失败 2.解决 引入外部源码时,只有引入头文件不会有异常,如果有CPP需要将源码加入到工程,只是include是不行的。 因为CPP需要编译,头文件不需要 阅读全文
posted @ 2024-03-13 11:39 朱小勇 阅读(15) 评论(0) 推荐(0)
摘要:https://zhuanlan.zhihu.com/p/268407438?utm_id=0 阅读全文
posted @ 2023-12-14 14:55 朱小勇 阅读(29) 评论(0) 推荐(0)
摘要:https://zhuanlan.zhihu.com/p/380856254 阅读全文
posted @ 2023-10-08 22:46 朱小勇 阅读(22) 评论(0) 推荐(0)
摘要:1.角度转复数,使用std::polar #include <iostream> #include <complex> #include <cmath> int main () { float theta = 45; float theta_pi = theta*(M_PI/180); std::c 阅读全文
posted @ 2023-10-06 18:29 朱小勇 阅读(243) 评论(0) 推荐(0)
摘要:1. #define MY_MACRO ... #ifdef MY_MACRO // 这部分代码会被预处理器处理 #else // 这部分代码会被预处理器忽略 #endif 2. int my_var = 1; #define MY_MACRO my_var ... #if defined(MY_M 阅读全文
posted @ 2023-09-06 15:11 朱小勇 阅读(20) 评论(0) 推荐(0)
摘要:1、代码 #include<iostream> #include<unordered_map> using namespace std; int main() { unordered_multimap<int, int> myUnorderedMultiMap = { {2, 10},{1, 20} 阅读全文
posted @ 2022-10-08 21:31 朱小勇 阅读(82) 评论(0) 推荐(0)
摘要:一、静态测试 1、CppCheck 2、Clang-tidy【linux】 二、动态测试 1、QTest 2、GTest 3、Boost Test 4、CodeViz【命令行】 5、CppTest【收费】 6、Insure++【linux】 7、Catch【hpp实现,提供几个宏】 阅读全文
posted @ 2022-08-11 19:42 朱小勇 阅读(531) 评论(0) 推荐(0)
摘要:1、函数式编程如std::bind、std::thread传参数等使用时,是对参数直接拷贝而不是引用 如: #include <functional> #include <iostream> void f(int& n1, int& n2, const int& n3) { std::cout << 阅读全文
posted @ 2022-05-31 15:32 朱小勇 阅读(179) 评论(0) 推荐(0)
摘要:1、功能 用一个从value递增的数列给[first, last)的容器赋值 2、实例 #include <iostream> #include <vector> #include <numeric> int main() { std::vector<int> nums(10); for (int 阅读全文
posted @ 2022-05-31 14:51 朱小勇 阅读(1366) 评论(0) 推荐(0)
摘要:1、如果在公共头文件includes.h里定义一个变量 int a; 2、其他头文件都包含了这个includes.h 会报错:a变量重复定义 3、原因 编译器会对头文件进行编译,每包含一次就会编译一次,故会报重定义。而CPP文件编译期间不会被编译,故不会出现这个问题 4、解决 定义成静态的 阅读全文
posted @ 2022-04-09 17:09 朱小勇 阅读(140) 评论(0) 推荐(0)
摘要:__VA_ARGS__ 是一个可变参数的宏,很少人知道这个宏,这个可变参数的宏是新的C99规范中新增的,目前似乎只有gcc支持(VC6.0的编译器不支持)。实现思想就是宏定义中参数列表的最后一个参数为省略号(也就是三个点) 阅读全文
posted @ 2022-03-24 17:04 朱小勇 阅读(310) 评论(0) 推荐(0)
摘要:#pragma message("this is message") 阅读全文
posted @ 2022-03-23 11:06 朱小勇 阅读(280) 评论(0) 推荐(0)
摘要:一、基本使用 0、描述 spd就是speed的缩写,代表速度,主要是由c++11写的。 支持异步回滚、单日记录、格式化等等; 不需要链接库或动态库,直接源码使用; 可创建多个不同的日志器; 1、在官网下载源码 https://github.com/gabime/spdlog 2、解压 include 阅读全文
posted @ 2022-03-19 21:58 朱小勇 阅读(2865) 评论(0) 推荐(0)
摘要:1、 bool isInt = std::is_same<int, int>::value; //为true std::cout << std::is_same<int, int32_t>::value << '\n'; // true std::cout << std::is_same<int, 阅读全文
posted @ 2022-03-13 14:13 朱小勇 阅读(245) 评论(0) 推荐(0)
摘要:1、C++14多了std::make_unique 2、C++14用auto推导函数返回值时,不需要使用decltype来配合使用 阅读全文
posted @ 2022-03-11 16:07 朱小勇 阅读(451) 评论(0) 推荐(0)
摘要:1、 int fun(int x) { return x + 1; } std::result_of<fun(int)>::type d = 100; // int 阅读全文
posted @ 2022-03-11 14:55 朱小勇 阅读(242) 评论(0) 推荐(0)

1 2 3 4 5 ··· 11 下一页