Compile time recursive objects in C++

J. Jarvi
{"title":"Compile time recursive objects in C++","authors":"J. Jarvi","doi":"10.1109/TOOLS.1998.713588","DOIUrl":null,"url":null,"abstract":"The article explores the possibilities of generic programming offered by the template features of C++. We define compile time recursive objects as instances of class templates which contain other instances of the same template as member variables. With such templates we can define containers that contain objects of arbitrary types, but where the type of each element is known at compile time. The structure of the container is therefore fixed. The technique mimics the polymorphism achieved with dynamic binding and inheritance using static binding and template specialisation. It is obviously less flexible but offers considerable performance gains at runtime. We give the template definitions for compile time recursive lists and explain how to perform operations on these lists. As an example application, we use compile time lists in the definition of templates for special sparse vectors and matrices. In these vectors and matrices, the sparseness pattern can be arbitrary but must be known at compile time. The tracking of zero and nonzero elements is performed at compile time. This allows the programmer to use abstract vector and matrix expressions and still reach performance equal to hand coded operations. This is possible since the compiler can locate the elementary expressions between zero entries and discard them entirely from the resulting code.","PeriodicalId":177805,"journal":{"name":"Proceedings Technology of Object-Oriented Languages. TOOLS 27 (Cat. No.98EX224)","volume":"34 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"1900-01-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"1","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings Technology of Object-Oriented Languages. TOOLS 27 (Cat. No.98EX224)","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1109/TOOLS.1998.713588","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 1

Abstract

The article explores the possibilities of generic programming offered by the template features of C++. We define compile time recursive objects as instances of class templates which contain other instances of the same template as member variables. With such templates we can define containers that contain objects of arbitrary types, but where the type of each element is known at compile time. The structure of the container is therefore fixed. The technique mimics the polymorphism achieved with dynamic binding and inheritance using static binding and template specialisation. It is obviously less flexible but offers considerable performance gains at runtime. We give the template definitions for compile time recursive lists and explain how to perform operations on these lists. As an example application, we use compile time lists in the definition of templates for special sparse vectors and matrices. In these vectors and matrices, the sparseness pattern can be arbitrary but must be known at compile time. The tracking of zero and nonzero elements is performed at compile time. This allows the programmer to use abstract vector and matrix expressions and still reach performance equal to hand coded operations. This is possible since the compiler can locate the elementary expressions between zero entries and discard them entirely from the resulting code.
c++编译时递归对象
本文探讨了c++模板特性提供的泛型编程的可能性。我们将编译时递归对象定义为类模板的实例,其中包含作为成员变量的同一模板的其他实例。使用这样的模板,我们可以定义包含任意类型对象的容器,但其中每个元素的类型在编译时是已知的。因此,容器的结构是固定的。该技术使用静态绑定和模板专门化模拟动态绑定和继承实现的多态性。它显然不那么灵活,但在运行时提供了相当大的性能提升。我们给出了编译时递归列表的模板定义,并解释了如何对这些列表执行操作。作为一个示例应用,我们在定义特殊稀疏向量和矩阵的模板时使用了编译时间列表。在这些向量和矩阵中,稀疏模式可以是任意的,但必须在编译时知道。零和非零元素的跟踪在编译时执行。这允许程序员使用抽象的向量和矩阵表达式,并且仍然达到等同于手工编码操作的性能。这是可能的,因为编译器可以找到零项之间的基本表达式,并从结果代码中完全丢弃它们。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信