Skip to content

Commit c9e3040

Browse files
committed
add #12: prepare English supports
1 parent 84a02f7 commit c9e3040

25 files changed

+187
-7
lines changed

README-en-us.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<img src="assets/cover-2nd-en.png" alt="logo" height="600" align="right" />
2+
3+
# C++11/14/17 On the Fly
4+
5+
![](https://img.shields.io/badge/version-v2-green.svg) ![](https://img.shields.io/badge/language-English-blue.svg) [![](https://img.shields.io/badge/$-donate-ff69b4.svg)](./assets/donate.md) [![](https://img.shields.io/badge/chat-community-667ed5.svg)](./assets/community.md)
6+
7+
> This book is adapting to C++17
8+
9+
## Languages
10+
11+
- 🇨🇳 [简体中文](./README.md)
12+
- 🇬🇧 English
13+
14+
## Purpose
15+
16+
The book claims "On the Fly". Its intent is to provide a comprehensive introduction to the relevant features regarding modern C++ (before 2020s).
17+
Readers can choose interesting content according to the following table of content to learn and quickly familiarize the new features you would like to learn.
18+
Readers should aware that all of these features are not required. It should be leart when you really need it.
19+
20+
At the same time, instead of grammar-only, the book introduces the historical background as simple as possible of its technical requirements, which provides great help in understanding why these features comes out.
21+
22+
In addition, The author would like to encourage that readers should be able to use C++17 directly in their new projects and migrate their old projects to C++17 gradually after read the book.
23+
24+
## Targets
25+
26+
- This book assumes that readers are already familiar with traditional C++ (e.g. C++98), at least they do not have any difficulty in reading traditional C++ code. In other words, those who have long experience in traditional C++ and people who desire to quickly understand the features of modern C++ in a short period of time are well suited to read the book;
27+
28+
- This book introduces to a certain extent of the dark magic of modern C++. However, these magics are very limited, they are not suitable for readers who want to learn advanced C++. The purpose of this book is offering a quick start for modern C++. Of course, advanced readers can also use this book to review and examine themselves on modern C++.
29+
30+
## Start
31+
32+
You can choose from the following reading methods:
33+
34+
- [GitHub Online](./book/en-us/toc.md)
35+
- [PDF document]
36+
- [Website]
37+
38+
## Code
39+
40+
Each chapter of this book has a lot of code. If you encounter problems when writing your own code with the introductory features of the book, you might as well read the source code attached to the book. You can find the book [here](./code). All the code organized by chapter, the folder name is the chapter number.
41+
42+
## Exercises
43+
44+
There are few exercises At the end of each chapter of the book. It is for testing whether you can use the knowledge points in the current chapter. You can find the possible answer to the problem from [here](./exercise). The folder name is the chapter number.
45+
46+
## Acknowledgements
47+
48+
This book is originally written in Chinese, and the author's time, skills and languages are limited. If readers find any mistakes of the book or any language improvements, please feel free to open an [issue](https://github.com/changkun/modern-cpp-tutorial/issues). The author would like to appreciate all of the contributors of this book for discovering mistakes:
49+
50+
[recolic](https://www.gitbook.com/@recolic), [sinomiko](https://www.gitbook.com/@sinomiko), [jackwish](https://www.gitbook.com/@jackwish), [asmwarrior](https://www.gitbook.com/@asmwarrior), [garicc](https://www.gitbook.com/@ihpy), [jiangwenhan](https://www.gitbook.com/@jiangwenhan), [liangx8](https://www.gitbook.com/@liangx8), [slivermeteor](https://github.com/slivermeteor), [inkedawn](https://github.com/inkedawn), [zhaoyao73](https://github.com/zhaoyao73), [sundy-li](https://github.com/sundy-li), [dontpanic92](https://github.com/dontpanic92)
51+
52+
## Licenses
53+
54+
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work is written by [Ou Changkun](https://changkun.de) and licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>. The code of this repository is open sourced under the [MIT license](./LICENSE).

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
# 《高速上手 C++11/14/17》
44

5-
![](https://img.shields.io/badge/version-v2-green.svg) [![](https://img.shields.io/badge/%C2%A5-%E8%B5%9E%E5%8A%A9-ff69b4.svg)](./assets/donate.md) [![](https://img.shields.io/badge/chat-%E4%BA%A4%E6%B5%81-667ed5.svg)](./assets/community.md)
5+
![](https://img.shields.io/badge/version-v2-green.svg)
6+
![](https://img.shields.io/badge/language-%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87-red.svg)
7+
[![](https://img.shields.io/badge/%C2%A5-%E8%B5%9E%E5%8A%A9-ff69b4.svg)](./assets/donate.md) [![](https://img.shields.io/badge/chat-%E4%BA%A4%E6%B5%81-667ed5.svg)](./assets/community.md)
68

79
> 本书正在适配 C++17 新特性,尽请期待。
810
11+
## 语言
12+
13+
- 🇨🇳 [简体中文](./README.md)
14+
- 🇬🇧 [English](./README-en-us.md)
15+
916
## 本书目的
1017

1118
本书号称『高速上手』,从内容上对二十一世纪二十年代之前产生 C++ 的相关特性做了非常相对全面的介绍,读者可以自行根据下面的目录选取感兴趣的内容进行学习,快速熟悉需要了解的内容。这些特性并不需要全部掌握,只需针对自己的使用需求和特定的应用场景,学习、查阅最适合自己的新特性即可。
@@ -23,8 +30,8 @@
2330

2431
你可以选择以下几种阅读方式:
2532

26-
1. [GitHub 在线](./book/toc.md)
27-
2. [PDF 文档](./pdf/modern-cpp-tutorial.pdf)
33+
1. [GitHub 在线](./book/zh-cn/toc.md)
34+
2. [PDF 文档](./pdf/zh-cn/modern-cpp-tutorial.pdf)
2835
3. [网站]
2936

3037
## 相关代码

assets/community-international.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Community
2+
3+
This book offers a reader community, you can join this Telegram:
4+
5+
TBA

assets/cover-2nd-en.afphoto

1.94 MB
Binary file not shown.

assets/cover-2nd-en.png

1.54 MB
Loading

assets/donate-international.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Donate
2+
3+
To donate the author:
4+
5+
TBA

book/en-us/toc.md

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# C++ 11/14/17 On The Fly
2+
3+
> This book adapting to C++17 and translating to English
4+
5+
## Table of Contents
6+
7+
- [**Preface**](./00-preface.md)
8+
- [**Chapter 01 Towards C++11/14/17**](./01-intro.md)
9+
+ 1.1 Deprecated Features
10+
+ 1.2 Compatibility with C
11+
+ Further Readings
12+
- [**Chapter 02 Language Usability Enhancements**](./02-usability.md)
13+
+ 2.1 Constants
14+
- nullptr
15+
- constexpr
16+
+ 2.2 Variables & Initialization
17+
- Conditional Statement
18+
- Initializer List
19+
- Structured binding
20+
+ 2.3 Type Deduction
21+
- auto
22+
- decltype
23+
- Tail return type
24+
- decltype(auto)
25+
+ 2.4 Control Flow
26+
- if constexpr
27+
- Range-based for loop
28+
+ 2.5 Templates
29+
- External templates
30+
- The ">"
31+
- Type alias templates
32+
- Default template parameters
33+
- Variadic templates
34+
- Fold expression
35+
+ 2.6 Object-oriented
36+
- Delegate constructor
37+
- Inheritance constructor
38+
- Explicit virtual function overwrite
39+
- override
40+
- final
41+
- Explicit delete default function
42+
- Strongly typed enumerations
43+
- [**Chapter 03 Language Runtime Enhancements**](./03-runtime.md)
44+
+ Lambda expression
45+
+ Basics
46+
+ Value capture
47+
+ Reference capture
48+
+ Implicit capture
49+
+ Expression capture
50+
+ Generic lambda
51+
+ Function object wrapper
52+
+ std::function
53+
+ std::bind/std::placeholder
54+
+ rvalue reference
55+
+ lvalue, rvalue, prvalue, xvalue
56+
+ rvalue reference & lvalue reference
57+
+ Move semantics
58+
+ Perfect forwarding
59+
- [**Chapter 04 Sandard Library: Containers**](./04-containers.md)
60+
+ `std::array`
61+
+ `std::forward_list`
62+
+ `std::unordered_set`
63+
+ `std::unordered_map`
64+
+ `std::tuple`
65+
+ basic operation
66+
+ runtime indexing
67+
+ merge and iteration
68+
- [**Chapter 05 Sandard Library: Pointers**](./05-pointers.md)
69+
+ RAII and reference counting
70+
+ `std::shared_ptr`
71+
+ `std::unique_ptr`
72+
+ `std::weak_ptr`
73+
- [**Chapter 06 Sandard Library: Regular Expression**](./06-regex.md)
74+
+ Regular Expression Introduction
75+
+ Normal characters
76+
+ Special characters
77+
+ Determinative
78+
+ `std::regex`
79+
+ `std::regex`
80+
+ `std::regex_match`
81+
+ `std::match_results`
82+
- [**Chapter 07 Sandard Library: Threads and Concurrency**](./07-thread.md)
83+
+ `std::thread`
84+
+ `std::mutex`
85+
+ `std::unique_lock`
86+
+ `std::future`
87+
+ `std::packaged_task`
88+
+ `std::condition_variable`
89+
- [**Chapter 08 Sandard Library: File System**](./08-filesystem.md)
90+
- [**Chapter 09 Minor Features**](./09-others.md)
91+
+ New Types
92+
+ `long long int`
93+
+ `noexcept`
94+
+ Literal
95+
+ Raw string literal
96+
+ Custom string literal
97+
+ Math Library
98+
- [**Chapter 10 Outlook: Introduction of C++20**](./10-cpp20.md)
99+
+ Concept
100+
+ Range
101+
+ Module
102+
+ Coroutine
103+
- [**Appendix: Further Study Materials**](./appendix.md)
104+
105+
Table of Content | Last Chapter | [Next Chapter: Preface](./00-preface.md)
106+
107+
## Licenses
108+
109+
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work is written by [Ou Changkun](https://changkun.de) and licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>. The code of this repository is open sourced under the [MIT license](./LICENSE).
File renamed without changes.

book/01-intro.md book/zh-cn/01-intro.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ InstalledDir: /Library/Developer/CommandLineTools/usr/bin
4545

4646
出于一些不可抗力、历史原因,我们不得不在 C++ 中使用一些 C 语言代码(甚至古老的 C 语言代码),例如 Linux 系统调用。在 C++1x 出现之前,大部分人当谈及『C 与 C++ 的区别是什么』时,普遍除了回答面向对象的类特性、泛型编程的模板特性外,就没有其他的看法了,甚至直接回答『差不多』,也是大有人在。图 1.2 中的韦恩图大致上回答了 C 和 C++ 相关的兼容情况。
4747

48-
![图 1.2: C 和 C++ 互相兼容情况](../assets/comparison.png)
48+
![图 1.2: C 和 C++ 互相兼容情况](../../assets/comparison.png)
4949

5050
从现在开始,你的脑子里应该树立『**C++ 不是 C 的一个超集**』这个观念(而且从一开始就不是,后面的[进一步阅读的参考文献](#进一步阅读的参考文献)中给出了 C++98 和 C99 之间的区别)。在编写 C++ 时,也应该尽可能的避免使用诸如 `void*` 之类的程序风格。而在不得不使用 C 时,应该注意使用 `extern "C"` 这种特性,将 C 语言的代码与 C++代码进行分离编译,再统一链接这种做法,例如:
5151

File renamed without changes.
File renamed without changes.
File renamed without changes.

book/05-pointers.md book/zh-cn/05-pointers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ int main() {
162162
163163
运行结果是 A, B 都不会被销毁,这是因为 a,b 内部的 pointer 同时又引用了 `a,b`,这使得 `a,b` 的引用计数均变为了 2,而离开作用域时,`a,b` 智能指针被析构,却智能造成这块区域的引用计数减一,这样就导致了 `a,b` 对象指向的内存区域引用计数不为零,而外部已经没有办法找到这块区域了,也就造成了内存泄露,如图所示:
164164
165-
![](../assets/pointers1.png)
165+
![](../../assets/pointers1.png)
166166
167167
解决这个问题的办法就是使用弱引用指针 `std::weak_ptr`,`std::weak_ptr`是一种弱引用(相比较而言 `std::shared_ptr` 就是一种强引用)。弱引用不会引起引用计数增加,当换用弱引用时候,最终的释放流程如下图所示:
168168
169-
![](../assets/pointers2.png)
169+
![](../../assets/pointers2.png)
170170
171171
在上图中,最后一步只剩下 B,而 B 并没有任何智能指针引用它,因此这块内存资源也会被释放。
172172
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

book/toc.md book/zh-cn/toc.md

File renamed without changes.

pdf/Makefile pdf/zh-cn/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pdf: markdown
1818

1919
markdown:
2020
@echo "Copy markdown files..."
21-
@cp -r ../book/* .
21+
@cp -r ../../book/zh-cn/* .
2222
@echo "Aggregating markdown files..."
2323
@python3 aggregator.py
2424

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)