skip to main content
10.1145/1111037.1111064acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article

Specifying C++ concepts

Published:11 January 2006Publication History

ABSTRACT

C++ templates are key to the design of current successful mainstream libraries and systems. They are the basis of programming techniques in diverse areas ranging from conventional general-purpose programming to software for safety-critical embedded systems. Current work on improving templates focuses on the notion of concepts (a type system for templates), which promises significantly improved error diagnostics and increased expressive power such as concept-based overloading and function template partial specialization. This paper presents C++ templates with an emphasis on problems related to separate compilation. We consider the problem of how to express concepts in a precise way that is simple enough to be usable by ordinary programmers. In doing so, we expose a few weakness of the current specification of the C++ standard library and suggest a far more precise and complete specification. We also present a systematic way of translating our proposed concept definitions, based on use-patterns rather than function signatures, into constraint sets that can serve as convenient basis for concept checking in a compiler.

References

  1. Lennart Augustsson. Implementing Haskell Over-loading. In Functional Programming Languages and Computer Architecture, pages 65--73, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Matthew H. Austern. Generic Programming and the STL. Addison-Wesley, October 1998.Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. Associated Type Synonyms. In ACM SIGPLAN International Conference on Functional Programming, Tallinn, Estonia, 2005. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Manuel M. T. Chakravarty, Gabriele Keller, Simon Peyton Jones, and Simon Marlow. Associated Types with Class. ACM SIGPLAN Notices, 40(1):1--13, January 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Gabriel Dos Reis. Generic Programming in C++: The next level. The Association of C and C++ Users Spring Conference, April 2002.Google ScholarGoogle Scholar
  6. Gabriel Dos Reis and Bjarne Stroustrup. A Formalism for C++. Technical Report N1885=05-0145, ISO/IECSC22/JTC1/WG21, October 2005.Google ScholarGoogle Scholar
  7. Gabriel Dos Reis and Bjarne Stroustrup. Specifying C++ Concepts. Technical Report N1886=05-0146, ISO/IEC SC22/JTC1/WG21, October 2005.Google ScholarGoogle Scholar
  8. Jean-Yves Girard. Interprétation fonctionnelle et élimination des coupures de l'arithmétique d'ordre supérieur. Thèse d'État, Université Paris VII, 1972.Google ScholarGoogle Scholar
  9. Ronald Garcia, Jaakko Järvi, Andrew Lumsdaine, Jeremy Siek, and Jeremiah Willcock. A Comparative Study of Language Support for Generic Programming. In Proceedings of the 18th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages and Applications, pages 115--134. ACM Press, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Douglas Gregor, Jeremy Siek, Jeremiah Willcock, Jaakko Järvi, Ronald Garcia, and Andrew Lumsdaine. Concept for C++0x (Revision 1). Technical Report N1849=05-00109, ISO/IEC SC22/JTC1/WG21, August 2005.Google ScholarGoogle Scholar
  11. Cordelia V. Hall, Kevin Hammond, Simon Peyton Jones, and Philip L. Wadler. Type classes in Haskell. ACM Transactions on Programming Languages and Systems, 18(2):109--138, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. International Organization for Standards. International Standard ISO/IEC 14882. Programming Languages - C++, 2nd edition, 2003.Google ScholarGoogle Scholar
  13. Mark P. Jones. Qualified Types: Theory and Practice. Cambridge University Press, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Richard D. Jenks and Robert S. Sutor. AXIOM: The Scientific Computation System. Springer-Verlag, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Stefan Kaes. Parametric Overloading in Polymorphic Programming Languages. In Proceedings of the 2nd European Symposium on Programming, volume 300 of Lecture Notes In Computer Science;, pages 131--144. Springer-Verlag, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Simon Peyton Jones. Haskell 98 Language and Libraries, The Revised Report. Cambridge University Press, 2003.Google ScholarGoogle Scholar
  17. Benjamin C. Pierce and David N. Turner. Local Type Inference. In Symposium on Principles of Programming Languages, pages 252--265, San Diego CA, USA, 1998. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. John Reynolds. Towards a theory of type structure. In Proceedings of Colloque sur la Programmation, volume 19 of Lecture Notes in Computer Science, pages 408--425, New York, 1974. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Bjarne Stroustrup and Gabriel Dos Reis. Concepts - Design choices for template argument checking. Technical Report N1522, ISO/IEC SC22/JTC1/WG21, September 2003.Google ScholarGoogle Scholar
  20. Bjarne Stroustrup and Gabriel Dos Reis. Concepts - syntax and composition. Technical Report N1536, ISO/IEC SC22/JTC1/WG21, September 2003.Google ScholarGoogle Scholar
  21. Bjarne Stroustrup and Gabriel Dos Reis. A Concept Design (rev.1). Technical Report N1782=05-0042, ISO/IEC SC22/JTC1/WG21, April 2005.Google ScholarGoogle Scholar
  22. Bjarne Stroustrup and Gabriel Dos Reis. Supporting SELL for High-Performance Computing. In Proceedings of the 18th International Workshop on Languages and Compilers for Parallel Computing, October 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Jeremy Siek, Douglas Gregor, Ronald Garcia, Jeremiah Willcock, Jaakko Järvi, and Andrew Lumsdaine. Concept for C++0x. Technical Report N1758=05-0018, ISO/IEC SC22/JTC1/WG21, January 2005.Google ScholarGoogle Scholar
  24. Alexander Stepanov and Meng Lee. The Standard Template Library. Technical Report N0482=94-0095, ISO/IEC SC22/JTC1/WG21, May 1994.Google ScholarGoogle Scholar
  25. Bjarne Stroustrup. Technical FAQ: Why can't I define constraints for my template parameters? http://www.research.att.com/~bs/bs_faq2.html#constraints.Google ScholarGoogle Scholar
  26. Bjarne Stroustrup. Parameterized Types for C++. In Proceedings of USENIX C++ Conference, Denver, CO., October 1988.Google ScholarGoogle Scholar
  27. Bjarne Stroustrup. The Evolution of C++: 1985-1989. USENIX Computer Systems, 2(3), 1989.Google ScholarGoogle Scholar
  28. Bjarne Stroustrup. The Design and Evolution of C++. Addison-Wesley, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Bjarne Stroustrup. The C++ Programming Language. Addison-Wesley, special edition, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Bjarne Stroustrup. Concept checking - A more abstract complement to type checking. Technical Report N1510, ISO/IEC SC22/JTC1/WG21, September 2003.Google ScholarGoogle Scholar
  31. Bjarne Stroustrup. Abstraction and the C++ model. In Proceedings of ICESS'04, December 2004.Google ScholarGoogle Scholar
  32. Bjarne Stroustrup. The design of C++0x. C/C++ Users Journal, May 2005.Google ScholarGoogle Scholar
  33. S. Tucker Taft, Robert A. Duff, Randall L. Brukardt, and Erhard Ploederer, editors. Consolidated Ada Reference Manual, volume 2219 of Lecture Notes in Computer Science. Springer, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Philip Wadler and Stephen Blott. How to make ad-hoc polymorphism less ad hoc. In Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 60--76, Austin, Texas, USA, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Specifying C++ concepts

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!