会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
czw-yibao
博客园
首页
新随笔
联系
订阅
管理
2025年12月7日
简易实现枚举类型到字符串
摘要: // 简易实现枚举类型到字符串 #include <array> #include <string> #include <utility> #include <string_view> template <typename E, E V> constexpr auto PrettyName() {
阅读全文
posted @ 2025-12-07 23:44 皮卡啰
阅读(2)
评论(0)
推荐(0)
2024年9月28日
C++遍历结构体中的属性
摘要: #include <iostream> #include <type_traits> #include <unordered_map> #include <variant> using namespace std; struct Person{ std::size_t age; std::size_
阅读全文
posted @ 2024-09-28 01:50 皮卡啰
阅读(295)
评论(0)
推荐(0)
2024年7月22日
C++模板元编程学习
摘要: C++模板元编程学习 https://borehole.blog.csdn.net/article/details/128077440
阅读全文
posted @ 2024-07-22 01:38 皮卡啰
阅读(8)
评论(0)
推荐(0)
2022年11月7日
字符串分割
摘要: 1. 将字符串以特定字符进行分割,例如将 "usr/local/lib64" 以 "/" 进行分割 vector<string> Split(const string& str) { stringstream ss(str); vector<string> res; string substr; w
阅读全文
posted @ 2022-11-07 19:46 皮卡啰
阅读(315)
评论(0)
推荐(0)
2022年10月30日
C++中的explicit
摘要: C++中的 explicit 关键字只能用于修饰只有一个参数的类构造函数, 它的作用是表明该构造函数是显示的; 而非隐式的, 跟它相对应的另一个关键字是implicit,意思是隐藏的,类构造函数默认情况下即声明为implicit(隐式); explicit 关键字的作用就是防止类构造函数的隐式自动转
阅读全文
posted @ 2022-10-30 21:11 皮卡啰
阅读(289)
评论(0)
推荐(0)
2022年10月23日
实现一个shell命令
摘要: 首先创建一个 main.c 文件(/home/tom/demon),该文件实现加法运算,代码如下: #include <stdio.h> #include <unistd.h> #include <getopt.h> #include <stdlib.h> int main(int argc, ch
阅读全文
posted @ 2022-10-23 23:59 皮卡啰
阅读(39)
评论(0)
推荐(0)
从本地往虚拟机里传输文件
摘要: SCP命令 命令格式如下: scp + 要上传的文件 + hadoop(虚拟机名)@192.168.3.20(ip):~/下载 (这里冒号后面跟的是虚拟机中的上传路径) 举例如下:将本机上的文件传输到虚拟机上的 /home/tom/demon 处 scp "C:\Users\Administrato
阅读全文
posted @ 2022-10-23 23:00 皮卡啰
阅读(431)
评论(0)
推荐(0)
2022年10月3日
理解 decltype
摘要: C++ 11 中,的主要用途大概是声明那些返回值型别依赖于形参型别的函数模板。 举个例子,如果我们想实现一个函数,其形参中包含一个容器(支持方括号下标语法),该函数会在返回下标操作前进行用户验证,同时要求函数的返回值型别必须与下标操作结果的返回值型别相同。 通常含有型别 T 的容器,其 operat
阅读全文
posted @ 2022-10-03 22:45 皮卡啰
阅读(421)
评论(0)
推荐(0)
auto型别推导
摘要: auto型别推导 auto型别推导就是模板型别推导。在模板型别推导和 auto型别推导之间可以建立起一一映射,它们之间也确实存在双向的算法变换。 以 rx 为例: int x = 27; const auto& rx = x; // x -> expr,auto -> T,const auto& -
阅读全文
posted @ 2022-10-03 10:09 皮卡啰
阅读(67)
评论(0)
推荐(0)
2022年10月2日
模板型别推导
摘要: 模板型别推导 下面代码表示:函数模板和函数调用(从 expr 来推导 T 和 ParamType 的型别)。 template<typename T> void func(ParamType param); // 函数模板的声明 func(expr); // expr:表达式,从 expr 来推导
阅读全文
posted @ 2022-10-02 00:44 皮卡啰
阅读(62)
评论(0)
推荐(0)
下一页
公告