上一页 1 2 3 4 5 6 7 8 ··· 21 下一页
摘要: 判断两个类型的关系 #include <iostream> #include <type_traits> using std::cout; using std::endl; // is_same is used to judge two data types same or not during c 阅读全文
posted @ 2022-07-25 17:52 Wangtn 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 讲算法原理的有很多,直接贴代码 dijkstra算法是直接对邻接矩阵进行操作求出最短路径的,我项目中的图结构需要转化成邻接矩阵,所以会有下面代码 图结构是一个map,first表示节点的index,second是一个结构体,包含节点的详细信息 map<int, node> routeTable; s 阅读全文
posted @ 2022-06-06 09:58 Wangtn 阅读(40) 评论(0) 推荐(0) 编辑
摘要: 编辑操作 i 在光标前插入 I 在行首插入 a 在光标后插入 A 在行尾插入 o 在当前光标下面多一空行插入 O 在当前光标上面多一空行插入 ciw 删除当前光标所在单词并插入 ci( 删除小括号内的内容并插入 ci[和ci{同样适用 u 撤销 在插入模式下按ctrl+w可以删除前面一个单词(同一种 阅读全文
posted @ 2022-05-23 09:23 Wangtn 阅读(42) 评论(0) 推荐(0) 编辑
摘要: 作用是减少函数输入参数,提高代码的复用率 #include <iostream> #include <vector> #include <list> #include <deque> // alias template // 别名模板 template <typename T> using Vec 阅读全文
posted @ 2022-04-12 10:57 Wangtn 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 目录结构 编译脚本build.sh if [ -d "./proto_code" ];then rm -rf ./proto_code fi mkdir ./proto_code protoc -I ./ --grpc_out=./proto_code --plugin=protoc-gen-grp 阅读全文
posted @ 2022-03-23 17:20 Wangtn 阅读(2440) 评论(0) 推荐(0) 编辑
摘要: 自己动手写一个grpc c++的demo,自己写protobuf文件,编译文件和源码 实现一个最简单的grpc功能,客户端向服务端发送一个消息,服务端接收到消息后把结果返回给客户端 demo的文件结构 首先定义proto文件 官方教程:https://developers.google.com/pr 阅读全文
posted @ 2022-03-22 18:05 Wangtn 阅读(3779) 评论(2) 推荐(0) 编辑
摘要: 线程库<pthread.h> 获取程序的进程号 getpid() cout<<"main function pid:"<<getpid()<<endl; 获取线程函数的线程号 #include <sys/types.h> cout<<"route thread function pid:"<<get 阅读全文
posted @ 2022-03-10 09:41 Wangtn 阅读(255) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <unistd.h> #include <string.h> #include <dirent.h> #include <stdlib.h> #include <limits.h> int main(void) { DIR *dir; stru 阅读全文
posted @ 2022-03-09 15:43 Wangtn 阅读(468) 评论(0) 推荐(0) 编辑
摘要: 将线程绑定到cpu指定核心可以避免线程函数在多个核心上执行,从而减少线程间通信的开销,也方便查看负载,便于比较不同线程之间负载是否均衡。 cpu的声明(变量类型)cpu_set_t 绑定进程主要是通过三个函数,这三个函数都是在线程函数里面调用的 CPU_ZERO(&cpu_size_t) cpu初始 阅读全文
posted @ 2022-02-21 16:47 Wangtn 阅读(7181) 评论(0) 推荐(0) 编辑
摘要: void func(void) {} struct Foo{ void operator()(void) {} }; struct Bar{ using fr_t=void (*)(void); static void func(void){} operator fr_t(void) { retur 阅读全文
posted @ 2022-02-10 14:10 Wangtn 阅读(51) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 21 下一页