ETC++: C++ Library for Concept-Based Expression Templates - Archive ouverte HAL Accéder directement au contenu
Logiciel Année : 2015

ETC++: C++ Library for Concept-Based Expression Templates

Résumé

The ETC++ library, "Expression Templates with Concepts in C++", provides an implementation of expression templates based on concepts to quickly and reliably design an embedded domain specific language (EDSL).

Concepts are likely to be introduced in a future C++ standard. They can be used for constraining template parameters, which enables checking requirements on template parameters sooner in the compilation process, and thus providing more intelligible error messages to the user.

They can also be used in the specialization of templates, thus leading to a better control over the selection of the most appropriate version of a template for a given instantiation. This latter aspect offers new possibilities in the design of template libraries, as it enhances the specialization mechanism of templates, and set it up as a solid alternative to inheritance when static binding can replace dynamic binding.

Expression templates (i.e. templates that represent expressions and are usually built through operator overloading) are useful to develop an EDSL, and can speed up the evaluation of an expression by delaying the evaluation of intermediate operations to avoid unnecessary temporary objects.

This library uses concept-based template specialization to parse expression templates in order to ease the design of an EDSL. It relies on a static variant of the well-known visitor design pattern that replaces the overridden methods in the double dispatch of the original design pattern by template specializations based on concepts. An example of EDSL for linear programming developed with our solution demonstrates that a concept-based design helps producing concise and reliable code.

Dates et versions

hal-02150991 , version 1 (15-06-2019)

Identifiants

  • HAL Id : hal-02150991 , version 1

Citer

Bruno Bachelet, Loïc Yon. ETC++: C++ Library for Concept-Based Expression Templates. 2015. ⟨hal-02150991⟩
208 Consultations
39 Téléchargements

Partager

Gmail Facebook X LinkedIn More