book: chapter name refinement

This commit is contained in:
Changkun Ou
2019-07-19 12:32:34 +02:00
parent 115827f98c
commit 86d84d25ca
7 changed files with 21 additions and 27 deletions

View File

@@ -6,7 +6,7 @@ order: 3
# Chapter 03: Language Runtime Enhancements
[Table of Content](./toc.md) | [Previous Chapter](./02-usability.md) | [Next Chapter: Standard Library: Containers](./04-containers.md)
[Table of Content](./toc.md) | [Previous Chapter](./02-usability.md) | [Next Chapter: Containers](./04-containers.md)
## Further Readings

View File

@@ -1,12 +1,12 @@
---
title: "Chapter 04 Standard Library: Containers"
title: "Chapter 04 Containers"
type: book-en-us
order: 4
---
# Chapter 04 Standard Library: Containers
# Chapter 04 Containers
[Table of Content](./toc.md) | [Previous Chapter](./03-runtime.md) | [Next Chapter: Standard Library: Pointers](./05-pointers.md)
[Table of Content](./toc.md) | [Previous Chapter](./03-runtime.md) | [Next Chapter: Smart Pointers and Memory Management](./05-pointers.md)
## Further Readings

View File

@@ -1,10 +1,10 @@
---
title: "Chapter 05 Standard Library: Pointers"
title: "Chapter 05 Smart Pointers and Memory Management"
type: book-en-us
order: 5
---
# Chapter 05 Standard Library: Pointers
# Chapter 05 Smart Pointers and Memory Management
[Table of Content](./toc.md) | [Previous Chapter](./04-containers.md) | [Next Chapter: Regular Expression](./06-regex.md)

View File

@@ -55,7 +55,7 @@
+ rvalue reference & lvalue reference
+ Move semantics
+ Perfect forwarding
- [**Chapter 04 Standard Library: Containers**](./04-containers.md)
- [**Chapter 04 Containers**](./04-containers.md)
+ 4.1 `std::array` and `std::forward_list`
+ 4.2 Unordered containers
+ `std::unordered_set`
@@ -64,11 +64,11 @@
+ basic operation
+ runtime indexing
+ merge and iteration
- [**Chapter 05 Standard Library: Pointers**](./05-pointers.md)
- [**Chapter 05 Smart Pointers and Memory Management**](./05-pointers.md)
+ 5.1 RAII and reference counting
+ 5.2 `std::shared_ptr`
+ 5.3 `std::unique_ptr`
- [**Chapter 06 Standard Library: Regular Expression**](./06-regex.md)
- [**Chapter 06 Regular Expression**](./06-regex.md)
+ 6.1 Introduction
+ Ordinary characters
+ Special characters

View File

@@ -6,8 +6,6 @@ order: 3
# 第 3 章 语言运行期的强化
> 内容修订中
[TOC]
## 3.1 Lambda 表达式
@@ -73,7 +71,7 @@ void learn_lambda_func_2() {
* \[&\] 引用捕获, 让编译器自行推导捕获列表
* \[=\] 值捕获, 让编译器执行推导应用列表
**4. 表达式捕获\(C++14\)**
**4. 表达式捕获**
> 这部分内容需要了解后面马上要提到的右值引用以及智能指针
@@ -189,15 +187,15 @@ int main() {
要弄明白右值引用到底是怎么一回事,必须要对左值和右值做一个明确的理解。
**左值\(lvalue, left value\)**,顾名思义就是赋值符号左边的值。准确来说,左值是表达式(不一定是赋值表达式)后依然存在的持久对象。
**左值(lvalue, left value)**,顾名思义就是赋值符号左边的值。准确来说,左值是表达式(不一定是赋值表达式)后依然存在的持久对象。
**右值\(rvalue, right value\)**,右边的值,是指表达式结束后就不再存在的临时对象。
**右值(rvalue, right value)**,右边的值,是指表达式结束后就不再存在的临时对象。
而 C++11 中为了引入强大的右值引用,将右值的概念进行了进一步的划分,分为:纯右值、将亡值。
**纯右值\(prvalue, pure rvalue\)**,纯粹的右值,要么是纯粹的字面量,例如 `10`, `true`;要么是求值结果相当于字面量或匿名临时对象,例如 `1+2`。非引用返回的临时变量、运算表达式产生的临时变量、原始字面量、Lambda 表达式都属于纯右值。
**纯右值(prvalue, pure rvalue)**,纯粹的右值,要么是纯粹的字面量,例如 `10`, `true`;要么是求值结果相当于字面量或匿名临时对象,例如 `1+2`。非引用返回的临时变量、运算表达式产生的临时变量、原始字面量、Lambda 表达式都属于纯右值。
**将亡值\(xvalue, expiring value\)**,是 C++11 为了引入右值引用而提出的概念(因此在传统 C++中,纯右值和右值是同一个概念),也就是即将被销毁、却能够被移动的值。
**将亡值(xvalue, expiring value)**,是 C++11 为了引入右值引用而提出的概念(因此在传统 C++中,纯右值和右值是同一个概念),也就是即将被销毁、却能够被移动的值。
将亡值可能稍有些难以理解,我们来看这样的代码:
@@ -418,7 +416,7 @@ std::forward 传参:左值引用
无论传递参数为左值还是右值,普通传参都会将参数作为左值进行转发,所以 `std::move` 总会接受到一个左值,从而转发调用了`reference(int&&)` 输出右值引用。
唯独 `std::forward` 即没有造成任何多余的拷贝,同时**完美转发**\(传递\)了函数的实参给了内部调用的其他函数。
唯独 `std::forward` 即没有造成任何多余的拷贝,同时**完美转发**(传递)了函数的实参给了内部调用的其他函数。
> `std::forward` 和 `std::move` 一样,没有做任何事情,`std::move` 单纯的将左值转化为右值,`std::forward` 也只是单纯的将参数做了一个类型的转换,从现象上来看,`std::forward<T>(v)` 和 `static_cast<T&&>(v)` 是完全一样的。
@@ -430,7 +428,7 @@ std::forward 传参:左值引用
2. 函数对象容器 std::function
3. 右值引用
[返回目录](./toc.md) | [上一章](./02-usability.md) | [下一章 标准库:容器](./04-containers.md)
[返回目录](./toc.md) | [上一章](./02-usability.md) | [下一章 容器](./04-containers.md)
## 许可

View File

@@ -1,12 +1,10 @@
---
title: 第 4 章 标准库:容器
title: 第 4 章 容器
type: book-zh-cn
order: 4
---
# 第 4 章 标准库:容器
> 内容修订中
# 第 4 章 容器
[TOC]
@@ -303,7 +301,7 @@ for(int i = 0; i != tuple_len(new_tuple); ++i)
`std::tuple` 虽然有效,但是标准库提供的功能有限,没办法满足运行期索引和迭代的需求,好在我们还有其他的方法可以自行实现。
[返回目录](./toc.md) | [上一章](./03-runtime.md) | [下一章 标准库:指针](./05-pointers.md)
[返回目录](./toc.md) | [上一章](./03-runtime.md) | [下一章 智能指针与内存管理](./05-pointers.md)
## 许可

View File

@@ -1,12 +1,10 @@
---
title: 第 5 章 标准库:指针
title: 第 5 章 智能指针与内存管理
type: book-zh-cn
order: 5
---
# 第 5 章 标准库:指针
> 内容修订中
# 第 5 章 智能指针与内存管理
[TOC]