DocumentCode :
2911954
Title :
Compile time recursive objects in C++
Author :
Jarvi, Jaakko
Author_Institution :
Turku Centre for Comput. Sci., Finland
fYear :
1998
fDate :
22-25 Sep 1998
Firstpage :
66
Lastpage :
77
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
Keywords :
C language; abstract data types; matrix algebra; object-oriented languages; object-oriented programming; program compilers; software reusability; C++; abstract vector; arbitrary types; class templates; compile time lists; compile time recursive lists; compile time recursive objects; dynamic binding; elementary expressions; generic programming; inheritance; matrices; matrix expressions; member variables; nonzero elements; polymorphism; sparseness pattern; special sparse vectors; static binding; template definitions; template features; template specialisation; zero entries; Computer science; Containers; Functional programming; Performance gain; Programming profession; Runtime; Sparse matrices;
fLanguage :
English
Publisher :
ieee
Conference_Titel :
Technology of Object-Oriented Languages, 1998. TOOLS 27. Proceedings
Conference_Location :
Beijing
Print_ISBN :
0-8186-9096-8
Type :
conf
DOI :
10.1109/TOOLS.1998.713588
Filename :
713588
Link To Document :
بازگشت