Skip to main content

Towards a General Template Introspection Library

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 3286))

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.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. McNamara, B., Smaragdakis, Y.: Static interfaces in C++. In: First Workshop on C++ Template Metaprogramming (October 2000)

    Google Scholar 

  2. Siek, J., Lumsdaine, A.: Concept checking: Binding parametric polymorphism in C++. In: First Workshop on C++ Template Metaprogramming (October 2000)

    Google Scholar 

  3. Vandevoorde, D., Josuttis, N.M.: C++ Templates: The Complete Guide. Addison-Wesley, Reading (2002)

    Google Scholar 

  4. Alexandrescu, A.: Modern C++ Design: Generic Programming and Design Patterns Applied. Addison-Wesley, Reading (2001)

    Google Scholar 

  5. Czarnecki, K., Eisenecker, U.W.: Generative Programming: Methods, Tools and Applications. Addison-Wesley, Reading (2000)

    Google Scholar 

  6. Stroustrup, B.: The C++ Programming Language Special Edition. Addison-Wesley, Reading (2000)

    Google Scholar 

  7. Stroustrup, B.: The Design and Evolution of C++. Addison-Wesley, Reading (1994)

    Google Scholar 

  8. 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)

    Chapter  Google Scholar 

  9. The Boost Library, http://www.boost.org

  10. The Boost concept checking library, http://www.boost.org/libs/concept_check/concept_check.htm

  11. Austern, M.H.: Generic Programming and the STL. Addison-Wesley, Reading (1999)

    Google Scholar 

  12. Jarvi, J., Willcock, J., Hinnant, H., Lumsdaine, A.: Function overloading based on arbitrary properties of types. C/C++ Users Journal 21, 25–32 (2003)

    Google Scholar 

  13. Pizza Java extension, http://pizzacompiler.sourceforge.net/

  14. Generic Java, http://www.cis.unisa.edu.au/~pizza/gj/

  15. 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)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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

Publish with us

Policies and ethics