Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
Skip header Section
C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ in Depth Series)December 2004
Publisher:
  • Addison-Wesley Professional
ISBN:978-0-321-22725-6
Published:01 December 2004
Skip Bibliometrics Section
Reflects downloads up to 10 Nov 2024Bibliometrics
Skip Abstract Section
Abstract

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.

Cited By

  1. ACM
    Racordon D and Chung B Use Site Checking Considered Harmful Proceedings of the 2024 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software, (275-287)
  2. Krasnov M and Feodoritova O (2024). The Use of Functional Programming Library for Parallel Computing on CUDA, Programming and Computing Software, 50:1, (11-23), Online publication date: 1-Feb-2024.
  3. Kubica B (2023). Algorithmic differentiation and hull-consistency enforcing using C++ template meta-programming, Numerical Algorithms, 94:4, (1673-1704), Online publication date: 1-Dec-2023.
  4. Agrawal V and Runnels B (2023). Robust, strong form mechanics on an adaptive structured grid: efficiently solving variable-geometry near-singular problems with diffuse interfaces, Computational Mechanics, 72:5, (1009-1027), Online publication date: 1-Nov-2023.
  5. Basin D, Krstić S, Schneider J and Traytel D Correct and Efficient Policy Monitoring, a Retrospective Automated Technology for Verification and Analysis, (3-30)
  6. ACM
    Phipps E, Pawlowski R and Trott C (2022). Automatic Differentiation of C++ Codes on Emerging Manycore Architectures with Sacado, ACM Transactions on Mathematical Software, 48:4, (1-29), Online publication date: 31-Dec-2022.
  7. Thoman P, Tischler F, Salzmann P and Fahringer T (2022). The Celerity High-level API: C++20 for Accelerator Clusters, International Journal of Parallel Programming, 50:3-4, (341-359), Online publication date: 1-Aug-2022.
  8. Krasnov M (2020). Functional Programming Library for C++, Programming and Computing Software, 46:5, (330-340), Online publication date: 1-Sep-2020.
  9. Zouaoui C and Taleb N (2017). CL_ARRAY, Computer Languages, Systems and Structures, 50:C, (53-81), Online publication date: 1-Dec-2017.
  10. Ibrahim K, Epifanovsky E, Williams S and Krylov A (2017). Cross-scale efficient tensor contractions for coupled cluster computations through multiple programming model backends, Journal of Parallel and Distributed Computing, 106:C, (92-105), Online publication date: 1-Aug-2017.
  11. Pati T, Kolli S and Hill J (2017). Proactive modeling, Software and Systems Modeling (SoSyM), 16:2, (499-521), Online publication date: 1-May-2017.
  12. Baset S and Stoffel K OntoJIT: Parsing Native OWL DL into Executable Ontologies in an Object Oriented Paradigm OWL: Experiences and Directions – Reasoner Evaluation, (1-14)
  13. ACM
    Hoeven J, Lecerf G and Quintin G (2016). Modular SIMD arithmetic in Mathemagix, ACM Transactions on Mathematical Software, 43:1, (1-37), Online publication date: 29-Aug-2016.
  14. Tran Tan A, Falcou J, Etiemble D and Kaiser H (2016). Automatic Task-Based Code Generation for High Performance Domain Specific Embedded Language, International Journal of Parallel Programming, 44:3, (449-465), Online publication date: 1-Jun-2016.
  15. Coullon H and Limet S (2016). The SIPSim implicit parallelism model and the SkelGIS library, Concurrency and Computation: Practice & Experience, 28:7, (2120-2144), Online publication date: 1-May-2016.
  16. ACM
    Gysi T, Osuna C, Fuhrer O, Bianco M and Schulthess T STELLA Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis, (1-12)
  17. Lilis Y and Savidis A (2015). An integrated implementation framework for compile-time metaprogramming, Software—Practice & Experience, 45:6, (727-763), Online publication date: 1-Jun-2015.
  18. ACM
    Hill J and Feiock D (2014). Pin++: an object-oriented framework for writing pintools, ACM SIGPLAN Notices, 50:3, (133-141), Online publication date: 12-May-2015.
  19. ACM
    Kramer S and Hagemann J (2015). SciPAL, ACM Transactions on Parallel Computing, 1:2, (1-31), Online publication date: 18-Feb-2015.
  20. Estérie P, Falcou J, Gaunard M, Lapresté J and Lacassagne L (2014). The numerical template toolbox, Journal of Parallel and Distributed Computing, 74:12, (3240-3253), Online publication date: 1-Dec-2014.
  21. ACM
    Langr D, Tvrdík P, Dytrych T and Draayer J (2014). Algorithm 947, ACM Transactions on Mathematical Software, 41:1, (1-26), Online publication date: 27-Oct-2014.
  22. ACM
    Hill J and Feiock D Pin++: an object-oriented framework for writing pintools Proceedings of the 2014 International Conference on Generative Programming: Concepts and Experiences, (133-141)
  23. ACM
    Teodorescu L, Dumitrel V and Potolea R Moving computations from run-time to compile-time Proceedings of the 11th ACM Conference on Computing Frontiers, (1-10)
  24. Johanson A and Hasselbring W Sprat Proceedings of the Symposium on Theory of Modeling & Simulation - DEVS Integrative, (1-6)
  25. Fuhrer O, Osuna C, Lapillonne X, Gysi T, Cumming B, Bianco M, Arteaga A and Schulthess T (2014). Towards a performance portable, architecture agnostic implementation strategy for weather and climate models, Supercomputing Frontiers and Innovations: an International Journal, 1:1, (45-62), Online publication date: 6-Apr-2014.
  26. Eddelbuettel D and Sanderson C (2014). RcppArmadillo, Computational Statistics & Data Analysis, 71:C, (1054-1063), Online publication date: 1-Mar-2014.
  27. ACM
    Liu W and Vinter B ad-heap Proceedings of Workshop on General Purpose Processing Using GPUs, (54-63)
  28. Liu W and Vinter B ad-heap Proceedings of Workshop on General Purpose Processing Using GPUs, (54-63)
  29. ACM
    Chen S, Erwig M and Walkingshaw E (2014). Extending Type Inference to Variational Programs, ACM Transactions on Programming Languages and Systems, 36:1, (1-54), Online publication date: 1-Mar-2014.
  30. ACM
    Benedetto S and Lipari G (2014). ADOK, ACM SIGBED Review, 11:1, (74-79), Online publication date: 1-Feb-2014.
  31. ACM
    Miao W and Siek J Compile-time reflection and metaprogramming for Java Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation, (27-37)
  32. ACM
    Chen S and Erwig M Early detection of type errors in C++ templates Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation, (133-144)
  33. ACM
    Devriese D and Piessens F (2013). Typed syntactic meta-programming, ACM SIGPLAN Notices, 48:9, (73-86), Online publication date: 12-Nov-2013.
  34. ACM
    Dubrov D N queens problem Proceedings of the 9th ACM SIGPLAN workshop on Generic programming, (35-46)
  35. ACM
    Devriese D and Piessens F Typed syntactic meta-programming Proceedings of the 18th ACM SIGPLAN international conference on Functional programming, (73-86)
  36. Bachelet B, Mahul A and Yon L (2013). Template metaprogramming techniques for concept-based specialization, Scientific Programming, 21:1-2, (43-61), Online publication date: 1-Jan-2013.
  37. ACM
    Haeri S, Schupp S and Hüser J Using functional languages to facilitate C++ metaprogramming Proceedings of the 8th ACM SIGPLAN workshop on Generic programming, (33-44)
  38. Pawlowski R, Phipps E, Salinger A, Owen S, Siefert C and Staten M (2012). Automating embedded analysis capabilities and managing software complexity in multiphysics simulation, Part II, Scientific Programming, 20:3, (327-345), Online publication date: 1-Jul-2012.
  39. Silkensen E and Siek J Well-Typed Islands Parse Faster Proceedings of the 2012 Conference on Trends in Functional Programming - Volume 7829, (69-84)
  40. Lilis Y and Savidis A Supporting compile-time debugging and precise error reporting in meta-programs Proceedings of the 50th international conference on Objects, Models, Components, Patterns, (155-170)
  41. Langr D, Tvrdík P, Dytrych T and Draayer J Fake run-time selection of template arguments in c++ Proceedings of the 50th international conference on Objects, Models, Components, Patterns, (140-154)
  42. Gottschling P and Hoefler T Productive Parallel Linear Algebra Programming with Unstructured Topology Adaption Proceedings of the 2012 12th IEEE/ACM International Symposium on Cluster, Cloud and Grid Computing (ccgrid 2012), (9-16)
  43. Pawlowski R, Phipps E and Salinger A (2012). Automating embedded analysis capabilities and managing software complexity in multiphysics simulation, Part I, Scientific Programming, 20:2, (197-219), Online publication date: 1-Apr-2012.
  44. ACM
    Lincke D and Schupp S From HOT to COOL Proceedings of the Twelfth Workshop on Language Descriptions, Tools, and Applications, (1-7)
  45. ACM
    Edwards H and Sunderland D Kokkos Array performance-portable manycore programming model Proceedings of the 2012 International Workshop on Programming Models and Applications for Multicores and Manycores, (1-10)
  46. Milo F, Bernaschi M and Bisson M (2011). A fast, GPU based, dictionary attack to OpenPGP secret keyrings, Journal of Systems and Software, 84:12, (2088-2096), Online publication date: 1-Dec-2011.
  47. Szźgyi Z and Pataki N (2011). Generative Version of the FastFlow Multicore Library, Electronic Notes in Theoretical Computer Science (ENTCS), 279:3, (73-84), Online publication date: 1-Dec-2011.
  48. Szźgyi Z, Török M and Pataki N (2011). Multicore C++ Standard Template Library in a Generative Way, Electronic Notes in Theoretical Computer Science (ENTCS), 279:3, (63-72), Online publication date: 1-Dec-2011.
  49. Sutton A and Stroustrup B Design of concept libraries for c++ Proceedings of the 4th international conference on Software Language Engineering, (97-118)
  50. ACM
    Lev Y and Moir M Lightweight parallel accumulators using C++ templates Proceedings of the 4th International Workshop on Multicore Software Engineering, (33-40)
  51. Newburn C, So B, Liu Z, McCool M, Ghuloum A, Toit S, Wang Z, Du Z, Chen Y, Wu G, Guo P, Liu Z and Zhang D Intel's Array Building Blocks Proceedings of the 9th Annual IEEE/ACM International Symposium on Code Generation and Optimization, (224-235)
  52. ACM
    Miao W and Siek J (2010). Incremental type-checking for type-reflective metaprograms, ACM SIGPLAN Notices, 46:2, (167-176), Online publication date: 26-Jan-2011.
  53. ACM
    Porkolab Z and Sinkovics Á (2010). Domain-specific language integration with compile-time parser generator library, ACM SIGPLAN Notices, 46:2, (137-146), Online publication date: 26-Jan-2011.
  54. Pirkelbauer P, Dechev D and Stroustrup B Support for the evolution of C++ generic functions Proceedings of the Third international conference on Software language engineering, (123-142)
  55. ACM
    Miao W and Siek J Incremental type-checking for type-reflective metaprograms Proceedings of the ninth international conference on Generative programming and component engineering, (167-176)
  56. ACM
    Porkolab Z and Sinkovics Á Domain-specific language integration with compile-time parser generator library Proceedings of the ninth international conference on Generative programming and component engineering, (137-146)
  57. ACM
    Rupp K Symbolic integration at compile time in finite element methods Proceedings of the 2010 International Symposium on Symbolic and Algebraic Computation, (347-354)
  58. Touraille L, Traoré M and Hill D Enhancing DEVS simulation through template metaprogramming Proceedings of the 2010 Summer Computer Simulation Conference, (394-402)
  59. Rupp K Increased efficiency in finite element computations through template metaprogramming Proceedings of the 2010 Spring Simulation Multiconference, (1-8)
  60. Li T and Robinson I plrint5d Proceedings of the 2010 international conference on Computational Science and Its Applications - Volume Part II, (44-59)
  61. Siek J The c++0x "concepts" effort Proceedings of the 2010 international spring school conference on Generic and Indexed Programming, (175-216)
  62. Klemm R and Fettweis G Bitstream processing for embedded systems using C++ metaprogramming Proceedings of the Conference on Design, Automation and Test in Europe, (909-913)
  63. ACM
    Garcia R and Lumsdaine A (2009). Toward foundations for type-reflective metaprogramming, ACM SIGPLAN Notices, 45:2, (25-34), Online publication date: 1-Feb-2010.
  64. ACM
    Garcia R and Lumsdaine A Toward foundations for type-reflective metaprogramming Proceedings of the eighth international conference on Generative programming and component engineering, (25-34)
  65. ACM
    Lincke D and Schupp S The function concept in C++ Proceedings of the 2009 ACM SIGPLAN workshop on Generic programming, (25-36)
  66. ACM
    Meerbergen K, Fresl K and Knapen T (2009). C++ Bindings to External Software Libraries with Examples from BLAS, LAPACK, UMFPACK, and MUMPS, ACM Transactions on Mathematical Software, 36:4, (1-23), Online publication date: 1-Aug-2009.
  67. ACM
    Kirchner N, Herzog O, Knell S, Holzwarth V, Ziegenhagel U, Sauer M and Klomfass A C++ code design for multi-purpose explicit finite volume methods Proceedings of the 8th workshop on Parallel/High-Performance Object-Oriented Scientific Computing, (1-5)
  68. ACM
    Di Pietro D, Gratien J, Häberlein F, Michel A and Prud'homme C Basic concepts to design a DSL for parallel finite volume applications Proceedings of the 8th workshop on Parallel/High-Performance Object-Oriented Scientific Computing, (1-11)
  69. Tambe S and Gokhale A LEESA Proceedings of the IFIP TC 2 Working Conference on Domain-Specific Languages, (100-124)
  70. Porkoláb Z Functional programming with C++ template metaprograms Proceedings of the Third summer school conference on Central European functional programming school, (306-353)
  71. Falcou J, Sérot J, Pech L and Lapresté J Meta-programming Applied to Automatic SMP Parallelization of Linear Algebra Code Proceedings of the 14th international Euro-Par conference on Parallel Processing, (729-738)
  72. ACM
    Pirkelbauer P, Parent S, Marcus M and Stroustrup B Runtime concepts for the C++ standard template library Proceedings of the 2008 ACM symposium on Applied computing, (171-177)
  73. ACM
    Veldhuizen T Parsimony principles for software components and metalanguages Proceedings of the 6th international conference on Generative programming and component engineering, (115-122)
  74. ACM
    Gil J and Lenz K Simple and safe SQL queries with c++ templates Proceedings of the 6th international conference on Generative programming and component engineering, (13-24)
  75. Davis K and Striegnitz J Multiparadigm programming in object-oriented languages Proceedings of the 2007 conference on Object-oriented technology, (13-26)
  76. ACM
    Gregor D, Järvi J, Siek J, Stroustrup B, Dos Reis G and Lumsdaine A Concepts Proceedings of the 21st annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applications, (291-310)
  77. ACM
    Porkoláb Z, Mihalicza J and Sipos Á Debugging C++ template metaprograms Proceedings of the 5th international conference on Generative programming and component engineering, (255-264)
  78. ACM
    Bachmann P Static and metaprogramming patterns and static frameworks Proceedings of the 2006 conference on Pattern languages of programs, (1-33)
  79. ACM
    Gregor D, Järvi J, Siek J, Stroustrup B, Dos Reis G and Lumsdaine A (2006). Concepts, ACM SIGPLAN Notices, 41:10, (291-310), Online publication date: 16-Oct-2006.
  80. Siek J and Taha W A semantic analysis of c++ templates Proceedings of the 20th European conference on Object-Oriented Programming, (304-327)
  81. Heinzl R, Spevak M, Schwaha P and Selberherr S A high performance generic scientific simulation environment Proceedings of the 8th international conference on Applied parallel computing: state of the art in scientific computing, (996-1005)
  82. Prud'homme C Life Proceedings of the 8th international conference on Applied parallel computing: state of the art in scientific computing, (712-721)
  83. Shopyrin D (2006). Multimethods Implementation in C++ Using Recursive Deferred Dispatching, IEEE Software, 23:3, (62-73), Online publication date: 1-May-2006.
  84. Åhlander K Sorting out the relationships between pairs of iterators, values, and references Proceedings of the 4th international conference on Generative Programming and Component Engineering, (342-356)
  85. Stroustrup B Keynote speech Proceedings of the First international conference on Embedded Software and Systems, (1-13)
Contributors

Index Terms

  1. C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ in Depth Series)

          Reviews

          Martin D. Schweitzer

          Boost.org is a Web site that provides access to the Boost programming library. One can think of the Boost library as offering all of those things that were meant to be in the standard C++ library, but never quite made it. One can also think of it as a testing ground for new ideas in C++. Abrahams and Gurtovoy have been involved in Boost since its very early days (or, at least, they were around when I started using it, in about 2000). One of the subtle changes that has taken place in programming has been something called generic programming. This has proven to be as powerful a paradigm as object-oriented programming (but has gotten far less press). C++ has had support for generic programming (in the form of templates) for over ten years, but it was probably only around the time that Modern C++ design [1] was published that designing with templates became a mainstream activity. Soon afterward, the Boost library began its metaprogramming library (MPL). This book is both an introduction to template metaprogramming, and an overview (and tutorial) for the Boost MPL. As mentioned before, the authors bring a great deal of authority to the topic. The book starts with an overview of metaprogramming. The explanations and examples are quite easy to follow, and could probably be followed by almost anyone with a basic knowledge of C++ and programming. Be warned, however: this book is not for beginners. Very quickly, the book starts getting into details. This is not a bad thing, since the intended audience for the book is the intermediate-to-advanced C++ programmer. As an example, section 2.5.2 is on primary type categorization, and starts as follows: "These unary metafunctions determine which of the fundamental type categories described in the C++ standard applies to their argument." Most of the book's pages are similarly dense. The first few chapters offer a good overview of metaprogramming, and introduce some good examples. Chapters 5, 6, and 7 cover sequences and iterators, algorithms and views, and iterator adaptors. Anybody who is familiar with the standard template library (STL), who would like to get a deeper understanding, or who would like to extend the STL in uncommon ways, would get a lot of value from these chapters. One thing that I found particularly useful in these chapters was the authors' definitions of terms such as concept, model, and refinement. The final two chapters (10 and 11) examine domain-specific embedded languages. Chapter 10 presents a good overview and motivation for using them, and chapter 11 works through a realistic example (developing a finite state machine generator). This book is part of the C++ In-Depth Series, and lives up to the reputation of the other books in the series. They are not generally for beginners. This book is an ideal addition to the library of someone who feels that they have mastered the basics of C++, and now wants to progress to the next level. Online Computing Reviews Service

          Access critical reviews of Computing literature here

          Become a reviewer for Computing Reviews.

          Recommendations