zbMATH — the first resource for mathematics

Properties of C++ template metaprograms. (English) Zbl 1183.68147
Kovács, Emőd (ed.) et al., Proceedings of the 7th international conference on applied informatics (ICAI 2007), January 28–31, 2007, Eger, Hungary. Vol. II. Eger: Eszterházy Károly College. 265-270 (2009).
Summary: Verifying properties of programs is a common way to ensure the proper behaviour of those programs. Invariants, pre- and postconditions are program properties often used when proving correctness of programs.
C++ Template MetaPrograms (TMPs) are special progams interpreted by the compiler. Metaprograms are widely used for the following purposes: executing algorithms in compile-time, optimizing runtime programs and emitting compilation errors and warnings to enforce certain semantic checks.
In this paper we step to “meta-meta-level”: we present a technique to make safer C++ TMPs with static asserts. We describe how to check invariants, pre- and postconditions of TMPs and enforce the compiler to refuse metaprograms if any of the specified program properties is dissatisfied. We present some examples where semantic errors in TMPs are revealed by our method.
For the entire collection see [Zbl 1176.68011].
68N15 Theory of programming languages
68N19 Other programming paradigms (object-oriented, sequential, concurrent, automatic, etc.)