Designing expression templates with concepts. (10th March 2017)
- Record Type:
- Journal Article
- Title:
- Designing expression templates with concepts. (10th March 2017)
- Main Title:
- Designing expression templates with concepts
- Authors:
- Bachelet, Bruno
Yon, Loïc - Abstract:
- Summary: 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. This article addresses the design of expression templates (i.e., templates that represent expressions and are usually built through operator overloading) that are useful to develop an embedded domain specific language (EDSL), and can speed up the evaluation of an expression by delaying the evaluation of intermediate operations to avoid unnecessary temporary objects. We propose to use concept‐based template specialization to parse expression templates in order to ease the design of an EDSL. This approach is 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 demonstratesSummary: 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. This article addresses the design of expression templates (i.e., templates that represent expressions and are usually built through operator overloading) that are useful to develop an embedded domain specific language (EDSL), and can speed up the evaluation of an expression by delaying the evaluation of intermediate operations to avoid unnecessary temporary objects. We propose to use concept‐based template specialization to parse expression templates in order to ease the design of an EDSL. This approach is 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. Copyright © 2017 John Wiley & Sons, Ltd. … (more)
- Is Part Of:
- Software, practice & experience. Volume 47:Number 11(2017)
- Journal:
- Software, practice & experience
- Issue:
- Volume 47:Number 11(2017)
- Issue Display:
- Volume 47, Issue 11 (2017)
- Year:
- 2017
- Volume:
- 47
- Issue:
- 11
- Issue Sort Value:
- 2017-0047-0011-0000
- Page Start:
- 1521
- Page End:
- 1537
- Publication Date:
- 2017-03-10
- Subjects:
- generic programming -- template specialization -- concept‐based specialization -- template metaprogramming -- expression templates
Computer software -- Periodicals
Computer programming -- Periodicals
Computer programs -- Periodicals
005.3 - Journal URLs:
- http://onlinelibrary.wiley.com/ ↗
- DOI:
- 10.1002/spe.2483 ↗
- Languages:
- English
- ISSNs:
- 0038-0644
- Deposit Type:
- Legaldeposit
- View Content:
- Available online (eLD content is only available in our Reading Rooms) ↗
- Physical Locations:
- British Library DSC - 8321.453000
British Library DSC - BLDSS-3PM
British Library STI - ELD Digital store - Ingest File:
- 4956.xml