Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ECQZXC/modern-cpp-tutorial
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: changkun/modern-cpp-tutorial
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
Loading
Showing with 4,586 additions and 1,977 deletions.
  1. +12 −0 .github/FUNDING.yml
  2. +29 −0 .github/workflows/website.yml
  3. +6 −1 .gitignore
  4. +0 −18 .travis.yml
  5. BIN .travis/travis.enc
  6. +1 −1 LICENSE
  7. +4 −3 Makefile
  8. +4 −4 README-zh-cn.md
  9. +3 −4 README.md
  10. +0 −11 assets/community.md
  11. BIN assets/qq-group.png
  12. +13 −13 book/en-us/00-preface.md
  13. +13 −13 book/en-us/01-intro.md
  14. +75 −83 book/en-us/02-usability.md
  15. +170 −156 book/en-us/03-runtime.md
  16. +18 −18 book/en-us/04-containers.md
  17. +31 −26 book/en-us/05-pointers.md
  18. +56 −48 book/en-us/06-regex.md
  19. +185 −178 book/en-us/07-thread.md
  20. +2 −2 book/en-us/08-filesystem.md
  21. +31 −33 book/en-us/09-others.md
  22. +12 −12 book/en-us/10-cpp20.md
  23. +2 −2 book/en-us/appendix1.md
  24. +1 −1 book/en-us/appendix2.md
  25. +1 −1 book/en-us/toc.md
  26. +5 −5 book/zh-cn/00-preface.md
  27. +7 −6 book/zh-cn/01-intro.md
  28. +65 −70 book/zh-cn/02-usability.md
  29. +63 −55 book/zh-cn/03-runtime.md
  30. +4 −4 book/zh-cn/04-containers.md
  31. +16 −16 book/zh-cn/05-pointers.md
  32. +20 −12 book/zh-cn/06-regex.md
  33. +35 −29 book/zh-cn/07-thread.md
  34. +2 −2 book/zh-cn/08-filesystem.md
  35. +4 −4 book/zh-cn/09-others.md
  36. +3 −3 book/zh-cn/10-cpp20.md
  37. +3 −3 book/zh-cn/appendix1.md
  38. +2 −2 book/zh-cn/appendix2.md
  39. +2 −2 book/zh-cn/toc.md
  40. +9 −9 code/2/2.06.auto.cpp
  41. +2 −1 code/3/3.1.lambda.basic.cpp
  42. +1 −1 code/3/3.3.rvalue.cpp
  43. +1 −0 code/7/7.2.critical.section.a.cpp
  44. +1 −0 code/7/7.3.critical.section.b.cpp
  45. +2 −2 docker/Dockerfile
  46. +1 −1 epub/en-us/Makefile
  47. +1 −1 epub/en-us/filter.py
  48. +1 −1 epub/zh-cn/Makefile
  49. +1 −1 epub/zh-cn/filter.py
  50. +2 −2 pdf/en-us/Makefile
  51. +2 −2 pdf/en-us/aggregator.py
  52. +2 −2 pdf/en-us/meta/template.tex
  53. +2 −2 pdf/zh-cn/Makefile
  54. +2 −2 pdf/zh-cn/aggregator.py
  55. +2 −2 pdf/zh-cn/meta/template.tex
  56. +0 −2 website/Makefile
  57. +1 −1 website/_config.yml
  58. +1 −1 website/filter.py
  59. +3,638 −1,087 website/package-lock.json
  60. +7 −7 website/package.json
  61. +2 −2 website/src/modern-cpp/about/copyright.md
  62. +2 −2 website/themes/moderncpp/layout/index.ejs
  63. +1 −1 website/themes/moderncpp/layout/layout.ejs
  64. +2 −2 website/themes/moderncpp/layout/page.ejs
  65. +0 −1 website/themes/moderncpp/layout/partials/main_menu.ejs
  66. +0 −1 website/themes/moderncpp/layout/partials/main_menu_en.ejs
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: [changkun] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
29 changes: 29 additions & 0 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Website

on:
push:
branches: [ master ]

jobs:

build:
name: Website
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
- name: build
env:
USER: ${{ secrets.SERVER_USER }}
TARGET: ${{ secrets.SERVER_PATH }}
KEY: ${{ secrets.SERVER_KEY }}
DOMAIN: ${{ secrets.SERVER_DOMAIN }}
run: |
make build
mkdir ~/.ssh
echo "$KEY" | tr -d '\r' > ~/.ssh/id_ed25519
chmod 400 ~/.ssh/id_ed25519
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
ssh-keyscan -H $DOMAIN >> ~/.ssh/known_hosts
scp -r website/public/modern-cpp/* $USER@$DOMAIN:$TARGET
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -40,6 +40,11 @@ website/src/modern-cpp/zh-cn/*
website/src/modern-cpp/en-us/*
website/src/modern-cpp/exercises
website/src/modern-cpp/code
website/src/modern-cpp/about/donate.md
website/src/modern-cpp/assets/alipay.jpg
website/src/modern-cpp/assets/cover-2nd-en.png
website/src/modern-cpp/assets/cover-2nd.png
website/src/modern-cpp/assets/figures/*
website/src/modern-cpp/assets/cover-2nd-en-logo.png
website/src/modern-cpp/assets/cover-2nd-logo.png
website/src/modern-cpp/assets/figures/*
website/src/modern-cpp/assets/wechat.jpg
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

Binary file removed .travis/travis.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 - 2019 Changkun Ou <hi@changkun.us>
Copyright (c) 2016 - 2020 Changkun Ou <hi@changkun.de>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DOCKER_ENV=changkun/modern-cpp-tutorial:build-env
NAME=modern-cpp-tutorial
DOCKER_ENV=changkun/$(NAME):build-env
TARGET = pdf epub
LANGS = zh-cn en-us
ALL_BUILDS = website $(TARGET)
@@ -11,14 +12,14 @@ $(TARGET): $(LANGS)
mkdir -p website/public/modern-cpp/$@/
for lang in $^ ; do \
cd $@/$${lang} && make && make clean && cd ../..; \
mv $@/$${lang}/modern-cpp-tutorial.$@ website/public/modern-cpp/$@/modern-cpp-tutorial-$${lang}.$@; \
mv $@/$${lang}/$(NAME).$@ website/public/modern-cpp/$@/$(NAME)-$${lang}.$@; \
done

website:
cd website && make

build:
docker run --rm -v `pwd`:/modern-cpp-tutorial -it $(DOCKER_ENV) make
docker run --rm -v `pwd`:/$(NAME) $(DOCKER_ENV) make

# dev

8 changes: 4 additions & 4 deletions README-zh-cn.md
Original file line number Diff line number Diff line change
@@ -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)

## 本书目的

@@ -22,7 +22,7 @@
你可以选择以下几种阅读方式:

1. [GitHub 在线](./book/zh-cn/toc.md)
2. [PDF 文档](https://changkun.de/modern-cpp/modern-cpp-tutorial-zh-cn.pdf)
2. [PDF 文档](https://changkun.de/modern-cpp/pdf/modern-cpp-tutorial-zh-cn.pdf)
3. [EPUB 文档](https://changkun.de/modern-cpp/epub/modern-cpp-tutorial-zh-cn.epub)
4. [网站](https://changkun.de/modern-cpp/)

@@ -59,6 +59,6 @@ $ make build

## 许可

<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="知识共享许可协议" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/80x15.png" /></a>
<a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="知识共享许可协议" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/80x15.png" /></a>

本书系[欧长坤](https://github.com/changkun)著,采用[知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议](http://creativecommons.org/licenses/by-nc-nd/4.0/)许可。项目中代码使用 MIT 协议开源,参见[许可](./LICENSE)
本书系[欧长坤](https://github.com/changkun)著,采用[知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议](https://creativecommons.org/licenses/by-nc-nd/4.0/)许可。项目中代码使用 MIT 协议开源,参见[许可](./LICENSE)
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).
@@ -35,7 +34,7 @@ Each chapter of this book contains a lot of code. If you encounter problems whil

## Exercises

There are few exercises at the end of each chapter of the book. These are ment to test whether you have mastered the knowledge in the current chapter. You can find the possible answer to the problem [here](./exercises). Again, the folder name is the chapter number.
There are few exercises at the end of each chapter of the book. These are meant to test whether you have mastered the knowledge in the current chapter. You can find the possible answer to the problem [here](./exercises). Again, the folder name is the chapter number.

## Website

@@ -66,4 +65,4 @@ The author is grateful to all contributors, including but not limited to [Contri

## Licenses

<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 was 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).
<a rel="license" href="https://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 was written by [Ou Changkun](https://changkun.de) and licensed under a <a rel="license" href="https://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).
11 changes: 0 additions & 11 deletions assets/community.md

This file was deleted.

Binary file removed assets/qq-group.png
Binary file not shown.
26 changes: 13 additions & 13 deletions book/en-us/00-preface.md
Original file line number Diff line number Diff line change
@@ -10,36 +10,36 @@ order: 0

## Introduction

C++ user group is a fairly large. From the advent of C++98 to the official finalization of C++11, it has accumulated over a decade. C++14/17 is an important complement and optimization for C++11, and C++20 brings this language to the door of modernization. The extended features of all these new standards are given to the C++ language. Infused with new vitality.
C++ programmers, who are still using **traditional C++** (this book refers to C++98 and its previous C++ standards as traditional C++), may even amazed by the fact that they are not using the same language while reading modern C++ code.
The C++ programming language owns a fairly large user group. From the advent of C++98 to the official finalization of C++11, it has continued to stay relevant. C++14/17 is an important complement and optimization for C++11, and C++20 brings this language to the door of modernization. The extended features of all these new standards are integrated into the C++ language and infuse it with new vitality.
C++ programmers who are still using **traditional C++** (this book refers to C++98 and its previous standards as traditional C++) may even amazed by the fact that they are not using the same language while reading modern C++ code.

**Modern C++** (this book refers to C++11/14/17/20) introduces a lot of features into traditional C++, which makes the whole C++ become language that modernized. Modern C++ not only enhances the usability of the C++ language itself, but the modification of the `auto` keyword semantics gives us more confidence in manipulating extremely complex template types. At the same time, a lot of enhancements have been made to the language runtime. The emergence of Lambda expressions has made C++ have the "closure" feature of "anonymous functions", which is almost in modern programming languages ​​(such as Python/Swift/.. It has become commonplace, and the emergence of rvalue references has solved the problem of temporary object efficiency that C++ has long been criticized.
**Modern C++** (this book refers to C++11/14/17/20) introduces many features into traditional C++ which bring the entire language to a new level of modernization. Modern C++ not only enhances the usability of the C++ language itself, but the modification of the `auto` keyword semantics gives us more confidence in manipulating extremely complex template types. At the same time, a lot of enhancements have been made to the language runtime. The emergence of Lambda expressions has given C++ the "closure" feature of "anonymous functions", which are in almost all modern programming languages ​​(such as Python, Swift, etc). It has become commonplace, and the emergence of rvalue references has solved the problem of temporary object efficiency that C++ has long been criticized for.

C++17 is the direction that has been promoted by the C++ community in the past three years. It also points out an important development direction of **modern C++** programming. Although it does not appear as much as C++11, it contains a large number of small and beautiful languages ​​and features (such as structured binding), and the appearance of these features once again corrects our programming paradigm in C++.

Modern C++ also adds a lot of tools and methods to its own standard library, such as `std::thread` at the level of the language itself, which supports concurrent programming and no longer depends on the underlying system on different platforms. The API implements cross-platform support at the language level; `std::regex` provides full regular expression support and more. C++98 has been proven to be a very successful "paradigm", and the emergence of modern C++ further promotes this paradigm, making C++ a better language for system programming and library development. Concepts provide verification on the compile-time of template parameters, further enhancing the usability of the language.
Modern C++ also adds a lot of tools and methods to its standard library such as `std::thread` at the level of the language itself, which supports concurrent programming and no longer depends on the underlying system on different platforms. The API implements cross-platform support at the language level; `std::regex` provides full regular expression support and more. C++98 has been proven to be a very successful "paradigm", and the emergence of modern C++ further promotes this paradigm, making C++ a better language for system programming and library development. Concepts verify the compile-time of template parameters, further enhancing the usability of the language.

In conclusion, as an advocate and practitioner of C++, we always maintain an open mind to accept new things, and we can promote the development of C++ faster, making this old and novel language more vibrant.

## Targets

- This book assumes that readers are already familiar with traditional C++ (i.e. C++98 or earlier), 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;
- This book assumes that readers are already familiar with traditional C++ (i.e. C++98 or earlier), 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 are well suited to read the book;

- 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++.
- 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 to offer a quick start for modern C++. Of course, advanced readers can also use this book to review and examine themselves on modern C++.

## Purpose

The book claims "On the Fly". Its intent is to provide a comprehensive introduction to the relevant features regarding modern C++ (before 2020s).
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.
Readers should aware that all of these features are not required. It should be leart when you really need it.
The book claims "On the Fly". It intends to provide a comprehensive introduction to the relevant features regarding modern C++ (before the 2020s).
Readers can choose interesting content according to the following table of contents to learn and quickly familiarize themselves with the new features that are available.
Readers should aware that all of these features are not required. It should be learned when you need it.

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.
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 come out.

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.
Also, 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 reading the book.

## Code

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.
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 is organized by chapter, the folder name is the chapter number.

## Exercises

@@ -49,4 +49,4 @@ There are few exercises At the end of each chapter of the book. It is for testin

## Licenses

<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 was 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).
<a rel="license" href="https://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 was written by [Ou Changkun](https://changkun.de) and licensed under a <a rel="license" href="https://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).
Loading