Multi-Dimensional Operator Overloading Example
Matrix example demonstrates how these operators can be overloaded for a two-dimensional type.
Note that this code can be implemented in more efficient ways. For example, instead of constructing a single-element sub-matrix even when operating on a single element, e.g., by
m[i, j], it could apply the operation directly on that element.
writeln(__FUNCTION__)expressions inside the functions have nothing to do with the behavior of the code. They merely help expose the functions that get called behind the scenes for different operator usages.
Also, note that the correctness of dimension values are enforced by template constraints.