Paper record
W2913602891Expression templates
Todd L. Veldhuizen
- Year
- 1996
- Venue
- —
- References
- 2
- Cited by
- 386
Details and counts from OpenAlex.
Abstract
: Expression Templates is a new C++ technique for passing expressions as function arguments. The expression can be inlined into the function body, which results in faster and more convenient code than C-style callback functions. This technique can also be used to evaluate vector and matrix expressions in a single pass without temporaries. In preliminary benchmark results, one compiler evaluates vector expressions at 95-99.5% efficiency of hand-coded C using this technique (for long vectors). The speed is 2-15 times that of a conventional C++ vector class. Introduction Passing an expression to a function is a common occurrence. In C, expressions are usually passed using a pointer to a callback function containing the expression. For example, the standard C library routines qsort(), lsearch(), and bsearch() accept an argument int (*cmp)(void*, void*) which points to a user-defined function to compare two elements. Another common example is passing mathematical expressions to functions. ...