Tuesday, March 4, 2008

Concepts and Generic Programming in C++0x

Bjarne Stroustrup and Herb Sutter

Background
C++ Templates: high-level of abstraction and close to the hardware
Spectacularly bad error messages
Classic example: Primer number calculation during compilation

C++0x: Concepts
“A type system for C++ types”
Combinations of types

Aims and Ideals
Direct expression of intent
Separate checking of template definitions and template uses
No performance degradation
Current templates remain valid
Usable in current toolchain

Status
A design
Implementation of design: ConceptGCC (search ‘WG21’)
Lots of examples, papers, etc

Next: Correctness, Performance, Maintainability, Flexibility/Generality, Compensability

Language features are there to support ways of thinking; shouldn’t/can’t define a programming style simply as using a language feature.
Generic programming is sometimes referred to as “algorithm oriented” as opposed to “object oriented.”

An example, going from concrete to abstract, and how Concepts aim to helps.

Discussion on coding concepts. C++98 STL type traits (documented in the standard in English) are now codified using Concepts.

No comments: