Cpp index
[[C++]]
https://github.com/MeouSker77/Cpp17
CRTP https://zhuanlan.zhihu.com/p/137879448
CPP Learn¶
struct input_iterator_tag {};
struct output_iterator_tag {};
struct forward_iterator_tag : public input_iterator_tag {};
struct bidirectional_iterator_tag : public forward_iterator_tag {};
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
Lambda¶
[capture list] (params list) -> return type {function body}
[capture list] (params list) {function body}
[capture list] {function body}
| 格式 | |
|---|---|
| 1 | [capture list] (params list) -> return type {function body} |
| 2 | [capture list] (params list) {function body} |
| 3 | [capture list] {function body} |
| 捕获形式 | 说明 |
|---|---|
| [] | 不捕获任何外部变量 |
| [变量名, …] | 默认以值得形式捕获指定的多个外部变量(用逗号分隔),如果引用捕获,需要显示声明(使用&说明符) |
| [this] | 以值的形式捕获this指针 |
| [=] | 以值的形式捕获所有外部变量 |
| [&] | 以引用形式捕获所有外部变量 |
| [=, &x] | 变量x以引用形式捕获,其余变量以传值形式捕获 |
| [&, x] | 变量x以值的形式捕获,其余变量以引用形式捕获 |