Skip to main content

Concept-Controlled Polymorphism

  • Conference paper
Generative Programming and Component Engineering (GPCE 2003)

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

Abstract

Concepts – sets of abstractions related by common requirements – have a central role in generic programming. This paper proposes a general framework for using concepts to control polymorphism in different ways. First, concepts can be used to constrain parametric polymorphism, as exemplified by type classes in Haskell. Second, concepts can be used to provide fine-grained control of function and operator overloading. Finally, generic functions can be overloaded (specialized) based on concepts, rather than simply on types. We describe a C++ implementation of a new mechanism, which we call enable_if, and its role in concept-controlled polymorphism.

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

Access this chapter

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

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Abrahams, D.: Qualified namespaces. Technical Report N1408=02-0066, ISO Programming Language C++ Project (November 2002), http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1408.html

  2. Abrahams, D., Siek, J.: The Boost Operators library (2002), http://www.boost.org

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

    Google Scholar 

  4. Austern, M.H.: Generic Programming and the STL. Professional computing series. Addison- Wesley, Reading (1999)

    Google Scholar 

  5. Barton, J., Nackman, L.: Scientific and engineering C++. Addison-Wesley, Reading (1994)

    Google Scholar 

  6. Baumgartner, G., Russo, V.F.: Signatures: A language extension for improving type abstraction and subtype polymorphism in C++. Software–Practice and Experience 25(8), 863–889 (1995)

    Article  Google Scholar 

  7. Coplien, J.O.: Curiously recurring template patterns. C++ Report, 24–27 (February1995)

    Google Scholar 

  8. Czarnecki, K., Eisenecker, U.: Generative Programming: Methods, Techniques and Applications. Addison-Wesley, Reading (2000)

    Google Scholar 

  9. Dimov, P., Hinnant, H., Abrahams, D.: The forwarding problem: Arguments. Technical Report N1385=02-0043, ISO Programming Language C++ Project (September 2002), http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.html

  10. Ditchfield, G.: Contextual Polymorphism. PhD thesis, University of Waterloo (1994)

    Google Scholar 

  11. Furnish, G.: Disambiguated glommable expression templates. Computers in Physics 11(3), 263–269 (1997)

    Google Scholar 

  12. Furnish, G.: Container-free numerical algorithms in C++. Computers in Physics 12(3), 258–266 (1998)

    Article  Google Scholar 

  13. Furnish, G.: Disambiguated glommable expression templates revisited. C++ Report (May 2000)

    Google Scholar 

  14. Gurtovoy, A., Abrahams, D.: The Boost C++ metaprogramming library (2002), http://www.boost.org/libs/mpl

  15. Järvi, J., Powell, G., Lumsdaine, A.: The Lambda Library: unnamed functions in C++. Software – Practice and Experience 33, 259–291 (2003)

    Article  MATH  Google Scholar 

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

    Google Scholar 

  17. Crotinger, J.A., Cummings, J., Haney, S.W., Humphrey, W.F., Karmesin, S.R., Reynders, J., Smith, S., Williams, T.J.: Generic programming in POOMA and PETE. In: Jazayeri, M., Musser, D.R., Loos, R.G.K. (eds.) Dagstuhl Seminar 1998. LNCS, vol. 1766, p. 218. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  18. Jeffery, D., Henderson, F., Somogyi, Z.: Type classes in Mercury. In: Proceedings of the 23rd Australasian Computer Science Conference, January/February 2000, pp. 128–137 (2000)

    Google Scholar 

  19. Jones, M.P.: Gofer. In: Documentation distributed with Gofer source. University of Oxford, Oxford (1992)

    Google Scholar 

  20. Jones, M.P.: A theory of qualified types. In: Krieg-Brückner, B. (ed.) ESOP 1992. LNCS, vol. 582, pp. 287–306. Springer, Heidelberg (1992)

    Google Scholar 

  21. Jones, M.P.: A system of constructor classes: overloading and implicit higher -order polymorphism. In: FPCA 1993: Conference on Functional Programming and Computer Architecture, pp. 52–61. ACM Press, New York (1993)

    Chapter  Google Scholar 

  22. Jones, M.P.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, pp. 230–244. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  23. Jones, S.P., Hughes, J., et al.: Haskell 98: A Non-strict, Purely Functional Language (February 1999), http://www.haskell.org/onlinereport/

  24. Jones, S.P., Jones, M., Meijer, E.: Type classes: an exploration of the design space (June 1997)

    Google Scholar 

  25. Maddock, J.: The Boost static assertion library (2000), http://www.boost.org/libs/static_assert

  26. Maddock, J., Cleary, S., et al.: The Boost type- traits library (2002), http://www.boost.org/libs/type_traits

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

    Google Scholar 

  28. Musser, D.R., Stepanov, A.: Generic programming. In: ISSAC: Proceedings of the ACM SIGSAM International Symposium on Symbolic and Algebraic Computation (1988)

    Google Scholar 

  29. Scheyen, P., Yu, S., Zhang, M., Zhuang, Q.: Introducing KINDs to C++. Technical Report 366, University of Western Ontario, London, Ontario (May 1993), http://www.csd.uwo.ca/~pete/kc.ps

  30. Siek, J.: Boost Concept Check Library. Boost (2000), http://www.boost.org/libs/-concept_check/

  31. Siek, J., Lumsdaine, A.: Concept checking: Binding parametric polymorphism in C++. In: 1st Workshop on C++ Template Programming (October 2000)

    Google Scholar 

  32. Siek, J.G., Lee, L.-Q., Lumsdaine, A.: The Boost Graph Library User Guide and Reference Manual. Addison Wesley Professional, London (2001)

    Google Scholar 

  33. Siek, J.G., Lumsdaine, A.: A modern framework for portable high performance numerical linear algebra. In: Modern Software Tools for Scientific Computing, Birkhäuser (1999)

    Google Scholar 

  34. Smith, R.: A default- constructible traits. Thread of Usenet articles in comp. sci. lang. c++.moderated (January 2002)

    Google Scholar 

  35. Strachey, C.: Fundamental concepts in programming languages. In: Lecture Notes for the International Summer School in Computer Programming (August 1967); As cited in [41]

    Google Scholar 

  36. Unruh, E.: Prime number computation. Distributed in the ANSI X3J16-94-0075/ISO WG21- 426 meeting (1994)

    Google Scholar 

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

    Google Scholar 

  38. Veldhuizen, T.L.: Expression templates. C++ Report 7(5), 26–31 (1995); reprinted in C++ Gems, ed. Stanley Lippman

    Google Scholar 

  39. Veldhuizen, T.L.: Using C++ template metaprograms. C++ Report 7(4), 36–43 (1995); reprinted in C++ Gems, ed. Stanley Lippman

    Google Scholar 

  40. Veldhuizen, T.L.: Arrays in Blitz++. In: Caromel, D., Oldehoeft, R.R., Tholburn, M. (eds.) ISCOPE 1998. LNCS, vol. 1505, pp. 223–230. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  41. Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad-hoc. In: Symposium on Principles of Programming Languages, January 1989, pp. 60–76. ACM, New York (1989)

    Google Scholar 

  42. Walter, J., Koch, M.: The Boost uBLAS Library. Boost (2002), http://www.boost.org/libs/numeric

  43. Wenzel, M.: Using axiomatic type classes in Isabelle (manual) (1995), http://www.cl.cam.acuk/Research/HVG/Isabelle/docs.html

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2003 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Järvi, J., Willcock, J., Lumsdaine, A. (2003). Concept-Controlled Polymorphism. In: Pfenning, F., Smaragdakis, Y. (eds) Generative Programming and Component Engineering. GPCE 2003. Lecture Notes in Computer Science, vol 2830. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-39815-8_14

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-39815-8_14

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-20102-1

  • Online ISBN: 978-3-540-39815-8

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics