The first book to provide complete and accurate information on using templates in C++.-- Great author team - both are widely respected, and bring complementary viewpoints to the book.-- With the greatly increased use of templates there is a real need in the C++ community for this information.This book will be the next C++ classic. Although templates have been part of C++ for we...
The first book to provide complete and accurate information on using templates in C++.-- Great author team - both are widely respected, and bring complementary viewpoints to the book.-- With the greatly increased use of templates there is a real need in the C++ community for this information.This book will be the next C++ classic. Although templates have been part of C++ for well over a decade, they still lead to misunderstanding, misuse, and controversy. At the same time, they are increasingly found to be powerful instruments for the development of cleaner, faster, and smarter software. This has made templates one of the hottest topics in the C++ community. This book will be both a complete reference as well as a tutorial. It will emphasize the practical use of templates, and will include real-world examples. Every working C++ programmer will need a copy of this book for his or her library.
David Vandevoorde is an engineer at the Edison Design Group. He is an active member of the ANSI C++ Standards Committee, and a cofounder of the newsgroup comp.lang.c++.moderated. A graduate of the Brussels Free University and the Rensselaer Polytechnic Institute, his interests include algorithm development, programming languages, and teaching. See www.vandevoorde.com.Nicolai M....
David Vandevoorde is an engineer at the Edison Design Group. He is an active member of the ANSI C++ Standards Committee, and a cofounder of the newsgroup comp.lang.c++.moderated. A graduate of the Brussels Free University and the Rensselaer Polytechnic Institute, his interests include algorithm development, programming languages, and teaching. See www.vandevoorde.com.Nicolai M. Josuttis is an independent technical consultant who designs object-oriented software for the telecommunications, traffic, finance, and manufacturing industries. He is an active member of the C++ Standards Committee Library Working Group. Nicolai has written several books on object-oriented programming and C++.
原文摘录
· · · · · ·
Thus, templates are compiled twice:
Without instantiation, the template code itself is checked for correct syntax. Syntax errors are discovered, such as missing semicolons.
At the time of instantiation, the template code is checked to ensure that all calls are valid. Invalid calls are discovered, such as unsupported function calls.
This leads to an important problem in the handling of templates in practice: When a function template is used in a way that triggers its instantiation, a compiler will (at some point) need to see that template's definition. This breaks the usual compile and link distinction for ordinary functions, when the declaration of a function is sufficient to compile its use. Methods of handling this problem are discussed in Chapter 6. For the moment, let's take the sim... (查看原文)
如果想重点学习研究一下的话就看这本书好了,内容跟进的也及时。1st part总起概览,只为了入门就看着部分;2nd part 事无巨细深入,各种想知道不想知道的rules总归会让你知道;3rd part 直接起手示范怎么运用 meta-programming 来实现一些东西,尤其标准库常用的组件。至于缺点嘛,后两个parts讲的东西的ROI比较低,如果时间很多就无所谓啦
01 学习C++模板技术的经典之作 C++ 技术爱好者们,特大喜讯来啦!《C++ Templates(第2版)中文版》将要上市,第 2 版相距第 1 版已有15年,这一次更新可以说是全面拥抱了现代 C++ 的语言特性。 C++ 程序员都知道,模板技术是一种强大的特性,可以让程序员编写尽可能通用的代码...
(展开)
2 有用 xeeXas 2018-04-29 23:33:40
一目十行势如破竹如浴春风如鱼得水 马的看起来太轻松愉快了 应该是我看的最后一本 C++的书。无疑是c++ template最好的书。也是14/17新特性最好的一本书。前半本覆盖了所有的feature,后半本覆盖了所有的应用场景和原理。对于每个特性的缘起,典型应用,衍生,直到STL对于这个feature的延伸,都通过简单的例子讲的通俗易懂。
1 有用 vuiBGmj 2023-12-06 17:53:51 浙江
2023/12首通。P1全面学习了解;P2还是没耐心啃完,超多intricacies,编译器开发的视角暂时超纲,c++20又有变,深奥内容的typo很能唬人(errata修了一些),等二刷;P3 traits太长不看,搞懂std::move/forward/function/enable_if/tuple;附录也是高质量细节深渊;整体而言c提的多,可能第一版写了的就懒得删了,c++各版本也加大了学... 2023/12首通。P1全面学习了解;P2还是没耐心啃完,超多intricacies,编译器开发的视角暂时超纲,c++20又有变,深奥内容的typo很能唬人(errata修了一些),等二刷;P3 traits太长不看,搞懂std::move/forward/function/enable_if/tuple;附录也是高质量细节深渊;整体而言c提的多,可能第一版写了的就懒得删了,c++各版本也加大了学习量、难度;本来就是想了解下当前的最佳实践,却一股脑把各个版本、历史渊源都写出来,经常是看完一节后,下一节就说新版本有更简便的写法! 怪我太急躁,但组织形式上,如果深入研究的部分按倒序展开,按需自取,多好(然而之后看c++20又要覆盖写入!心累,只能说以前学少了呗! (展开)
0 有用 邻家の躺平人 2025-02-26 00:34:47 浙江
如果想重点学习研究一下的话就看这本书好了,内容跟进的也及时。1st part总起概览,只为了入门就看着部分;2nd part 事无巨细深入,各种想知道不想知道的rules总归会让你知道;3rd part 直接起手示范怎么运用 meta-programming 来实现一些东西,尤其标准库常用的组件。至于缺点嘛,后两个parts讲的东西的ROI比较低,如果时间很多就无所谓啦
2 有用 Ethanity 2020-05-20 05:41:49
莫名其妙多了两周空窗期,干脆就把这本书挑着读完了。对于日常的模板使用前12章是个很好的功能介绍,略难理解的是concepts(对于代码生成规则的约束)、constexpr(编译时常量)、type deduction(effective modern第一章讲的非常清楚)。到了part2、3逼你思考编译器的运行原则:mem layout有什么必须follow的准则?编译时期怎么做name lookup... 莫名其妙多了两周空窗期,干脆就把这本书挑着读完了。对于日常的模板使用前12章是个很好的功能介绍,略难理解的是concepts(对于代码生成规则的约束)、constexpr(编译时常量)、type deduction(effective modern第一章讲的非常清楚)。到了part2、3逼你思考编译器的运行原则:mem layout有什么必须follow的准则?编译时期怎么做name lookup?怎样缩短泛用模板的编译时间?这两部分同时也慢慢显现黑魔法的本质:typelist、expression template、type traits等等,也涉及了设计模式,CRTP怎么实现static polymorphism?和inheritance有啥区别?诸如此类。。人生漫漫 慢慢学慢慢写吧。 (展开)
0 有用 Quack 2021-09-29 20:52:40
先看完 Part 1,心情复杂