Concepts: First-Class Language Support for Generic Programming in C++Research Paper Thursday, Oct 26, from 10:30 to 12:00
Generic programming has recently emerged as an important technique for the development of highly reusable and efficient software libraries. In C++, generic programming is enabled by the flexibility of templates, the C++ type parameterization mechanism. However, the power of templates comes with a steep price: generic (template) libraries are often much more difficult to use and develop than non-template libraries and their misuse results in notoriously confusing error messages. As currently defined, templates in C++ are unconstrained, and type-checking of templates is performed too late in the compilation process, i.e., after the use of a template has been combined with its definition To improve the support for generic programming in C++, we introduce first class support for concepts, which serve both to express the syntactic and semantic behavior of types and to constrain the type parameters in a C++ template. Using concepts, type-checking of template definitions is separated from their uses, thereby making templates easier to use and easier to compile. These improvements are achieved without limiting the flexibility of templates or decreasing their performance--in fact their expressive power is increased. This paper describes the extended language to support concepts, which we call ConceptC++, its use in the expression of the C++ Standard Template Library, and its implementation in the ConceptGCC compiler. Douglas Gregor, Indiana University Jaakko Jarvi, Texas A&M University Jeremy Siek, Rice University Bjarne Stroustrup, Texas A&M University Gabriel Dos Reis, Texas A&M University Andrew Lumsdaine, Indiana University
|