If you're like me, you're excited by what people do with template metaprogramming (TMP) but are frustrated at the lack of clear guidance and powerful tools. Well, this is the book we've been waiting for. With help from the excellent Boost Metaprogramming Library, David and Aleksey take TMP from the laboratory to the workplace with readable prose and practical examples, showing that "compile-time STL" is as able as its runtime counterpart. Serving as a tutorial as well as a handbook for experts, this is the book on C++ template metaprogramming."
—Chuck Allison, Editor, The C++ Source
C++ Template Metaprogramming sheds light on the most powerful idioms of today's C++, at long last delivering practical metaprogramming tools and techniques into the hands of the everyday programmer.
A metaprogram is a program that generates or manipulates program code. Ever since generic programming was introduced to C++, programmers have discovered myriad "template tricks" for manipulating programs as they are compiled, effectively eliminating the barrier between program and metaprogram. While excitement among C++ experts about these capabilities has reached the community at large, their practical application remains out of reach for most programmers. This book explains what metaprogramming is and how it is best used. It provides the foundation you'll need to use the template metaprogramming effectively in your own work.
This book is aimed at any programmer who is comfortable with idioms of the Standard Template Library (STL). C++ power-users will gain a new insight into their existing work and a new fluency in the domain of metaprogramming. Intermediate-level programmers who have learned a few advanced template techniques will see where these tricks fit in the big picture and will gain the conceptual foundation to use them with discipline. Programmers who have caught the scent of metaprogramming, but for whom it is still mysterious, will finally gain a clear understanding of how, when, and why it works. All readers will leave with a new tool of unprecedented power at their disposal—the Boost Metaprogramming Library.
The companion CD-ROM contains all Boost C++ libraries, including the Boost Metaprogramming Library and its reference documentation, along with all of the book's sample code and extensive supplementary material.
The design of application programming interfaces can affect the behavior, capabilities, stability, and ease of use of end-user applications. With this book, you will learn how to design a good API for large-scale long-term projects. With extensive C++ code to illustrate each concept, API Design for C++ covers all of the strategies of world-class API development. Martin Reddy draws on over fifteen years of experience in the software industry to offer in-depth discussions of interface design, documentation, testing, and the advanced topics of scripting and plug-in extensibility. Throughout, he focuses on various API styles and patterns that will allow you to produce elegant and durable libraries.
Consistent, high-quality coding standards improve software quality, reduce time-to-market, promote teamwork, eliminate time wasted on inconsequential matters, and simplify maintenance. Now, two of the world's most respected C++ experts distill the rich collective experience of the global C++ community into a set of coding standards that every developer and development team can understand and use as a basis for their own coding standards.
The authors cover virtually every facet of C++ programming: design and coding style, functions, operators, class design, inheritance, construction/destruction, copying, assignment, namespaces, modules, templates, genericity, exceptions, STL containers and algorithms, and more. Each standard is described concisely, with practical examples. From type definition to error handling, this book presents C++ best practices, including some that have only recently been identified and standardized-techniques you may not know even if you've used C++ for years. Along the way, you'll find answers to questions like
What's worth standardizing--and what isn't
What are the best ways to code for scalability
What are the elements of a rational error handling policy
How (and why) do you avoid unnecessary initialization, cyclic, and definitional dependencies
The inventor of C++ presents the definitive insider's guide to the design and development of the C++ programming language. Without ommitting critical details or getting bogged down in technicalities, Stroustrup presents his unique insights into the decisions that shaped C++. Every C++ programmer will benefit from Stroustrup's explanations of the 'why's' behind C++ from the earliest features, such as the original class concept, to the latest extensions, such as new casts and explicit template instantiation. Some C++ design decisions have been universally praised, while others remain controversial, and debated vigorously; still other features have been rejected based on experimentation. In this book, Stroustrup dissects many of these decisions to present a case study in "real object- oriented language development" for the working programmer. In doing so, he presents his views on programming and design in a concrete and useful way that makes this book a must-buy for every C++ programmer. Features*Written by the inventor of C++ Stroustrup *Provides insights into the design decisions which shaped C++. *Gives technical summaries of C++.* Discusses the latest language features: templates, exceptions, run-time type information, and namespaces