The semantics of the C++ programming language
Specification and validation methods
Using C++ template metaprograms
C++ gems
Generative programming: methods, tools, and applications
Generative programming: methods, tools, and applications
Modern C++ design: generic programming and design patterns applied
Modern C++ design: generic programming and design patterns applied
Macros as multi-stage computations: type-safe, generative, binding macros in MacroML
Proceedings of the sixth ACM SIGPLAN international conference on Functional programming
The Definition of Standard ML
Template meta-programming for Haskell
Proceedings of the 2002 ACM SIGPLAN workshop on Haskell
C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ in Depth Series)
Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
TYPES'02 Proceedings of the 2002 international conference on Types for proofs and programs
Isabelle/HOL: a proof assistant for higher-order logic
Isabelle/HOL: a proof assistant for higher-order logic
Evolving a language in and for the real world: C++ 1991-2006
Proceedings of the third ACM SIGPLAN conference on History of programming languages
Lightweight modular staging: a pragmatic approach to runtime code generation and compiled DSLs
GPCE '10 Proceedings of the ninth international conference on Generative programming and component engineering
Extending Type Inference to Variational Programs
ACM Transactions on Programming Languages and Systems (TOPLAS)
Early detection of type errors in C++ templates
Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation
Hi-index | 0.00 |
Templates are a powerful but poorly understood feature of the C++ language. Their syntax resembles the parameterized classes of other languages (e.g., of Java). But because C++ supports template specialization, their semantics is quite different from that of parameterized classes. Template specialization provides a Turing-complete sub-language within C++ that executes at compile-time. Programmers put this power to many uses. For example, templates are a popular tool for writing program generators. The C++ Standard defines the semantics of templates using natural language, so it is prone to misinterpretation. The meta-theoretic properties of C++ templates have not been studied, so the semantics of templates has not been systematically checked for errors. In this paper we present the first formal account of C++ templates including some of the more complex aspects, such as template partial specialization. We validate our semantics by proving type safety and verify the proof with the Isabelle proof assistant. Our formalization reveals two interesting issues in the C++ Standard: the first is a problem with member instantiation and the second concerns the generation of unnecessary template specializations.