Skip to content

Commit 4c4ad97

Browse files
authored
Merge pull request #52 from Mq-b/Mq-b-dev2
修改 `auto` 的错误措辞,格式化格式
2 parents be22d21 + eff0477 commit 4c4ad97

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

docs/lambda.md

+29-30
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ int main() {
314314

315315
> {{ icon.tip }} 高层封装 API 应当可以完全通过调用底层 API 实现,提供高层 API 只是方便初级用户使用和理解。
316316
317-
> {{ icon.story }}
317+
> {{ icon.story }}
318318
例如 `libcurl` 就提供了 `curl_easy` 和 `curl_multi` 两套 API。
319319

320320
- `curl_multi` 提供了超详细的参数,把每个操作分拆成多步,方便用户插手细节,满足高级用户的定制化需求,但太过复杂,难以学习。
@@ -524,7 +524,7 @@ int generic_sum(std::vector<int> const &v, Op op) {
524524
}
525525
```
526526

527-
> {{ icon.fun }} C++11:auto 只能用于定义变量;C++14:函数返回类型可以是 auto;C++17:模板参数也可以 auto;C++20:函数参数也可以是 auto 了;(狂想)C++47:auto 现在是 C++47 的唯一关键字,用户只需不断输入 auto-auto-auto,编译器内建人工智能自动识别你的意图生成机器码。
527+
> {{ icon.fun }} C++11:auto 只能用于定义变量以及作为函数返回类型的占位符(无法自行推导);C++14:函数返回类型可以是 auto 并自动推导;C++17:模板非类型参数也可以 auto;C++20:函数参数也可以是 auto 了;(狂想)C++47:auto 现在是 C++47 的唯一关键字,用户只需不断输入 auto-auto-auto,编译器内建人工智能自动识别你的意图生成机器码。
528528
529529
### 函数也是对象!
530530

@@ -1766,8 +1766,8 @@ TODO:延迟回调
17661766
- 在当前函数体内创建,当前函数体内立即调用,可以引用捕获 `[&]`,但值捕获 `[=]` 也没错。
17671767
- 返回一个 lambda,必须值捕获 `[=]`。
17681768
- 接受一个 lambda 做参数,需要进一步分为两种情况:
1769-
- 在当前函数体内立即调用,可以引用捕获 `[&]`,但值捕获 `[=]` 也没错。
1770-
- 作为回调函数,延迟调用,那就必须值捕获 `[=]`。
1769+
- 在当前函数体内立即调用,可以引用捕获 `[&]`,但值捕获 `[=]` 也没错。
1770+
- 作为回调函数,延迟调用,那就必须值捕获 `[=]`。
17711771
17721772
以上四种情况,分别代码演示:
17731773
@@ -1895,35 +1895,34 @@ TODO: count_if, erase_if, argsort
18951895

18961896
二元运算符
18971897

1898-
| 运算符 | 仿函数类型 |
1899-
|-|-|
1900-
|`a < b`|`std::less`|
1901-
|`a > b`|`std::greater`|
1902-
|`a <= b`|`std::less_equal`|
1903-
|`a >= b`|`std::greater_equal`|
1904-
|`a == b`|`std::equal_to`|
1905-
|`a != b`|`std::not_equal_to`|
1906-
|`a <=> b`|`std::compare_three_way` (C++20)|
1907-
|`a && b`|`std::logical_and`|
1908-
|`a \|\| b`|`std::logical_or`|
1909-
|`a & b`|`std::bit_and`|
1910-
|`a \| b`|`std::bit_or`|
1911-
|`a ^ b`|`std::bit_xor`|
1912-
|`a + b`|`std::plus`|
1913-
|`a - b`|`std::minus`|
1914-
|`a * b`|`std::multiplies`|
1915-
|`a / b`|`std::divides`|
1916-
|`a % b`|`std::modulus`|
1917-
1898+
| 运算符 | 仿函数类型 |
1899+
| ----------- | ---------------------------------- |
1900+
| `a < b` | `std::less` |
1901+
| `a > b` | `std::greater` |
1902+
| `a <= b` | `std::less_equal` |
1903+
| `a >= b` | `std::greater_equal` |
1904+
| `a == b` | `std::equal_to` |
1905+
| `a != b` | `std::not_equal_to` |
1906+
| `a <=> b` | `std::compare_three_way` (C++20) |
1907+
| `a && b` | `std::logical_and` |
1908+
| `a \|\| b` | `std::logical_or` |
1909+
| `a & b` | `std::bit_and` |
1910+
| `a \| b` | `std::bit_or` |
1911+
| `a ^ b` | `std::bit_xor` |
1912+
| `a + b` | `std::plus` |
1913+
| `a - b` | `std::minus` |
1914+
| `a * b` | `std::multiplies` |
1915+
| `a / b` | `std::divides` |
1916+
| `a % b` | `std::modulus` |
19181917

19191918
一元运算符
19201919

1921-
| 运算符 | 仿函数类型 |
1922-
|-|-|
1923-
|`!a`|`std::logical_not`|
1924-
|`~a`|`std::bit_not`|
1925-
|`-a`|`std::negate`|
1926-
|`a`|`std::identity`|
1920+
| 运算符 | 仿函数类型 |
1921+
| ------ | -------------------- |
1922+
| `!a` | `std::logical_not` |
1923+
| `~a` | `std::bit_not` |
1924+
| `-a` | `std::negate` |
1925+
| `a` | `std::identity` |
19271926

19281927
## bind 为函数对象绑定参数
19291928

0 commit comments

Comments
 (0)