From 6629382ed2c81e049bbd79d032cbeff9c07d425b Mon Sep 17 00:00:00 2001 From: Changkun Ou Date: Sun, 7 Jun 2026 21:12:40 +0200 Subject: [PATCH 01/20] Remove DigitalOcean sponsorship blocks --- README-zh-cn.md | 7 ------- README.md | 7 ------- website/src/modern-cpp/about/ack.md | 16 +--------------- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/README-zh-cn.md b/README-zh-cn.md index 22a3de6d..3ab8ae7e 100644 --- a/README-zh-cn.md +++ b/README-zh-cn.md @@ -50,13 +50,6 @@ $ make build 笔者时间和水平有限,如果读者发现书中内容的错误,欢迎提 [Issue](https://github.com/changkun/modern-cpp-tutorial/issues),或者直接提 [Pull request](https://github.com/changkun/modern-cpp-tutorial/pulls)。详细贡献指南请参考[如何参与贡献](CONTRIBUTING.md),由衷感谢每一位指出本书中出现错误的读者,包括但不限于 [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors)。 -

本项目还由以下产品提供赞助支持:

-

- - - -

- ## 许可 知识共享许可协议 diff --git a/README.md b/README.md index f44c816b..70c72465 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,6 @@ The author has limited time and language skills. If readers find any mistakes in The author is grateful to all contributors, including but not limited to [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors). -

This project is also supported by:

-

- - - -

- ## Licenses 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). diff --git a/website/src/modern-cpp/about/ack.md b/website/src/modern-cpp/about/ack.md index 1e3107bf..144287b3 100644 --- a/website/src/modern-cpp/about/ack.md +++ b/website/src/modern-cpp/about/ack.md @@ -12,20 +12,6 @@ The author has limited time and language skills. If readers find any mistakes in The author is grateful to all contributors, including but not limited to [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors). -

This project is also supported by:

-

- - - -

- ## 致谢 -笔者时间和水平有限,如果读者发现书中内容的错误,欢迎提 [Issue](https://github.com/changkun/modern-cpp-tutorial/issues),或者直接提 [Pull request](https://github.com/changkun/modern-cpp-tutorial/pulls)。详细贡献指南请参考[如何参与贡献](CONTRIBUTING.md),由衷感谢每一位指出本书中出现错误的读者,包括但不限于 [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors)。 - -

本项目还由以下产品提供赞助支持:

-

- - - -

\ No newline at end of file +笔者时间和水平有限,如果读者发现书中内容的错误,欢迎提 [Issue](https://github.com/changkun/modern-cpp-tutorial/issues),或者直接提 [Pull request](https://github.com/changkun/modern-cpp-tutorial/pulls)。详细贡献指南请参考[如何参与贡献](CONTRIBUTING.md),由衷感谢每一位指出本书中出现错误的读者,包括但不限于 [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors)。 \ No newline at end of file From 66b1a38bb098acee746d2bae62c6b9e71beb30a4 Mon Sep 17 00:00:00 2001 From: Changkun Ou Date: Sun, 7 Jun 2026 21:12:41 +0200 Subject: [PATCH 02/20] website: show one language at a time on the homepage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the stacked Chinese+English heroes on the root page with a single hero plus a 中文/English toggle. The language is auto-detected from the browser on first visit and remembered in localStorage; the non-active language is hidden by default to avoid a flash of both. --- website/themes/moderncpp/layout/index.ejs | 52 ++++++++++++++++--- .../source/modern-cpp/css/index.styl | 39 +++++++++++++- 2 files changed, 82 insertions(+), 9 deletions(-) diff --git a/website/themes/moderncpp/layout/index.ejs b/website/themes/moderncpp/layout/index.ejs index f5677d0f..3a414004 100755 --- a/website/themes/moderncpp/layout/index.ejs +++ b/website/themes/moderncpp/layout/index.ejs @@ -10,12 +10,21 @@ -
+
+ + +
+ +
">
-

欧长坤 著

+

欧长坤 著

现代 C++ 教程

@@ -29,12 +38,12 @@
-
+
">
-

Changkun Ou

+

Changkun Ou

Modern C++ Tutorial

@@ -49,14 +58,43 @@
+ + - \ No newline at end of file + diff --git a/website/themes/moderncpp/source/modern-cpp/css/index.styl b/website/themes/moderncpp/source/modern-cpp/css/index.styl index f9afb1ce..ca33472c 100755 --- a/website/themes/moderncpp/source/modern-cpp/css/index.styl +++ b/website/themes/moderncpp/source/modern-cpp/css/index.styl @@ -23,8 +23,41 @@ body .logo display: none +// Before JS runs, show only the Chinese sections to avoid a flash of both +// languages; the toggle script reveals the right one on load. +.lang[data-lang="en"] + display: none + +#lang-switch + text-align: center + padding: 90px 40px 0 200px + button.lang-btn + background: transparent + border: 1px solid rgba(126, 45, 54, 0.4) + color: $theme + font-size: 0.95em + font-weight: 600 + letter-spacing: .05em + padding: 6px 16px + margin: 0 4px + border-radius: 4px + cursor: pointer + transition: all .2s ease + &:hover + border-color: $theme + &.active + background: $theme + color: #fff + border-color: $theme + .flag + width: 15px + height: 15px + margin-right: 6px + vertical-align: middle + margin-bottom: 2px + #hero - padding: 100px 40px 40px 200px + padding: 60px 40px 40px 200px background-color: #fff .inner max-width: $width @@ -120,8 +153,10 @@ body display: none #mobile-bar display: block + #lang-switch + padding: 70px 40px 0 #hero - padding: 70px 40px 50px + padding: 20px 40px 50px .hero-logo float: none margin: 30px 0 30px From add210d419c37f5b23c79ad5bdbb274abb88d228 Mon Sep 17 00:00:00 2001 From: Changkun Ou Date: Sun, 7 Jun 2026 21:18:53 +0200 Subject: [PATCH 03/20] code: sync structured-binding example with rewritten book MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The why-first rewrite of Chapter 2 added a second structured-binding example — binding key/value pairs while iterating a std::map. Extend the companion file so the downloadable code matches what the book now shows. This was the only code block that changed across the whole book since the companion code was last synced (f148826). --- code/2/2.05.structured.binding.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/2/2.05.structured.binding.cpp b/code/2/2.05.structured.binding.cpp index 48963f3f..7896f299 100644 --- a/code/2/2.05.structured.binding.cpp +++ b/code/2/2.05.structured.binding.cpp @@ -10,13 +10,22 @@ #include #include #include +#include std::tuple f() { return std::make_tuple(1, 2.3, "456"); } int main() { + // Unpack a tuple straight into named variables. auto [x, y, z] = f(); std::cout << x << ", " << y << ", " << z << std::endl; + + // Bind each key/value pair while iterating an associative container, + // instead of writing it->first / it->second. + std::map scores{{"alice", 90}, {"bob", 80}}; + for (const auto& [name, score] : scores) { + std::cout << name << ": " << score << '\n'; + } return 0; } From 78d2505d29fdea79e7a2a754fac454d2c2930333 Mon Sep 17 00:00:00 2001 From: Changkun Ou Date: Sun, 7 Jun 2026 21:46:49 +0200 Subject: [PATCH 04/20] website: rebrand version strings to C++11 to C++26 The book was rebranded from C++11/14/17/20 to 'C++11 to C++26', but the site title, header, hero, and meta description still showed the old range. Bring them in line with the book and the site _config. --- website/themes/moderncpp/_config.yml | 2 +- website/themes/moderncpp/layout/index.ejs | 4 ++-- website/themes/moderncpp/layout/layout.ejs | 2 +- website/themes/moderncpp/layout/partials/header.ejs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/website/themes/moderncpp/_config.yml b/website/themes/moderncpp/_config.yml index 4fb7e026..5c79add1 100755 --- a/website/themes/moderncpp/_config.yml +++ b/website/themes/moderncpp/_config.yml @@ -1,4 +1,4 @@ -site_description: "Modern C++ Tutorial | C++ 11/14/17/20 On the Fly | 现代 C++ 教程 | 高速上手 C++11/14/17/20" +site_description: "Modern C++ Tutorial | C++11 to C++26 On the Fly | 现代 C++ 教程 | 高速上手 C++11 到 C++26" 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 3a414004..1ae64011 100755 --- a/website/themes/moderncpp/layout/index.ejs +++ b/website/themes/moderncpp/layout/index.ejs @@ -28,7 +28,7 @@

现代 C++ 教程

-

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

+

高速上手 C++11 到 C++26

第二版

">🇨🇳 在线阅读 @@ -47,7 +47,7 @@

Modern C++ Tutorial

-

C++ 11/14/17/20 On the Fly

+

C++11 to C++26 On the Fly

SECOND EDITION

">🇬🇧 Read Online diff --git a/website/themes/moderncpp/layout/layout.ejs b/website/themes/moderncpp/layout/layout.ejs index 442f1810..e3f631c4 100755 --- a/website/themes/moderncpp/layout/layout.ejs +++ b/website/themes/moderncpp/layout/layout.ejs @@ -3,7 +3,7 @@ - <%- page.title ? page.title : '' %> 现代 C++ 教程: 高速上手 C++ 11/14/17/20 - Modern C++ Tutorial: C++ 11/14/17/20 On the Fly + <%- page.title ? page.title : '' %> 现代 C++ 教程: 高速上手 C++11 到 C++26 - Modern C++ Tutorial: C++11 to C++26 On the Fly diff --git a/website/themes/moderncpp/layout/partials/header.ejs b/website/themes/moderncpp/layout/partials/header.ejs index e9f07ba0..21581ea8 100755 --- a/website/themes/moderncpp/layout/partials/header.ejs +++ b/website/themes/moderncpp/layout/partials/header.ejs @@ -2,10 +2,10 @@