得之我幸 失之我命

when someone abandons you,it is him that gets loss because he lost someone who truly loves him but you just lost one who doesn’t love you.

Cpp11 auto

c++11 中的 auto 是一个占位符,编译器在编译期间自动推导出变量的类型,并适当地改变结果类型使其更符合初始化规则,因此 auto 定义的变量必须有初始值

1
2
int x;
auto y; // error

Read More...


搭建 Git 服务器

1
2
3
4
5
$ mkdir test.git  # 创建 Git 资源的存储目录 test.git
$ git init --bare test.git # 在 test.git 目录中初始化 Git 的基本配置信息
# 添加系统用户和用户组,如 test_git:test_git_grp
$ chown -R test_git:test_git_grp test.git # -R :递归,表示递归 test.git 中的所有文件归属到指定用户 test_git 上
$ git clone test_git@7.7.7.7:/home/test_git/test.git test

Read More...


1
2
3
4
5
6
7
8
9
10
11
12
struct child
{
char name[10];
};
struct child she = { "Jerry" };

int main()
{
static struct child she1 = { "Jerry1" };
struct child she2 = { "Jerry2" };
return 0;
}

Read More...


Cpp17 variant

std::variant

std::variant 是 C++17 中一个新加入标准函式库的 template 容器,使用时需要 #include

它的概念基本上是和 union 一样,是一个可以用来储存多种型别资料的容器;和 union 不同的是,std::variant 是 type-safe 的,再加上有许多函数可以搭配使用,所以在使用上应该算是相对安全

由于它是标准函式库的 template class,在使用时不需要另外去宣告一个新的类型

std::variant 在储存数据的时候,内部会有一个索引值来记录目前存储的是哪一个类型的数据

Read More...


ln 命令用于给文件创建链接,链接的方式分为以下 2 种:

  1. 软链接:类似于 Windows 系统中给文件创建快捷方式,即产生一个特殊的文件,该文件用来指向另一个文件,此链接方式同样适用于目录
  2. 硬链接:文件的基本信息都存储在 inode 中,而硬链接指的就是给一个文件的 inode 分配多个文件名,通过任何一个文件名,都可以找到此文件的 inode,从而读取该文件的数据信息

Read More...


extern "c" 是什么

今天在看编译报错的时候发现一个神奇的 extern “C”

1
2
3
4
5
6
7
8
#ifdef __cplusplus
extern "C"
{
#endif
...
#ifdef __cplusplus
}
#endif

这是什么?我涉及的明明是 c++ 的工程,而且这个 extern 好像也不是单纯声明用的

Read More...


CRTP 简介

CRTP(Curiously Recurring Template Pattern)是 c++ 使用范型实现静态多态的方法,这种方法和虚拟函数比起来优点就是可以节省内存,不需要额外的空间存储 virtual table,并且提高运行速度,运行时不需要动态查找对应的函数

Read More...


the only present love demands is love