Design of Concept Libraries for C++

Andrew Sutton, Bjarne Stroustrup

Research output: Chapter in Book/Report/Conference proceedingChapter

12 Scopus citations

Abstract

We present a set of concepts (requirements on template arguments) for a large subset of the ISO C++ standard library. The goal of our work is twofold: to identify a minimal and useful set of concepts required to constrain the library's generic algorithms and data structures and to gain insights into how best to support such concepts within C++. We start with the design of concepts rather than the design of supporting language features; the language design must be made to fit the concepts, rather than the other way around. A direct result of the experiment is the realization that to simply and elegantly support generic programming we need two kinds of abstractions: constraints are predicates on static properties of a type, and concepts are abstract specifications of an algorithm's syntactic and semantic requirements. Constraints are necessary building blocks of concepts. Semantic properties are represented as axioms. We summarize our approach: concepts = constraints + axioms. This insight is leveraged to develop a library containing only 14 concepts that encompassing the functional, iterator, and algorithm components of the C++ Standard Library (the STL). The concepts are implemented as constraint classes and evaluated using Clang's and GCC's Standard Library test suites. © 2012 Springer-Verlag.
Original languageEnglish (US)
Title of host publicationLecture Notes in Computer Science
PublisherSpringer Nature
Pages97-118
Number of pages22
ISBN (Print)9783642288296
DOIs
StatePublished - 2012
Externally publishedYes

Fingerprint

Dive into the research topics of 'Design of Concept Libraries for C++'. Together they form a unique fingerprint.

Cite this