{"id":15025905,"url":"https://github.com/downdemo/cpp-templates-2ed","last_synced_at":"2025-05-14T15:10:05.221Z","repository":{"id":37739532,"uuid":"175356781","full_name":"downdemo/Cpp-Templates-2ed","owner":"downdemo","description":"Master Modern C++(11/14/17/20) Templates: TMP, SFINAE, Concepts, CRTP, Variadic Magic, and Compile-Time Sorcery","archived":false,"fork":false,"pushed_at":"2025-01-24T15:09:36.000Z","size":51,"stargazers_count":1633,"open_issues_count":0,"forks_count":284,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-04-04T23:03:02.687Z","etag":null,"topics":["cpp-templates","template-metaprogramming"],"latest_commit_sha":null,"homepage":"https://downdemo.github.io/Cpp-Templates-2ed/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/downdemo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-13T06:05:00.000Z","updated_at":"2025-04-04T14:16:42.000Z","dependencies_parsed_at":"2024-11-11T02:31:54.882Z","dependency_job_id":"83a9cfbb-6328-4a57-8502-2b944d4f1db0","html_url":"https://github.com/downdemo/Cpp-Templates-2ed","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"97f691c9039dafaec377e20cc9a840094b46cc66"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/downdemo%2FCpp-Templates-2ed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/downdemo%2FCpp-Templates-2ed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/downdemo%2FCpp-Templates-2ed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/downdemo%2FCpp-Templates-2ed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/downdemo","download_url":"https://codeload.github.com/downdemo/Cpp-Templates-2ed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505871,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp-templates","template-metaprogramming"],"created_at":"2024-09-24T20:03:18.453Z","updated_at":"2025-04-12T01:51:39.008Z","avatar_url":"https://github.com/downdemo.png","language":"C++","readme":"* C++ [模板](https://en.cppreference.com/w/cpp/language/templates)技术是泛型编程的核心，但囿于编译器技术限制，不得不带着缺陷诞生，语法晦涩，报错冗长，难以调试，应用层开发较少使用，相关技术书籍匮乏，因此掌握难度较大。模板相关的经典技术书籍主要有三本，分别是 2001 年出版的 [*Modern C++ Design*](https://book.douban.com/subject/1755195/)、2002 年出版的 [*C++ Templates*](https://book.douban.com/subject/1455780/)、2004 年出版的 [*C++ Template Metaprogramming*](https://book.douban.com/subject/1920800/)。三者基于的 C++ 标准都是 C++98，*Modern C++ Design* 涉及 [Andrei Alexandrescu](https://en.wikipedia.org/wiki/Andrei_Alexandrescu) 写书时配套的 [Loki](http://loki-lib.sourceforge.net/)，*C++ Template Metaprogramming* 涉及 [Boost](https://www.boost.org/)，二者以介绍元编程（模板技术的一种应用）为主，只有 *C++ Templates* 主要介绍 C++98 标准的模板技术。时过境迁，C++ 标准的更新逐步修复了一些语法缺陷，减少了使用者的心智负担，并引入了语法糖和工具，让编写模板越来越简单。2017 年 9 月 25 日，基于 C++17 标准，[*C++ Templates 2ed*](https://book.douban.com/subject/11939436/) 出版，填补了十多年间模板技术进化时相关书籍的空白，堪称最全面的模板教程，也是对 C++11/14/17 特性介绍最为全面的书籍之一。个人完整学习[原书](https://www.safaribooksonline.com/library/view/c-templates-the/9780134778808/)后，梳理精简章节脉络，补充 C++20 相关特性，如 [concepts](https://en.cppreference.com/w/cpp/concepts)、支持模板参数的 [lambda](https://en.cppreference.com/w/cpp/language/lambda) 等，运行验证所有代码结果，最终记录至此。\n\n## Contents\n\n1. [Function template](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/01_function_template.md)\n2. [Class template](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/02_class_template.md)\n3. [Non-type template parameter](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/03_non_type_template_parameter.md)\n4. [Variadic template](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/04_variadic_template.md)\n5. [Move semantics and perfect forwarding](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/05_move_semantics_and_perfect_forwarding.md)\n6. [Name lookup](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/06_name_lookup.md)\n7. [Instantiation](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/07_instantiation.md)\n8. [Template argument deduction](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/08_template_argument_deduction.md)\n9. [Specialization and overloading](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/09_specialization_and_overloading.md)\n10. [Traits](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/10_traits.md)\n11. [Inheritance](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/11_inheritance.md)\n12. [Type erasure](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/12_type_erasure.md)\n13. [Metaprogramming](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/13_metaprogramming.md)\n14. [Expression template](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/14_expression_template.md)\n15. [Debugging](https://github.com/downdemo/Cpp-Templates-2ed/blob/master/docs/15_debugging.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdowndemo%2Fcpp-templates-2ed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdowndemo%2Fcpp-templates-2ed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdowndemo%2Fcpp-templates-2ed/lists"}