Generic Programming: Controlling Static Specialization with Concepts in C++ - Archive ouverte HAL Accéder directement au contenu
Rapport Année : 2012

Generic Programming: Controlling Static Specialization with Concepts in C++

Résumé

In generic programming, software components are parameterized on types (and sometimes static values, as in C++) rather than dynamic values. When available, a static specialization mechanism allows building, for a given set of parameters, a more suitable version of a generic component than its primary version. The normal C++ template specialization mechanism is based on the type pattern (or sometimes the static value) of parameters, which may not be accurate enough and may lead to ambiguities or false specializations. This is mainly due to the fact that some relationships between types, which can be considered as similar in some ways, are missing. Thus, it is not always possible to determine an order of the specializations of a generic component. Concepts can be used to introduce relationships between "similar" types: a concept represents a set of requirements for a component that among others refer to its interface and its behavior. This paper describes generic programming techniques in C++ for declaring concepts, "modeling" relationships (between a type and a concept) and "refinement" relationships (between two concepts), and for controlling template specializations based on a taxonomy of concepts. This control relies on a metaprogram that determines, in a given static specialization context, the most specialized concept of any type instantiating a template parameter. The solution presented here is open for retroactive extension: at any time, a new concept or a new modeling/refinement relationship can be declared, or a new template specialization can be defined; and this new statement will be picked up by the specialization mechanism. The control is also improved by avoiding false specializations and many ambiguities during the specialization process.
Fichier principal
Vignette du fichier
RR-10-18.pdf (276.33 Ko) Télécharger le fichier
Origine : Fichiers produits par l'(les) auteur(s)

Dates et versions

hal-00641006 , version 1 (29-11-2011)
hal-00641006 , version 2 (04-03-2012)
hal-00641006 , version 3 (06-06-2012)
hal-00641006 , version 4 (20-12-2012)
hal-00641006 , version 5 (21-12-2012)

Identifiants

  • HAL Id : hal-00641006 , version 2

Citer

Bruno Bachelet, Antoine Mahul, Loïc Yon. Generic Programming: Controlling Static Specialization with Concepts in C++. 2012. ⟨hal-00641006v2⟩
218 Consultations
1773 Téléchargements

Partager

Gmail Facebook X LinkedIn More