Specifying C++ concepts

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.

[1]  Benjamin C. Pierce,et al.  Local type inference , 1998, POPL '98.

[2]  Bjarne Stroustrup,et al.  Supporting SELL for High-Performance Computing , 2005, LCPC.

[3]  Bjarne Stroustrup The Evolution of C , 1987 .

[4]  Simon L. Peyton Jones,et al.  Associated type synonyms , 2005, ICFP '05.

[5]  Stefan Kaes,et al.  Parametric Overloading in Polymorphic Programming Languages , 1988, ESOP.

[6]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[7]  Bjarne Stroustrup,et al.  Concepts – Design choices for template argument checking , 2003 .

[8]  S. Tucker Taft,et al.  Consolidated Ada Reference Manual Language and Standard Libraries , 2002, Lecture Notes in Computer Science.

[9]  Erhard Plödereder,et al.  Ada 2005 Reference Manual. Language and Standard Libraries - International Standard ISO/IEC 8652/1995 (E) with Technical Corrigendum 1 and Amendment 1 , 2007, Lecture Notes in Computer Science.

[10]  Bjarne Stroustrup The Evolution of C++: 1985 to 1989 , 1989, Comput. Syst..

[11]  J. Y. Girard,et al.  Interpretation fonctionelle et elimination des coupures dans l'aritmetique d'ordre superieur , 1972 .

[12]  Richard D. Jenks,et al.  AXIOM: the scientific computation system , 1992 .

[13]  Simon L. Peyton Jones,et al.  Type classes in Haskell , 1994, TOPL.

[14]  Bjarne Stroustrup,et al.  A Formalism for C , 2005 .

[15]  Michael J. Vilot,et al.  Standard template library , 1996 .

[16]  Matthew Harold Austern,et al.  Generic programming and the STL , 1998 .

[17]  Mark P. Jones Qualified Types: Theory and Practice , 1994 .

[18]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[19]  Bjarne Stroustrup,et al.  Abstraction and the C++ Machine Model , 2004, ICESS.

[20]  Alexander A. Stepanov,et al.  C++ Standard Template Library , 2000 .

[21]  John C. Reynolds,et al.  Towards a theory of type structure , 1974, Symposium on Programming.

[22]  Jaakko Järvi,et al.  A comparative study of language support for generic programming , 2003, OOPSLA '03.

[23]  Lennart Augustsson,et al.  Implementing Haskell overloading , 1993, FPCA '93.

[24]  Douglas Gregor,et al.  Concepts for C++0x Revision 1 , 2005 .

[25]  Bjarne Stroustrup,et al.  The Design and Evolution of C , 1994 .

[26]  Bjarne Stroustrup,et al.  Parameterized Types for C++ , 1989, C++ Conference.

[27]  Bjarne Stroustrup,et al.  A concept design (Rev. 1) , 2005 .

[28]  Simon L. Peyton Jones,et al.  Associated types with class , 2005, POPL '05.

[29]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .