modern-cpp-tutorial Documentation

Modern C++ Tutorial: C++11 to C++26 On the Fly |

25,601 stars C++ C++ 1 file · ~1,720 tokens #cpp#cpp-tutorial#cpp11#cpp14#cpp17#cpp20#modern-cpp
RAW Doc

Docker & Self-Hosted Deployment Verified OCI

Deploy modern-cpp-tutorial on any server, homelab, or cloud container platform.

1-Click Terminal Command
bash (docker run)
docker run -d --name modern-cpp-tutorial --restart always changkun/modern-cpp-tutorial:latest

File: README.md

Modern C++ Tutorial: C++11 to C++26 On the Fly

Purpose

The book claims to be "On the Fly". Its intent is to provide a comprehensive introduction to the relevant features of modern C++ (from C++11 through C++26).
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 be aware that not all of these features are required. Instead, it should be learned when you really need it.

At the same time, instead of coding-only, the book introduces the historical background of its technical requirements (as simple as possible), which provides great help in understanding why these features came out.

In addition, the author would like to encourage readers to use modern C++ directly in their new projects and migrate their old projects to modern C++ gradually after reading the book.

Targets

  • This book assumes that readers are already familiar with traditional C++ (i.e. C++98 or earlier), or at least that 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 introduces, to a certain extent, the dark magic of modern C++. However, these magic tricks 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++.

Start

You can choose from the following reading methods:

Code

Each chapter of this book contains a lot of code. If you encounter problems while writing your own code with the introductory features of the book, reading the source code attached to the book might be of help. You can find the book here. All the code is organized by chapter, the folder name is the chapter number.

Exercises

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

Website

The source code of the website of this book can be found here, which is built by hexo and vuejs. The website provides you another way of reading the book, it also adapts to mobile browsers.

Build

If you are interested in building everything locally, it is recommended using Docker. To build, simply run:

bash
$ make build

Acknowledgements

This book was originally written in Chinese by Changkun Ou.

The author has limited time and language skills. If readers find any mistakes in the book or any language improvements, please feel free to open an Issue or start a Pull request. For detailed guidelines and checklist, please refer to How to contribute.

The author is grateful to all contributors, including but not limited to Contributors.

Licenses

This work was written by Ou Changkun 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.


File: website/README.md

changkun.de/modern-cpp

Welcome to Modern C++ Tutorial! This site is built with hexo. 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.

Requirements

  • node.js
  • npm

Developing

Start from the terminal:

text
$ make    # build
$ make s  # start serve

File: README-zh-cn.md

现代 C++ 教程:高速上手 C++11 到 C++26

本书目的

本书号称『高速上手』,从内容上对现代 C++(从 C++11 到 C++26)的相关特性做了相对全面的介绍,读者可以自行根据下面的目录选取感兴趣的内容进行学习,快速熟悉需要了解的内容。这些特性并不需要全部掌握,只需针对自己的使用需求和特定的应用场景,学习、查阅最适合自己的新特性即可。

同时,本书在介绍这些特性的过程中,尽可能简单明了的介绍了这些特性产生的历史背景和技术需求,这为理解这些特性、运用这些特性提供了很大的帮助。

此外,笔者希望读者在阅读本书后,能够努力在新项目中直接使用现代 C++,并努力将旧项目逐步迁移到现代 C++。也算是笔者为推进现代 C++ 的普及贡献了一些绵薄之力。

目标读者

  1. 本书假定读者已经熟悉了传统 C++ ,至少在阅读传统 C++ 代码上不具备任何困难。换句话说,那些长期使用传统 C++进行编码的人、渴望在短时间内迅速了解现代 C++ 特性的人非常适合阅读本书;
  2. 本书一定程度上介绍了一些现代 C++ 的黑魔法,但这些魔法毕竟有限,不适合希望进阶学习现代 C++ 的读者,本书的定位系现代 C++ 的快速上手。当然,希望进阶学习的读者可以使用本书来回顾并检验自己对 现代 C++ 的熟悉度。

开始阅读

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

  1. GitHub 在线
  2. PDF 文档
  3. EPUB 文档
  4. 网站

相关代码

本书每章中都出现了大量的代码,如果你在跟随本书介绍特性的思路编写自己的代码遇到问题时,不妨读一读随书附上的源码,你可以在这里中找到书中介绍过的全部的源码,所有代码按章节组织,文件夹名称为章节序号。

随书习题

本书每章最后还加入了少量难度极小的习题,仅用于检验你是否能混合运用当前章节中的知识点。你可以在这里找到习题的答案,文件夹名称为章节序号。

本书网站

本书的网站源码可以在这里找到,由 hexo 和 vuejs 协同构建而成。网站旨在提供一个除 GitHub 之外的阅读方式,除了在桌面端访问之外,你也可以在移动端上阅读本书。

构建

如果你希望在本地编译整个仓库,我们建议使用 Docker。如果 Docker 在你的本地能正常使用,则可以简单的通过运行下面的指令完成构建:

bash
$ make build

致谢

笔者时间和水平有限,如果读者发现书中内容的错误,欢迎提 Issue,或者直接提 Pull request。详细贡献指南请参考如何参与贡献,由衷感谢每一位指出本书中出现错误的读者,包括但不限于 Contributors。

许可

本书系欧长坤著,采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议许可。项目中代码使用 MIT 协议开源,参见许可。