Abstract
To ensure the correctness of template based constructions in C++, constraints on template parameters are especially useful. Unlike other languages (Ada, Eiffel, etc.), C++ does not directly support checking requirements on template parameters (i.e., concept checking). However, many articles introduce ad hoc solutions based on special language features. In this paper we propose a structure for a general introspection library which supports easy expression and combination of basic orthogonal requirements, providing the possibility to avoid reimplementation of simple checks for every similar concept. Based on these building blocks, it is possible to express highly complex constraints on template parameters, contrary to languages having builtin support for a limited set of constraints only. Our library enables a checking method that takes the advantages of previous solutions, such as REQUIRE-like macros and static interfaces. Our implementation is non-intrusive, relies only on standard C++ language features and results no runtime overhead.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
McNamara, B., Smaragdakis, Y.: Static interfaces in C++. In: First Workshop on C++ Template Metaprogramming (October 2000)
Siek, J., Lumsdaine, A.: Concept checking: Binding parametric polymorphism in C++. In: First Workshop on C++ Template Metaprogramming (October 2000)
Vandevoorde, D., Josuttis, N.M.: C++ Templates: The Complete Guide. Addison-Wesley, Reading (2002)
Alexandrescu, A.: Modern C++ Design: Generic Programming and Design Patterns Applied. Addison-Wesley, Reading (2001)
Czarnecki, K., Eisenecker, U.W.: Generative Programming: Methods, Tools and Applications. Addison-Wesley, Reading (2000)
Stroustrup, B.: The C++ Programming Language Special Edition. Addison-Wesley, Reading (2000)
Stroustrup, B.: The Design and Evolution of C++. Addison-Wesley, Reading (1994)
Jarvi, J., Willcock, J., Lumsdaine, A.: Concept-Controlled Polymorphism. In: Pfenning, F., Smaragdakis, Y. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 228–244. Springer, Heidelberg (2003)
The Boost Library, http://www.boost.org
The Boost concept checking library, http://www.boost.org/libs/concept_check/concept_check.htm
Austern, M.H.: Generic Programming and the STL. Addison-Wesley, Reading (1999)
Jarvi, J., Willcock, J., Hinnant, H., Lumsdaine, A.: Function overloading based on arbitrary properties of types. C/C++ Users Journal 21, 25–32 (2003)
Pizza Java extension, http://pizzacompiler.sourceforge.net/
Generic Java, http://www.cis.unisa.edu.au/~pizza/gj/
Zólyomi, I., Porkoláb, Z.: An extension to the subtype relationship in C++ implemented with template metaprogramming. In: Pfenning, F., Smaragdakis, Y. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 209–227. Springer, Heidelberg (2003)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2004 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Zólyomi, I., Porkoláb, Z. (2004). Towards a General Template Introspection Library. In: Karsai, G., Visser, E. (eds) Generative Programming and Component Engineering. GPCE 2004. Lecture Notes in Computer Science, vol 3286. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-30175-2_14
Download citation
DOI: https://doi.org/10.1007/978-3-540-30175-2_14
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-23580-4
Online ISBN: 978-3-540-30175-2
eBook Packages: Springer Book Archive