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. Note: CD materials are only available with the print edition.
Advanced Metaprogramming in Classic C++ aims to be both an introduction and a reference to C++ template metaprogramming (TMP); TMP is presented in the book as a set of techniques that will bring a new style in C++ and make code exceptionally clear and efficient. The book deals with language aspects, design patterns, examples and applications (seen as case studies). Special emphasis is put on small reusable techniques that will improve the quality of daily work. What makes the book exceptional is the level of understanding of the concepts involved imparted by the author. This is not just a rote overview of metaprogramming. You will truly understand difficult topics like static assertions, how to write metafunctions, overload resolution, lambda expressions, and many others. More than that, you will work through them with practical examples guided by the author's frank explanations. This book requires you to think and to learn and to understand the language so that you can program at a higher level.
Introducing the Boost libraries: the next breakthrough in C++ programming Boost takes you far beyond the C++ Standard Library, making C++ programming more elegant, robust, and productive. Now, for the first time, a leading Boost expert systematically introduces the broad set of Boost libraries and teaches best practices for their use. Writing for intermediate-to-advanced C++ developers, Björn Karlsson briefly outlines all 58 Boost libraries, and then presents comprehensive coverage of 12 libraries you're likely to find especially useful. Karlsson's topics range from smart pointers and conversions to containers and data structures, explaining exactly how using each library can improve your code. He offers detailed coverage of higher-order function objects that enable you to write code that is more concise, expressive, and readable. He even takes you "behind the scenes" with Boost, revealing tools and techniques for creating your own generic libraries. Coverage includes Smart pointers that provide automatic lifetime management of objects and simplify resource sharing Consistent, best-practice solutions for performing type conversions and lexical conversions Utility classes that make programming simpler and clearer Flexible container libraries that solve common problems not covered by the C++ Standard Library Powerful support for regular expressions with Boost.Regex Function objects defined at the call site with Boost.Bind and Boost.Lambda More flexible callbacks with Boost.Function Managed signals and slots (a.k.a. the Observer pattern) with Boost.Signals The Boost libraries are proving so useful that many of them are planned for inclusion in the next version of the C++ Standard Library. Get your head start now, with Beyond the C++ Standard Library.
Author: Jeremy G. Siek
Publisher: Pearson Education
Release Date: 2001-12-20
The Boost Graph Library (BGL) is the first C++ library to apply the principles of generic programming to the construction of the advanced data structures and algorithms used in graph computations. Problems in such diverse areas as Internet packet routing, molecular biology, scientific computing, and telephone network design can be solved by using graph theory. This book presents an in-depth description of the BGL and provides working examples designed to illustrate the application of BGL to these real-world problems. Written by the BGL developers, The Boost Graph Library: User Guide and Reference Manual gives you all the information you need to take advantage of this powerful new library. Part I is a complete user guide that begins by introducing graph concepts, terminology, and generic graph algorithms. This guide also takes the reader on a tour through the major features of the BGL; all motivated with example problems. Part II is a comprehensive reference manual that provides complete documentation of all BGL concepts, algorithms, and classes. Readers will find coverage of: Graph terminology and concepts Generic programming techniques in C++ Shortest-path algorithms for Internet routing Network planning problems using the minimum-spanning tree algorithms BGL algorithms with implicitly defined graphs BGL Interfaces to other graph libraries BGL concepts and algorithms BGL classes–graph, auxiliary, and adaptor Groundbreaking in its scope, this book offers the key to unlocking the power of the BGL for the C++ programmer looking to extend the reach of generic programming beyond the Standard Template Library.
Author: Andrei Alexandrescu
Publisher: Addison-Wesley Professional
Release Date: 2001
This title documents a convergence of programming techniques - generic programming, template metaprogramming, object-oriented programming and design patterns. It describes the C++ techniques used in generic programming and implements a number of industrial strength components.
Author: Krzysztof Czarnecki
Publisher: Addison-Wesley Professional
Release Date: 2000
The authors present a grand tour of Generative Programming that is bound to become a classic. They ... focus on the generally unappreciated connection between Domain Specific Languages and Generative Programming as a motivation for future development. Their wide-ranging and practical methods for Domain Analysis and Domain Engineering describe the first steps that developers can take right now ... and are valuable both when existing systems are used or in preparation for emerging new generative technologies. - Charles Simonyi, Chief Architect at Microsoft Research and the inventor of Intentional Programming The book develops strong themes around unifying principles that tie the pieces together, most notably domain engineering and metaprogramming. Its crucial to understand that this book is not just some refreshing diversion, nor just an exposition of some noteworthy niche techniques: It is a harbinger of a broader enlightenment that opens the door to a new age. - From the Foreword by James Coplien, a Distinguished Member of Technical Staff at Lucent Technologiesm Bell Laboratories Generative Programming (GP) offers great promise to application developers. It makes the idea of mo
Author: Dirk Eddelbuettel
Publisher: Springer Science & Business Media
Release Date: 2013-06-04
Rcpp is the glue that binds the power and versatility of R with the speed and efficiency of C++. With Rcpp, the transfer of data between R and C++ is nearly seamless, and high-performance statistical computing is finally accessible to most R users. Rcpp should be part of every statistician's toolbox. -- Michael Braun, MIT Sloan School of Management "Seamless R and C++ integration with Rcpp" is simply a wonderful book. For anyone who uses C/C++ and R, it is an indispensable resource. The writing is outstanding. A huge bonus is the section on applications. This section covers the matrix packages Armadillo and Eigen and the GNU Scientific Library as well as RInside which enables you to use R inside C++. These applications are what most of us need to know to really do scientific programming with R and C++. I love this book. -- Robert McCulloch, University of Chicago Booth School of Business Rcpp is now considered an essential package for anybody doing serious computational research using R. Dirk's book is an excellent companion and takes the reader from a gentle introduction to more advanced applications via numerous examples and efficiency enhancing gems. The book is packed with all you might have ever wanted to know about Rcpp, its cousins (RcppArmadillo, RcppEigen .etc.), modules, package development and sugar. Overall, this book is a must-have on your shelf. -- Sanjog Misra, UCLA Anderson School of Management The Rcpp package represents a major leap forward for scientific computations with R. With very few lines of C++ code, one has R's data structures readily at hand for further computations in C++. Hence, high-level numerical programming can be made in C++ almost as easily as in R, but often with a substantial speed gain. Dirk is a crucial person in these developments, and his book takes the reader from the first fragile steps on to using the full Rcpp machinery. A very recommended book! -- Søren Højsgaard, Department of Mathematical Sciences, Aalborg University, Denmark "Seamless R and C ++ Integration with Rcpp" provides the first comprehensive introduction to Rcpp. Rcpp has become the most widely-used language extension for R, and is deployed by over one-hundred different CRAN and BioConductor packages. Rcpp permits users to pass scalars, vectors, matrices, list or entire R objects back and forth between R and C++ with ease. This brings the depth of the R analysis framework together with the power, speed, and efficiency of C++. Dirk Eddelbuettel has been a contributor to CRAN for over a decade and maintains around twenty packages. He is the Debian/Ubuntu maintainer for R and other quantitative software, edits the CRAN Task Views for Finance and High-Performance Computing, is a co-founder of the annual R/Finance conference, and an editor of the Journal of Statistical Software. He holds a Ph.D. in Mathematical Economics from EHESS (Paris), and works in Chicago as a Senior Quantitative Analyst.
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? When (and how) should you use static and dynamic polymorphism together? How do you practice "safe" overriding? When should you provide a no-fail swap? Why and how should you prevent exceptions from propagating across module boundaries? Why shouldn't you write namespace declarations or directives in a header file? Why should you use STL vector and string instead of arrays? How do you choose the right STL search or sort algorithm? What rules should you follow to ensure type-safe code? Whether you're working alone or with others, C++ Coding Standards will help you write cleaner code--and write it faster, with fewer hassles and less frustration.
Author: Philip Romanik
Publisher: Addison-Wesley Professional
Release Date: 2003
* *Effective, practical tips for building fast, real, and robust C++ programs. *Solutions-based: Discusses ideal solutions versus practical solutions and the tradeoffs of various design decisions. *Concrete case study runs throughout the book and shows how to develop quality C++ software.
Filled with dozens of working code examples that illustrate the use of over 40 popular Boost libraries, this book takes you on a tour of Boost, helping you to independently build the libraries from source and use them in your own code. The first half of the book focuses on basic programming interfaces including generic containers and algorithms, strings, resource management, exception safety, and a miscellany of programming utilities that make everyday programming chores easy. Following a short interlude that introduces template metaprogramming and functional programming, the later chapters are devoted to systems programming interfaces, focusing on directory handling, I/O, concurrency, and network programming
Author: David Vandevoorde
Publisher: Addison-Wesley Professional
Release Date: 2002-11-12
Templates are among the most powerful features of C++, but they are too often neglected, misunderstood, and misused. C++ Templates: The Complete Guide provides software architects and engineers with a clear understanding of why, when, and how to use templates to build and maintain cleaner, faster, and smarter software more efficiently. C++ Templates begins with an insightful tutorial on basic concepts and language features. The remainder of the book serves as a comprehensive reference, focusing first on language details, then on a wide range of coding techniques, and finally on advanced applications for templates. Examples used throughout the book illustrate abstract concepts and demonstrate best practices. Readers learn The exact behaviors of templates How to avoid the pitfalls associated with templates Idioms and techniques, from the basic to the previously undocumented How to reuse source code without threatening performance or safety How to increase the efficiency of C++ programs How to produce more flexible and maintainable software This practical guide shows programmers how to exploit the full power of the template features in C++. The companion Web site at http://www.josuttis.com/tmplbook/ contains sample code and additional updates.
Author: Peter Gottschling
Publisher: Addison-Wesley Professional
Release Date: 2015-12-23
As scientific and engineering projects grow larger and more complex, it is increasingly likely that those projects will be written in C++. With embedded hardware growing more powerful, much of its software is moving to C++, too. Mastering C++ gives you strong skills for programming at nearly every level, from “close to the hardware” to the highest-level abstractions. In short, C++ is a language that scientific and technical practitioners need to know. Peter Gottschling’s Discovering Modern C++ is an intensive introduction that guides you smoothly to sophisticated approaches based on advanced features. Gottschling introduces key concepts using examples from many technical problem domains, drawing on his extensive experience training professionals and teaching C++ to students of physics, math, and engineering. This book is designed to help you get started rapidly and then master increasingly robust features, from lambdas to expression templates. You’ll also learn how to take advantage of the powerful libraries available to C++ programmers: both the Standard Template Library (STL) and scientific libraries for arithmetic, linear algebra, differential equations, and graphs. Throughout, Gottschling demonstrates how to write clear and expressive software using object orientation, generics, metaprogramming, and procedural techniques. By the time you’re finished, you’ll have mastered all the abstractions you need to write C++ programs with exceptional quality and performance.