10.3 Customizing Operations
2025/9/22小于 1 分钟
10.3 Customizing Operations
[!quote]
The library also defines versions of these algorithms that let us supply our own operation to use in place of the default operator.
为什么要Customizing Operations?
sort() 默认使用 元素类型的 < operator 进行排序。
- 要进不同的排序方式,如反向的排序,即使用 > operator 进行比较
- 队列中的元素类型不支持 < operator
以上两种情况需要自定义用于比较操作的方法
目录
| 序号 | 名称 | 内容 |
|---|---|---|
| 1 | 10.3.1 Passing a Function to an Algorithm | |
| 2 | Lambda Expressions | |
| 3 | Lambda Captures and Returns | |
| 4 | Binding Arguments |