4.2. Expression templates

In Sourcery VSIPL++, the above operators are defined such that they don't evaluate the operation directly. Instead, they return a representation of the operation that can then be evaluated later. Using this technique, an entire expression will map to a single expression object, which then can be evaluated in a single pass, during the assignment.

In other words, all such operators don't return a value, but a parse tree containing its operands, as well as operation

Figure 4.1. Parse tree representation of the expression (a+b)/(c-d)

Parse tree representation of the expression (a+b)/(c-d)

With a suitable definition of those binary operators, this results into a result type like:

Figure 4.2. Expression type generated from the above expression (a+b)/(c-d)

Expression type generated from the above expression (a+b)/(c-d)

If an assignment operator exists that takes such types as input, it may be able to perform a much faster assignment, without any temporaries.