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
- 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)
- 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.
- 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.
- 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.
- Basin D, Krstić S, Schneider J and Traytel D Correct and Efficient Policy Monitoring, a Retrospective Automated Technology for Verification and Analysis, (3-30)
- 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.
- 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.
- Krasnov M (2020). Functional Programming Library for C++, Programming and Computing Software, 46:5, (330-340), Online publication date: 1-Sep-2020.
- Zouaoui C and Taleb N (2017). CL_ARRAY, Computer Languages, Systems and Structures, 50:C, (53-81), Online publication date: 1-Dec-2017.
- 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.
- 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.
- 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)
- 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.
- 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.
- 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.
- 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)
- 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.
- 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.
- Kramer S and Hagemann J (2015). SciPAL, ACM Transactions on Parallel Computing, 1:2, (1-31), Online publication date: 18-Feb-2015.
- 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.
- 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.
- 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)
- 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)
- Johanson A and Hasselbring W Sprat Proceedings of the Symposium on Theory of Modeling & Simulation - DEVS Integrative, (1-6)
- 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.
- Eddelbuettel D and Sanderson C (2014). RcppArmadillo, Computational Statistics & Data Analysis, 71:C, (1054-1063), Online publication date: 1-Mar-2014.
- Liu W and Vinter B ad-heap Proceedings of Workshop on General Purpose Processing Using GPUs, (54-63)
- Liu W and Vinter B ad-heap Proceedings of Workshop on General Purpose Processing Using GPUs, (54-63)
- 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.
- Benedetto S and Lipari G (2014). ADOK, ACM SIGBED Review, 11:1, (74-79), Online publication date: 1-Feb-2014.
- 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)
- 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)
- Devriese D and Piessens F (2013). Typed syntactic meta-programming, ACM SIGPLAN Notices, 48:9, (73-86), Online publication date: 12-Nov-2013.
- Dubrov D N queens problem Proceedings of the 9th ACM SIGPLAN workshop on Generic programming, (35-46)
- Devriese D and Piessens F Typed syntactic meta-programming Proceedings of the 18th ACM SIGPLAN international conference on Functional programming, (73-86)
- 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.
- 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)
- 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.
- Silkensen E and Siek J Well-Typed Islands Parse Faster Proceedings of the 2012 Conference on Trends in Functional Programming - Volume 7829, (69-84)
- 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)
- 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)
- 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)
- 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.
- Lincke D and Schupp S From HOT to COOL Proceedings of the Twelfth Workshop on Language Descriptions, Tools, and Applications, (1-7)
- 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)
- 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.
- 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.
- 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.
- Sutton A and Stroustrup B Design of concept libraries for c++ Proceedings of the 4th international conference on Software Language Engineering, (97-118)
- Lev Y and Moir M Lightweight parallel accumulators using C++ templates Proceedings of the 4th International Workshop on Multicore Software Engineering, (33-40)
- 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)
- 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.
- 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.
- 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)
- 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)
- 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)
- Rupp K Symbolic integration at compile time in finite element methods Proceedings of the 2010 International Symposium on Symbolic and Algebraic Computation, (347-354)
- Touraille L, Traoré M and Hill D Enhancing DEVS simulation through template metaprogramming Proceedings of the 2010 Summer Computer Simulation Conference, (394-402)
- Rupp K Increased efficiency in finite element computations through template metaprogramming Proceedings of the 2010 Spring Simulation Multiconference, (1-8)
- Li T and Robinson I plrint5d Proceedings of the 2010 international conference on Computational Science and Its Applications - Volume Part II, (44-59)
- Siek J The c++0x "concepts" effort Proceedings of the 2010 international spring school conference on Generic and Indexed Programming, (175-216)
- 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)
- 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.
- 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)
- Lincke D and Schupp S The function concept in C++ Proceedings of the 2009 ACM SIGPLAN workshop on Generic programming, (25-36)
- 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.
- 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)
- 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)
- Tambe S and Gokhale A LEESA Proceedings of the IFIP TC 2 Working Conference on Domain-Specific Languages, (100-124)
- Porkoláb Z Functional programming with C++ template metaprograms Proceedings of the Third summer school conference on Central European functional programming school, (306-353)
- 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)
- 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)
- Veldhuizen T Parsimony principles for software components and metalanguages Proceedings of the 6th international conference on Generative programming and component engineering, (115-122)
- 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)
- Davis K and Striegnitz J Multiparadigm programming in object-oriented languages Proceedings of the 2007 conference on Object-oriented technology, (13-26)
- 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)
- 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)
- Bachmann P Static and metaprogramming patterns and static frameworks Proceedings of the 2006 conference on Pattern languages of programs, (1-33)
- 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.
- Siek J and Taha W A semantic analysis of c++ templates Proceedings of the 20th European conference on Object-Oriented Programming, (304-327)
- 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)
- Prud'homme C Life Proceedings of the 8th international conference on Applied parallel computing: state of the art in scientific computing, (712-721)
- Shopyrin D (2006). Multimethods Implementation in C++ Using Recursive Deferred Dispatching, IEEE Software, 23:3, (62-73), Online publication date: 1-May-2006.
- Å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)
- Stroustrup B Keynote speech Proceedings of the First international conference on Embedded Software and Systems, (1-13)
Index Terms
- C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ in Depth Series)
Recommendations
Using functional languages to facilitate C++ metaprogramming
WGP '12: Proceedings of the 8th ACM SIGPLAN workshop on Generic programmingTemplate and Preprocessor Metaprogramming are both well-known in the C++ community to have much in common with Functional Programming (FP). Recently, very few research threads on underpinning these commonalities have emerged to empower cross-development ...