book: translation of ch04

Update #12
This commit is contained in:
Changkun Ou
2019-07-19 19:17:16 +02:00
parent bf6b09253b
commit 7776a59e97
9 changed files with 412 additions and 69 deletions

View File

@@ -8,7 +8,7 @@ order: 4
[TOC]
## 4.1 `std::array` 和 `std::forward_list`
## 4.1 线性容器
### `std::array`
@@ -166,7 +166,7 @@ Key:[2] Value:[2]
Key:[3] Value:[3]
```
## 4.3 元组 `std::tuple`
## 4.3 元组
了解过 Python 的程序员应该知道元组的概念,纵观传统 C++ 中的容器,除了 `std::pair` 外,
似乎没有现成的结构能够用来存放不同类型的数据(通常我们会自己定义结构)。
@@ -297,7 +297,7 @@ for(int i = 0; i != tuple_len(new_tuple); ++i)
## 总结
简单介绍了 C++11/14 中新增的容器,它们的用法和传统 C++ 中已有的容器类似,相对简单,可以根据实际场景丰富的选择需要使用的容器,从而获得更好的性能。
简单介绍了现代 C++ 中新增的容器,它们的用法和传统 C++ 中已有的容器类似,相对简单,可以根据实际场景丰富的选择需要使用的容器,从而获得更好的性能。
`std::tuple` 虽然有效,但是标准库提供的功能有限,没办法满足运行期索引和迭代的需求,好在我们还有其他的方法可以自行实现。

View File

@@ -56,13 +56,15 @@
+ 移动语义
+ 完美转发
- [**第 4 章 标准库: 容器**](./04-containers.md)
+ 4.1 `std::array``std::forward_list`
+ 4.1 线性容器
+ `std::array`
+ `std::forward_list`
+ 4.2 无序容器
+ `std::unordered_set`
+ `std::unordered_map`
+ 4.3 元组 `std::tuple`
+ 基本操作
+ 运行期索引
+ 运行期索引 `std::variant`
+ 合并与迭代
- [**第 5 章 标准库: 指针**](./05-pointers.md)
+ 5.1 RAII 与引用计数