diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3fe0efbb..b2776b6d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ ## 提交 Issue -『C++ 11/14/17』的 issue 用于追踪书中存在的原则性的描述错误、存在的 `typo` 错误,以及向本书作者提问等。 +『C++ 11/14/17/20』的 issue 用于追踪书中存在的原则性的描述错误、存在的 `typo` 错误,以及向本书作者提问等。 - 通常情况下,你可能会发现书中某个段落存在错别字、语义错误、文法错误等。 这都是 `typo` 错误。如果该错误已经对你的阅读造成了一定障碍, @@ -24,7 +24,7 @@ ## 提交 Pull request -『C++ 11/14/17』是一本开源书籍,任何人都可以参与贡献自己 PR。但在提交 PR 之前请仔细阅读下面的说明: +『C++ 11/14/17/20』是一本开源书籍,任何人都可以参与贡献自己 PR。但在提交 PR 之前请仔细阅读下面的说明: - 当你认为需要提交一个 PR 时,请确保 [issue 列表](https://github.com/changkun/modern-cpp-tutorial/issues)中,已经包含了你想要解决的问题。 如果没有,请参考**提交 Issue** 一节中的描述,提交你的 issue,再提交你的 PR。 diff --git a/LICENSE b/LICENSE index 57e96434..eaf37d56 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016 - Present Changkun Ou +Copyright (c) 2016 - 2019 Changkun Ou Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README-en-us.md b/README-en-us.md index 495ef8e4..39d7c062 100644 --- a/README-en-us.md +++ b/README-en-us.md @@ -1,12 +1,9 @@ logo -# C++11/14/17 On the Fly +# C++11/14/17/20 On the Fly ![](https://img.shields.io/badge/version-v2-green.svg) [![](https://img.shields.io/badge/language-%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87-red.svg)](./README.md) [![](https://img.shields.io/badge/language-English-blue.svg)](./README-en-us.md) [![](https://img.shields.io/badge/$-donate-ff69b4.svg)](./assets/donate.md) [![](https://img.shields.io/badge/chat-community-667ed5.svg)](./assets/community.md) - -> This book is adapting to C++17 and translating to English. - ## Purpose The book claims "On the Fly". Its intent is to provide a comprehensive introduction to the relevant features regarding modern C++ (before 2020s). @@ -15,7 +12,7 @@ Readers should aware that all of these features are not required. It should be l 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. -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. +In addition, The author would like to encourage that readers should be able to use modern C++ directly in their new projects and migrate their old projects to modern C++ gradually after read the book. ## Targets @@ -51,4 +48,4 @@ The author has limited time and language skills. If readers find any mistakes of ## Licenses -Creative Commons License
This work is written by [Ou Changkun](https://changkun.de) and licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. The code of this repository is open sourced under the [MIT license](./LICENSE). \ No newline at end of file +Creative Commons License
This work was written by [Ou Changkun](https://changkun.de) and licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. The code of this repository is open sourced under the [MIT license](./LICENSE). \ No newline at end of file diff --git a/README.md b/README.md index d6e450ca..d98c4d5d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -logo +logo -# 《高速上手 C++11/14/17》 +# 《高速上手 C++11/14/17/20》 [![](https://img.shields.io/badge/language-%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87-red.svg)](./README.md) [![](https://img.shields.io/badge/language-English-blue.svg)](./README-en-us.md) [![](https://img.shields.io/badge/%C2%A5-%E8%B5%9E%E5%8A%A9-ff69b4.svg)](./assets/donate.md) @@ -11,7 +11,7 @@ 同时,本书在介绍这些特性的过程中,尽可能简单明了的介绍了这些特性产生的历史背景和技术需求,这为理解这些特性、运用这些特性提供了很大的帮助。 -此外,笔者希望读者在阅读本书后,能够努力在新项目中直接使用 C++17,并努力将旧项目逐步迁移到 C++17。也算是笔者为推进现代 C++ 的普及贡献了一些绵薄之力。 +此外,笔者希望读者在阅读本书后,能够努力在新项目中直接使用现代 C++,并努力将旧项目逐步迁移到现代 C++。也算是笔者为推进现代 C++ 的普及贡献了一些绵薄之力。 ## 目标读者 diff --git a/assets/cover-2nd-en.afphoto b/assets/cover-2nd-en.afphoto index 8e0de941..28c7848d 100644 Binary files a/assets/cover-2nd-en.afphoto and b/assets/cover-2nd-en.afphoto differ diff --git a/assets/cover-2nd-en.png b/assets/cover-2nd-en.png index cae0dadd..3f8c1619 100644 Binary files a/assets/cover-2nd-en.png and b/assets/cover-2nd-en.png differ diff --git a/assets/cover-2nd.afphoto b/assets/cover-2nd.afphoto new file mode 100644 index 00000000..0f350deb Binary files /dev/null and b/assets/cover-2nd.afphoto differ diff --git a/assets/cover-2nd.png b/assets/cover-2nd.png index 92ea730f..393e45fc 100644 Binary files a/assets/cover-2nd.png and b/assets/cover-2nd.png differ diff --git a/book/en-us/00-preface.md b/book/en-us/00-preface.md new file mode 100644 index 00000000..e69de29b diff --git a/book/en-us/toc.md b/book/en-us/toc.md index eab8a6a7..801abbd0 100644 --- a/book/en-us/toc.md +++ b/book/en-us/toc.md @@ -1,9 +1,9 @@ -# C++ 11/14/17 On The Fly +# C++ 11/14/17/20 On The Fly ## Table of Contents - [**Preface**](./00-preface.md) -- [**Chapter 01 Towards C++11/14/17**](./01-intro.md) +- [**Chapter 01 Towards Modern C++**](./01-intro.md) + 1.1 Deprecated Features + 1.2 Compatibility with C + Further Readings @@ -39,69 +39,71 @@ - Explicit delete default function - Strongly typed enumerations - [**Chapter 03 Language Runtime Enhancements**](./03-runtime.md) - + Lambda expression + + 3.1 Lambda expression + Basics + Value capture + Reference capture + Implicit capture + Expression capture + Generic lambda - + Function object wrapper + + 3.2 Function object wrapper + std::function + std::bind/std::placeholder - + rvalue reference + + 3.3 rvalue reference + lvalue, rvalue, prvalue, xvalue + rvalue reference & lvalue reference + Move semantics + Perfect forwarding - [**Chapter 04 Sandard Library: Containers**](./04-containers.md) - + `std::array` - + `std::forward_list` - + `std::unordered_set` - + `std::unordered_map` - + `std::tuple` + + 4.1 `std::array` and `std::forward_list` + + 4.2 Unordered containers + + `std::unordered_set` + + `std::unordered_map` + + 4.3 Tuples `std::tuple` + basic operation + runtime indexing + merge and iteration - [**Chapter 05 Sandard Library: Pointers**](./05-pointers.md) - + RAII and reference counting - + `std::shared_ptr` - + `std::unique_ptr` - + `std::weak_ptr` + + 5.1 RAII and reference counting + + 5.2 `std::shared_ptr` + + 5.3 `std::unique_ptr` - [**Chapter 06 Sandard Library: Regular Expression**](./06-regex.md) - + Regular Expression Introduction + + 6.1 Regular Expression Introduction + Normal characters + Special characters + Determinative - + `std::regex` + + 6.2 `std::regex` and related + `std::regex` + `std::regex_match` + `std::match_results` - [**Chapter 07 Sandard Library: Threads and Concurrency**](./07-thread.md) - + `std::thread` - + `std::mutex` - + `std::unique_lock` - + `std::future` - + `std::packaged_task` - + `std::condition_variable` + + 7.1 `std::thread` + + 7.2 `std::mutex` and `std::unique_lock` + + 7.3 `std::future` and `std::packaged_task` + + 7.4 `std::condition_variable` + + 7.5 `std::atomic` and memory order + + 7.6 Transactional memory - [**Chapter 08 Sandard Library: File System**](./08-filesystem.md) + + 8.1 Documents and links + + 8.2 `std::filesystem` - [**Chapter 09 Minor Features**](./09-others.md) - + New Types + + 9.1 New Types + `long long int` - + `noexcept` - + Literal + + 9.2 `noexcept` and its operates + + 9.3 Literal + Raw string literal + Custom string literal - + Math Library + + 9.4 Math Library - [**Chapter 10 Outlook: Introduction of C++20**](./10-cpp20.md) + Concept + Range + Module + Coroutine -- [**Appendix: Further Study Materials**](./appendix.md) +- [**Appendix 1: Further Study Materials**](./appendix1.md) +- [**Appendix 2: Modern C++ Best Practices**](./appendix2.md) Table of Content | Last Chapter | [Next Chapter: Preface](./00-preface.md) ## Licenses -Creative Commons License
This work is written by [Ou Changkun](https://changkun.de) and licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. The code of this repository is open sourced under the [MIT license](./LICENSE). \ No newline at end of file +Creative Commons License
This work was written by [Ou Changkun](https://changkun.de) and licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. The code of this repository is open sourced under the [MIT license](./LICENSE). \ No newline at end of file diff --git a/book/zh-cn/00-preface.md b/book/zh-cn/00-preface.md index 1fc7908b..d2ac8f06 100644 --- a/book/zh-cn/00-preface.md +++ b/book/zh-cn/00-preface.md @@ -9,9 +9,9 @@ order: 0 ## 引言 C++ 是一个用户群体相当大的语言。从 C++98 的出现到 C++11 的正式定稿经历了长达十年多之久的积累。C++14/17 则是作为对 C++11 的重要补充和优化,所有这些新标准中扩充的特性,给 C++ 这门语言注入了新的活力。 -那些还在坚持使用**传统 C++**(本书把 C++98 及其之前的 C++ 特性均称之为传统 C++)而未接触过 C++11/14/17 的 C++ 程序员在见到诸如 Lambda 表达式这类全新特性时,甚至会流露出『学的不是同一门语言』的惊叹之情。 +那些还在坚持使用**传统 C++**(本书把 C++98 及其之前的 C++ 特性均称之为传统 C++)而未接触过 C++11/14/17/20 的 C++ 程序员在见到诸如 Lambda 表达式这类全新特性时,甚至会流露出『学的不是同一门语言』的惊叹之情。 -**C++1x** (或**现代 C++**,本书中均指 C++11/14/17) 为传统 C++ 注入的大量特性使得整个 C++ 变得更加像一门现代化的语言。C++1x 不仅仅增强了 C++ 语言自身的可用性,`auto` 关键字语义的修改使得我们更加有信心来操控极度复杂的模板类型。同时还对语言运行期进行了大量的强化,Lambda 表达式的出现让 C++ 具有了『匿名函数』的『闭包』特性,而这一特性几乎在现代的编程语言(诸如 Python/Swift/... )中已经司空见惯,右值引用的出现解决了 C++ 长期以来被人诟病的临时对象效率问题等等。 +**C++1x** (或**现代 C++**,本书中均指 C++11/14/17/20) 为传统 C++ 注入的大量特性使得整个 C++ 变得更加像一门现代化的语言。C++1x 不仅仅增强了 C++ 语言自身的可用性,`auto` 关键字语义的修改使得我们更加有信心来操控极度复杂的模板类型。同时还对语言运行期进行了大量的强化,Lambda 表达式的出现让 C++ 具有了『匿名函数』的『闭包』特性,而这一特性几乎在现代的编程语言(诸如 Python/Swift/... )中已经司空见惯,右值引用的出现解决了 C++ 长期以来被人诟病的临时对象效率问题等等。 C++17 则是近三年依赖 C++ 社区一致推进的方向,也指出了**现代C++**编程的一个重要发展方向。尽管它的出现并不如 C++11 的分量之重,但它包含了大量小而美的语言与特性(例如结构化绑定),这些特性的出现再一次修正了我们在 C++ 中的编程范式。 @@ -36,7 +36,7 @@ C++17 则是近三年依赖 C++ 社区一致推进的方向,也指出了**现 本书每章中都出现了大量的代码,如果你在跟随本书介绍特性的思路编写自己的代码遇到问题时,不妨读一读随书附上的源码,你可以在[这里](../code)中找到书中介绍过的全部的源码,所有代码按章节组织,文件夹名称为章节序号。 -[返回目录](./toc.md) | 上一章 | [下一章 迈向 C++11/14/17](./01-intro.md) +[返回目录](./toc.md) | 上一章 | [下一章 迈向现代 C++](./01-intro.md) ## 许可 diff --git a/book/zh-cn/01-intro.md b/book/zh-cn/01-intro.md index cc2cb566..31c8234f 100644 --- a/book/zh-cn/01-intro.md +++ b/book/zh-cn/01-intro.md @@ -1,10 +1,10 @@ --- -title: 第 1 章 迈向 C++11/14/17 +title: 第 1 章 迈向现代 C++ type: book-zh-cn order: 1 --- -# 第 1 章 迈向 C++11/14/17 +# 第 1 章 迈向现代 C++ [TOC] diff --git a/book/zh-cn/02-usability.md b/book/zh-cn/02-usability.md index 3bf758ed..464ce251 100644 --- a/book/zh-cn/02-usability.md +++ b/book/zh-cn/02-usability.md @@ -931,7 +931,7 @@ std::cout << new_enum::value3 << std::endl ## 总结 -本节介绍了 C++11/14/17 中对语言可用性的增强,其中笔者认为最为重要的几个特性是几乎所有人都需要了解并熟练使用的: +本节介绍了 C++11/14/17/20 中对语言可用性的增强,其中笔者认为最为重要的几个特性是几乎所有人都需要了解并熟练使用的: 1. auto 类型推导 2. 范围 for 迭代 diff --git a/book/zh-cn/10-cpp20.md b/book/zh-cn/10-cpp20.md index 091b4e04..c2bd8a94 100644 --- a/book/zh-cn/10-cpp20.md +++ b/book/zh-cn/10-cpp20.md @@ -130,7 +130,7 @@ Concepts TS 的发布到最后一次 C++17 的讨论会只相隔了不到四个 1. [Final features of C++17](https://meetingcpp.com/index.php/br/items/final-features-of-c17.html) 2. [C++17: will it be great or just ok?](https://codeplay.com/public/uploaded/filehost/0cbdaf_c++17post-oulu2016.pdf) 3. [Why Concepts didn't make C++17?](http://honermann.net/blog/2016/03/06/why-concepts-didnt-make-cxx17/) -4. [C++11/14/17 编译器支持情况](http://en.cppreference.com/w/cpp/compiler_support) +4. [C++11/14/17/20 编译器支持情况](http://en.cppreference.com/w/cpp/compiler_support) ## 许可 diff --git a/book/zh-cn/appendix1.md b/book/zh-cn/appendix1.md index 3d55e759..dfeb2f2d 100644 --- a/book/zh-cn/appendix1.md +++ b/book/zh-cn/appendix1.md @@ -8,7 +8,7 @@ order: 11 首先,恭喜你阅读完本书 🎉 !笔者希望本书有提起你对现代 C++ 的兴趣。 -正如本书引言部分提到的,本书只是一本带你快速领略现代 C++ 11/14/17 新特性的读物,而非进阶学习实践 C++『黑魔法』的内容。笔者当然也想到了这个需求,只是这样的内容非常艰深,鲜有受众。在此,笔者列出一些能够帮助你在此书基础之上进一步学习现代 C++ 的资料,希望能够祝你一臂之力: +正如本书引言部分提到的,本书只是一本带你快速领略现代 C++ 11/14/17/20 新特性的读物,而非进阶学习实践 C++『黑魔法』的内容。笔者当然也想到了这个需求,只是这样的内容非常艰深,鲜有受众。在此,笔者列出一些能够帮助你在此书基础之上进一步学习现代 C++ 的资料,希望能够祝你一臂之力: - [C++ 参考](http://en.cppreference.com/w) - [CppCon YouTube 频道](https://www.youtube.com/user/CppCon/videos) diff --git a/book/zh-cn/toc.md b/book/zh-cn/toc.md index 99ce6632..b0a9099b 100644 --- a/book/zh-cn/toc.md +++ b/book/zh-cn/toc.md @@ -1,11 +1,9 @@ -# 高速上手 C++ 11/14/17 - -> 正在向全面介绍 C++17 特性的内容过度 +# 高速上手 C++ 11/14/17/20 ## 目录 - [**序言**](./00-preface.md) -- [**第 1 章 迈向 C++11/14/17**](./01-intro.md) +- [**第 1 章 迈向现代 C++**](./01-intro.md) + 1.1 被弃用的特性 + 1.2 与 C 的兼容性 + 进一步阅读的参考文献 @@ -83,6 +81,8 @@ + 7.2 `std::mutex` 和 `std::unique_lock` + 7.3 `std::future` 和 `std::packaged_task` + 7.4 `std::condition_variable` + + 7.5 `std::atomic` 与内存顺序 + + 7.6 事务内存 - [**第 8 章 标准库: 文件系统**](./08-filesystem.md) + 8.1 文档与链接 + 8.2 `std::filesystem` diff --git a/pdf/en-us/Makefile b/pdf/en-us/Makefile index 8830fe66..a7b3c399 100644 --- a/pdf/en-us/Makefile +++ b/pdf/en-us/Makefile @@ -1,4 +1,4 @@ -title = 'C++11/14/17 On the Fly' +title = 'C++11/14/17/20 On the Fly' filename = 'modern-cpp-tutorial' outputname='modern-cpp-tutorial' revision = $(shell git describe --always --tags) diff --git a/pdf/en-us/aggregator.py b/pdf/en-us/aggregator.py index 1894b5cc..90eb8a0e 100644 --- a/pdf/en-us/aggregator.py +++ b/pdf/en-us/aggregator.py @@ -10,7 +10,7 @@ with open('modern-cpp-tutorial.md', 'w') as outfile: outfile.write("""--- -title: "C++11/14/17 On the Fly" +title: "C++11/14/17/20 On the Fly" author: Changkun Ou copyright: cc-by-nc-nd 4.0 --- diff --git a/pdf/en-us/meta/template.tex b/pdf/en-us/meta/template.tex index ca52aa67..7e918288 100644 --- a/pdf/en-us/meta/template.tex +++ b/pdf/en-us/meta/template.tex @@ -161,7 +161,7 @@ \thispagestyle{plain} \begin{center} - {\LARGE\textbf{C++11/14/17 On the Fly}} + {\LARGE\textbf{C++11/14/17/20 On the Fly}} \vspace{1em} {\large Changkun Ou (hi@changkun.us)} @@ -172,7 +172,7 @@ \vspace{1em} \textbf{\large License} - \noindent This work is written by \href{https://github.com/changkun}{Ou Changkun} and licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. \texttt{\small http://creativecommons.org/licenses/by-nc-nd/4.0/} + \noindent This work was written by \href{https://github.com/changkun}{Ou Changkun} and licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. \texttt{\small http://creativecommons.org/licenses/by-nc-nd/4.0/} \vspace{8em} \includegraphics{../../assets/cover-2nd-en} diff --git a/pdf/zh-cn/Makefile b/pdf/zh-cn/Makefile index bf1771a4..fafe598d 100644 --- a/pdf/zh-cn/Makefile +++ b/pdf/zh-cn/Makefile @@ -1,4 +1,4 @@ -title = '高速上手 C++11/14/17' +title = '高速上手 C++11/14/17/20' filename = 'modern-cpp-tutorial' outputname='modern-cpp-tutorial' revision = $(shell git describe --always --tags) diff --git a/pdf/zh-cn/aggregator.py b/pdf/zh-cn/aggregator.py index 2af6138b..a5555fa0 100755 --- a/pdf/zh-cn/aggregator.py +++ b/pdf/zh-cn/aggregator.py @@ -9,7 +9,7 @@ with open('modern-cpp-tutorial.md', 'w') as outfile: outfile.write("""--- -title: "高速上手 C++11/14/17" +title: "高速上手 C++11/14/17/20" author: 欧长坤 copyright: cc-by-nc-nd 4.0 --- diff --git a/pdf/zh-cn/meta/template.tex b/pdf/zh-cn/meta/template.tex index b7609e33..60623577 100644 --- a/pdf/zh-cn/meta/template.tex +++ b/pdf/zh-cn/meta/template.tex @@ -164,7 +164,7 @@ \thispagestyle{plain} \begin{center} - {\LARGE\textbf{高速上手 C++11/14/17}} + {\LARGE\textbf{高速上手 C++11/14/17/20}} \vspace{1em} {\large 欧长坤 (hi@changkun.us)} diff --git a/website/README.md b/website/README.md index 6fbc31fe..ecff5b2e 100755 --- a/website/README.md +++ b/website/README.md @@ -1,6 +1,6 @@ # changkun.de/modern-cpp -Welcome to Modern C++ Tutorial! This site is built with [hexo](http://hexo.io/). Site content is written in Markdown format located in `../book`. And all static files will be built into `./public`, which is served by a nginx server at [changkun.de](https://changkun.de). +Welcome to Modern C++ Tutorial! This site is built with [hexo](http://hexo.io/). Site content was written in Markdown format located in `../book`. And all static files will be built into `./public`, which is served by a nginx server at [changkun.de](https://changkun.de). ## Requirements diff --git a/website/_config.yml b/website/_config.yml index 2dbb5f51..de1989df 100755 --- a/website/_config.yml +++ b/website/_config.yml @@ -1,6 +1,6 @@ # Site Configuration -title: 高速上手 C++ 11/14/17 -subtitle: C++ 11/14/17 On the Fly +title: 高速上手 C++ 11/14/17/20 +subtitle: C++ 11/14/17/20 On the Fly description: "欧长坤" author: 欧长坤 email: hi[at]changkun.us diff --git a/website/themes/moderncpp/_config.yml b/website/themes/moderncpp/_config.yml index eb6dae0e..6f30f182 100755 --- a/website/themes/moderncpp/_config.yml +++ b/website/themes/moderncpp/_config.yml @@ -1,4 +1,4 @@ -site_description: "现代 C++ | 高速上手 C++ 11/14/17" +site_description: "现代 C++ | 高速上手 C++ 11/14/17/20" google_analytics: root_domain: changkun.de/modern-cpp moderncpp_version: 2.0.0 diff --git a/website/themes/moderncpp/layout/index.ejs b/website/themes/moderncpp/layout/index.ejs index 44bac673..6362a783 100755 --- a/website/themes/moderncpp/layout/index.ejs +++ b/website/themes/moderncpp/layout/index.ejs @@ -13,7 +13,7 @@

欧长坤 著

- 高速上手
C++ 11/14/17 + 高速上手
C++ 11/14/17/20

第二版

diff --git a/website/themes/moderncpp/layout/layout.ejs b/website/themes/moderncpp/layout/layout.ejs index d4e4cc0f..cd4483ee 100755 --- a/website/themes/moderncpp/layout/layout.ejs +++ b/website/themes/moderncpp/layout/layout.ejs @@ -3,7 +3,7 @@ - <%- page.title ? page.title : '' %> 高速上手 C++ 11/14/17 - C++ 11/14/17 On the Fly + <%- page.title ? page.title : '' %> 高速上手 C++ 11/14/17/20 - C++ 11/14/17/20 On the Fly @@ -23,7 +23,7 @@ -

> +
>
diff --git a/website/themes/moderncpp/layout/partials/header.ejs b/website/themes/moderncpp/layout/partials/header.ejs index 9d34fb12..d137d6d2 100755 --- a/website/themes/moderncpp/layout/partials/header.ejs +++ b/website/themes/moderncpp/layout/partials/header.ejs @@ -1,7 +1,7 @@