A Semantic Analysis of C++ Templates

13 years 6 months ago
A Semantic Analysis of C++ Templates
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 Isabe...
Jeremy G. Siek, Walid Taha
Added 22 Aug 2010
Updated 22 Aug 2010
Type Conference
Year 2006
Authors Jeremy G. Siek, Walid Taha
Comments (0)