Specifying C++ concepts

  • Authors:
  • Gabriel Dos Reis;Bjarne Stroustrup

  • Affiliations:
  • Texas A&M University;Texas A&M University and AT&T Labs -- Research

  • Venue:
  • Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

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.