From 91739f178c5c3b5711898e03a4e3b0ea425eb296 Mon Sep 17 00:00:00 2001 From: Guoliang WANG Date: Tue, 29 Dec 2020 15:51:11 +0800 Subject: [PATCH 01/77] book: typo fixes (#164) Co-authored-by: guoliang wang --- book/en-us/03-runtime.md | 4 ++-- book/zh-cn/03-runtime.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/book/en-us/03-runtime.md b/book/en-us/03-runtime.md index ea235daf..a3efdf63 100644 --- a/book/en-us/03-runtime.md +++ b/book/en-us/03-runtime.md @@ -87,8 +87,8 @@ capture lists can be: - \[\] empty capture list - \[name1, name2, ...\] captures a series of variables -- \[&\] reference capture, let the compiler derive the capture list by itself -- \[=\] value capture, let the compiler execute the list of derivation applications +- \[&\] reference capture, let the compiler deduce the reference list by itself +- \[=\] value capture, let the compiler deduce the value list by itself #### 4. Expression capture diff --git a/book/zh-cn/03-runtime.md b/book/zh-cn/03-runtime.md index e4d02d7a..161ed90e 100644 --- a/book/zh-cn/03-runtime.md +++ b/book/zh-cn/03-runtime.md @@ -76,8 +76,8 @@ void lambda_reference_capture() { - \[\] 空捕获列表 - \[name1, name2, ...\] 捕获一系列变量 -- \[&\] 引用捕获, 让编译器自行推导捕获列表 -- \[=\] 值捕获, 让编译器执行推导引用列表 +- \[&\] 引用捕获, 让编译器自行推导引用列表 +- \[=\] 值捕获, 让编译器自行推导值捕获列表 **4. 表达式捕获** From 054119f69c74d4f2da150658452b1b4ad690dc67 Mon Sep 17 00:00:00 2001 From: Guoliang WANG Date: Tue, 29 Dec 2020 15:52:14 +0800 Subject: [PATCH 02/77] book: fmt (#163) Co-authored-by: guoliang wang --- book/zh-cn/03-runtime.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/book/zh-cn/03-runtime.md b/book/zh-cn/03-runtime.md index 161ed90e..2c880375 100644 --- a/book/zh-cn/03-runtime.md +++ b/book/zh-cn/03-runtime.md @@ -27,12 +27,12 @@ Lambda 表达式的基本语法如下: 上面的语法规则除了 `[捕获列表]` 内的东西外,其他部分都很好理解,只是一般函数的函数名被略去, 返回值使用了一个 `->` 的形式进行(我们在上一节前面的尾返回类型已经提到过这种写法了)。 -所谓捕获列表,其实可以理解为参数的一种类型,lambda 表达式内部函数体在默认情况下是不能够使用函数体外部的变量的, +所谓捕获列表,其实可以理解为参数的一种类型,Lambda 表达式内部函数体在默认情况下是不能够使用函数体外部的变量的, 这时候捕获列表可以起到传递外部数据的作用。根据传递的行为,捕获列表也分为以下几种: #### 1. 值捕获 -与参数传值类似,值捕获的前提是变量可以拷贝,不同之处则在于,被捕获的变量在 lambda 表达式被创建时拷贝, +与参数传值类似,值捕获的前提是变量可以拷贝,不同之处则在于,被捕获的变量在 Lambda 表达式被创建时拷贝, 而非调用时才拷贝: ```cpp @@ -72,7 +72,7 @@ void lambda_reference_capture() { 手动书写捕获列表有时候是非常复杂的,这种机械性的工作可以交给编译器来处理,这时候可以在捕获列表中写一个 `&` 或 `=` 向编译器声明采用引用捕获或者值捕获. -总结一下,捕获提供了lambda 表达式对外部值进行使用的功能,捕获列表的最常用的四种形式可以是: +总结一下,捕获提供了 Lambda 表达式对外部值进行使用的功能,捕获列表的最常用的四种形式可以是: - \[\] 空捕获列表 - \[name1, name2, ...\] 捕获一系列变量 @@ -157,7 +157,7 @@ int main() { C++11 `std::function` 是一种通用、多态的函数封装, 它的实例可以对任何可以调用的目标实体进行存储、复制和调用操作, -它也是对 C++中现有的可调用实体的一种类型安全的包裹(相对来说,函数指针的调用不是类型安全的), +它也是对 C++ 中现有的可调用实体的一种类型安全的包裹(相对来说,函数指针的调用不是类型安全的), 换句话说,就是函数的容器。当我们有了函数的容器之后便能够更加方便的将函数、函数指针作为对象进行处理。 例如: @@ -241,7 +241,7 @@ int main() { } ``` -**将亡值(xvalue, expiring value)**,是 C++11 为了引入右值引用而提出的概念(因此在传统 C++中, +**将亡值(xvalue, expiring value)**,是 C++11 为了引入右值引用而提出的概念(因此在传统 C++ 中, 纯右值和右值是同一个概念),也就是即将被销毁、却能够被移动的值。 将亡值可能稍有些难以理解,我们来看这样的代码: @@ -256,7 +256,7 @@ std::vector v = foo(); ``` 在这样的代码中,就传统的理解而言,函数 `foo` 的返回值 `temp` 在内部创建然后被赋值给 `v`, -然而 `v` 获得这个对象时,会将整个 temp 拷贝一份,然后把 `temp` 销毁,如果这个 `temp` 非常大, +然而 `v` 获得这个对象时,会将整个 `temp` 拷贝一份,然后把 `temp` 销毁,如果这个 `temp` 非常大, 这将造成大量额外的开销(这也就是传统 C++ 一直被诟病的问题)。在最后一行中,`v` 是左值、 `foo()` 返回的值就是右值(也是纯右值)。但是,`v` 可以被别的变量捕获到, 而 `foo()` 产生的那个返回值作为一个临时值,一旦被 `v` 复制后,将立即被销毁,无法获取、也不能修改。 From 7eceaf1bee6790e64a6965b93b312f25656e41ab Mon Sep 17 00:00:00 2001 From: Changkun Ou Date: Thu, 31 Dec 2020 09:26:05 +0100 Subject: [PATCH 03/77] all: remove chat group (#165) --- README-zh-cn.md | 2 +- README.md | 3 +-- assets/community.md | 11 ----------- website/Makefile | 2 -- .../themes/moderncpp/layout/partials/main_menu.ejs | 1 - .../themes/moderncpp/layout/partials/main_menu_en.ejs | 1 - 6 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 assets/community.md diff --git a/README-zh-cn.md b/README-zh-cn.md index 3e98207a..1b0aef83 100644 --- a/README-zh-cn.md +++ b/README-zh-cn.md @@ -2,7 +2,7 @@ # 现代 C++ 教程:高速上手 C++11/14/17/20 -![](https://img.shields.io/travis/changkun/modern-cpp-tutorial/master?style=flat-square) [![](https://img.shields.io/badge/language-English-blue.svg?style=flat-square)](./README.md) [![](https://img.shields.io/badge/language-简体中文-red.svg?style=flat-square)](./README-zh-cn.md) [![](https://img.shields.io/badge/€-donate-ff69b4.svg?style=flat-square)](./assets/donate.md) [![](https://img.shields.io/badge/chat-community-667ed5.svg?style=flat-square)](./assets/community.md) +![](https://img.shields.io/travis/changkun/modern-cpp-tutorial/master?style=flat-square) [![](https://img.shields.io/badge/language-English-blue.svg?style=flat-square)](./README.md) [![](https://img.shields.io/badge/language-简体中文-red.svg?style=flat-square)](./README-zh-cn.md) [![](https://img.shields.io/badge/€-donate-ff69b4.svg?style=flat-square)](./assets/donate.md) ## 本书目的 diff --git a/README.md b/README.md index 8e94da7e..6ef8ae93 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ # Modern C++ Tutorial: C++11/14/17/20 On the Fly -![](https://img.shields.io/travis/changkun/modern-cpp-tutorial/master?style=flat-square) [![](https://img.shields.io/badge/language-English-blue.svg?style=flat-square)](./README.md) [![](https://img.shields.io/badge/language-简体中文-red.svg?style=flat-square)](./README-zh-cn.md) [![](https://img.shields.io/badge/€-donate-ff69b4.svg?style=flat-square)](./assets/donate.md) [![](https://img.shields.io/badge/chat-community-667ed5.svg?style=flat-square)](./assets/community.md) - +![](https://img.shields.io/travis/changkun/modern-cpp-tutorial/master?style=flat-square) [![](https://img.shields.io/badge/language-English-blue.svg?style=flat-square)](./README.md) [![](https://img.shields.io/badge/language-简体中文-red.svg?style=flat-square)](./README-zh-cn.md) [![](https://img.shields.io/badge/€-donate-ff69b4.svg?style=flat-square)](./assets/donate.md) ## Purpose The book claims to be "On the Fly". Its intent is to provide a comprehensive introduction to the relevant features regarding modern C++ (before 2020s). diff --git a/assets/community.md b/assets/community.md deleted file mode 100644 index 657980cf..00000000 --- a/assets/community.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: 社区 -type: about -order: 2 ---- - -## Community - -The book offers a telegram chat group, feel free to join if you are interested: - -[![](https://img.shields.io/badge/chat-telegram-blue.svg?style=popout-square&logo=telegram)](https://t.me/joinchat/FEeulBM5OVYzuDI4phQ9Mg) diff --git a/website/Makefile b/website/Makefile index a3591267..d0d625fe 100755 --- a/website/Makefile +++ b/website/Makefile @@ -8,7 +8,6 @@ all: clean cp ../assets/alipay.jpg ./src/modern-cpp/assets/alipay.jpg cp ../assets/wechat.jpg ./src/modern-cpp/assets/wechat.jpg cp ../assets/donate.md ./src/modern-cpp/about/ - cp ../assets/community.md ./src/modern-cpp/about/ cp -r ../assets/figures ./src/modern-cpp/assets/figures cp -r ../exercises ./src/modern-cpp/ cp -r ../code ./src/modern-cpp/ @@ -25,7 +24,6 @@ clean: ./src/modern-cpp/assets/alipay.jpg \ ./src/modern-cpp/assets/wechat.jpg \ ./src/modern-cpp/about/donate.md \ - ./src/modern-cpp/about/community.md \ ./src/modern-cpp/code \ ./src/modern-cpp/exercises \ public db.json src/modern-cpp/zh-cn src/modern-cpp/en-us diff --git a/website/themes/moderncpp/layout/partials/main_menu.ejs b/website/themes/moderncpp/layout/partials/main_menu.ejs index a2cd2124..9a2f3ed8 100755 --- a/website/themes/moderncpp/layout/partials/main_menu.ejs +++ b/website/themes/moderncpp/layout/partials/main_menu.ejs @@ -16,7 +16,6 @@