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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
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
Abrahams, D., Siek, J.: The Boost Operators library (2002), http://www.boost.org
Alexandrescu, A.: Modern C++ Design: Generic Programming and Design Patterns Applied. Addison-Wesley, Reading (2001)
Austern, M.H.: Generic Programming and the STL. Professional computing series. Addison- Wesley, Reading (1999)
Barton, J., Nackman, L.: Scientific and engineering C++. Addison-Wesley, Reading (1994)
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)
Coplien, J.O.: Curiously recurring template patterns. C++ Report, 24–27 (February1995)
Czarnecki, K., Eisenecker, U.: Generative Programming: Methods, Techniques and Applications. Addison-Wesley, Reading (2000)
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
Ditchfield, G.: Contextual Polymorphism. PhD thesis, University of Waterloo (1994)
Furnish, G.: Disambiguated glommable expression templates. Computers in Physics 11(3), 263–269 (1997)
Furnish, G.: Container-free numerical algorithms in C++. Computers in Physics 12(3), 258–266 (1998)
Furnish, G.: Disambiguated glommable expression templates revisited. C++ Report (May 2000)
Gurtovoy, A., Abrahams, D.: The Boost C++ metaprogramming library (2002), http://www.boost.org/libs/mpl
Järvi, J., Powell, G., Lumsdaine, A.: The Lambda Library: unnamed functions in C++. Software – Practice and Experience 33, 259–291 (2003)
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)
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)
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)
Jones, M.P.: Gofer. In: Documentation distributed with Gofer source. University of Oxford, Oxford (1992)
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)
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)
Jones, M.P.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, pp. 230–244. Springer, Heidelberg (2000)
Jones, S.P., Hughes, J., et al.: Haskell 98: A Non-strict, Purely Functional Language (February 1999), http://www.haskell.org/onlinereport/
Jones, S.P., Jones, M., Meijer, E.: Type classes: an exploration of the design space (June 1997)
Maddock, J.: The Boost static assertion library (2000), http://www.boost.org/libs/static_assert
Maddock, J., Cleary, S., et al.: The Boost type- traits library (2002), http://www.boost.org/libs/type_traits
McNamara, B., Smaragdakis, Y.: Static interfaces in C++. In: 1st Workshop on C++ Template Programming (October 2000)
Musser, D.R., Stepanov, A.: Generic programming. In: ISSAC: Proceedings of the ACM SIGSAM International Symposium on Symbolic and Algebraic Computation (1988)
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
Siek, J.: Boost Concept Check Library. Boost (2000), http://www.boost.org/libs/-concept_check/
Siek, J., Lumsdaine, A.: Concept checking: Binding parametric polymorphism in C++. In: 1st Workshop on C++ Template Programming (October 2000)
Siek, J.G., Lee, L.-Q., Lumsdaine, A.: The Boost Graph Library User Guide and Reference Manual. Addison Wesley Professional, London (2001)
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)
Smith, R.: A default- constructible traits. Thread of Usenet articles in comp. sci. lang. c++.moderated (January 2002)
Strachey, C.: Fundamental concepts in programming languages. In: Lecture Notes for the International Summer School in Computer Programming (August 1967); As cited in [41]
Unruh, E.: Prime number computation. Distributed in the ANSI X3J16-94-0075/ISO WG21- 426 meeting (1994)
Vandevoorde, D., Josuttis, N.M.: C++ Templates: The Complete Guide. Addison-Wesley, Reading (2002)
Veldhuizen, T.L.: Expression templates. C++ Report 7(5), 26–31 (1995); reprinted in C++ Gems, ed. Stanley Lippman
Veldhuizen, T.L.: Using C++ template metaprograms. C++ Report 7(4), 36–43 (1995); reprinted in C++ Gems, ed. Stanley Lippman
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)
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)
Walter, J., Koch, M.: The Boost uBLAS Library. Boost (2002), http://www.boost.org/libs/numeric
Wenzel, M.: Using axiomatic type classes in Isabelle (manual) (1995), http://www.cl.cam.acuk/Research/HVG/Isabelle/docs.html
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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