No. 5 June 1995, pp. 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.
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. Another common example is passing mathematical expressions to functions. The problem with callback functions is that repeated calls generate a lot of overhead, especially if the expression which the function evaluates is simple. Callback functions also slow pipelined machines, since the function calls force the processor to stall. The technique of expression templates allows expressions to be passed to functions as an argument and inlined into the function body.